When and where to use \\\"
instead. OK if you are like me you will feel just as silly as I did when I realized what I was doing after I found this thread.
If you're making a .json text file/stream and importing the data from there then the main stream answer of just one backslash before the double quotes:\"
is the one you're looking for.
However if you're like me and you're trying to get the w3schools.com "Tryit Editor" to have a double quotes in the output of the JSON.parse(text), then the one you're looking for is the triple backslash double quotes \\\"
. This is because you're building your text string within an HTML <script>
block, and the first double backslash inserts a single backslash into the string variable then the following backslash double quote inserts the double quote into the string so that the resulting script string contains the \"
from the standard answer and the JSON parser will parse this as just the double quotes.
<script>
var text="{";
text += '"quip":"\\\"If nobody is listening, then you\'re likely talking to the wrong audience.\\\""';
text += "}";
var obj=JSON.parse(text);
</script>
+1: since it's a JavaScript text string, a double backslash double quote \\"
would work too; because the double quote does not need escaped within a single quoted string eg '\"'
and '"'
result in the same JS string.
Try below code
String dateStr = "Jul 27, 2011 8:35:29 PM";
DateFormat readFormat = new SimpleDateFormat( "MMM dd, yyyy hh:mm:ss aa");
DateFormat writeFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = readFormat.parse( dateStr );
} catch ( ParseException e ) {
e.printStackTrace();
}
String formattedDate = "";
if( date != null ) {
formattedDate = writeFormat.format( date );
}
System.out.println(formattedDate);
Good Luck!!!
Check for various formats.
Similar to Orland's answer here: https://stackoverflow.com/a/32870380/462781
Combined with Chris' code here: https://stackoverflow.com/a/12121309/462781
If the areas fit in a grid you can overlay the areas by transparent pictures using a width in % that keep their aspect ratio.
.wrapperspace {_x000D_
width: 100%;_x000D_
display: inline-block;_x000D_
position: relative;_x000D_
}_x000D_
.mainspace {_x000D_
position: absolute;_x000D_
top: 0;_x000D_
bottom: 0;_x000D_
right: 0;_x000D_
left: 0;_x000D_
}
_x000D_
<div class="wrapperspace">_x000D_
<img style="float: left;" title="" src="background-image.png" width="100%" />_x000D_
<div class="mainspace">_x000D_
<div>_x000D_
<img src="space-top.png" style="margin-left:6%;width:15%;"/>_x000D_
</div>_x000D_
<div>_x000D_
<a href="http://www.example.com"><img src="space-company.png" style="margin-left:6%;width:15%;"></a>_x000D_
</div>_x000D_
<div>_x000D_
<a href="http://www.example.com"><img src="space-company.png" style="margin-left:6%;width:10%;"></a>_x000D_
<a href="http://www.example.com"><img src="space-company.png" style="width:20%;"></a>_x000D_
</div>_x000D_
</div>_x000D_
</div>
_x000D_
You can use a margin in %. Additionally "space" images can be placed next to each other inside a 3rd level div.
Also note that "in" keyword does not work on arrays. It works on objects only.
propName in myObject
Array inclusion test is
myArray.includes('three');
in terminal do:
sudo mysql -u root -p
enter the password.
select user from mysql.user;
now delete the user 'the_username'
DROP USER the_unername;
replace 'the_username' with the user that you want to delete.
following sequence of commands works (I lose the first line of the data -no header=None present-, but at least it loads):
df = pd.read_csv(filename,
usecols=range(0, 42))
df.columns = ['YR', 'MO', 'DAY', 'HR', 'MIN', 'SEC', 'HUND',
'ERROR', 'RECTYPE', 'LANE', 'SPEED', 'CLASS',
'LENGTH', 'GVW', 'ESAL', 'W1', 'S1', 'W2', 'S2',
'W3', 'S3', 'W4', 'S4', 'W5', 'S5', 'W6', 'S6',
'W7', 'S7', 'W8', 'S8', 'W9', 'S9', 'W10', 'S10',
'W11', 'S11', 'W12', 'S12', 'W13', 'S13', 'W14']
Following does NOT work:
df = pd.read_csv(filename,
names=['YR', 'MO', 'DAY', 'HR', 'MIN', 'SEC', 'HUND',
'ERROR', 'RECTYPE', 'LANE', 'SPEED', 'CLASS',
'LENGTH', 'GVW', 'ESAL', 'W1', 'S1', 'W2', 'S2',
'W3', 'S3', 'W4', 'S4', 'W5', 'S5', 'W6', 'S6',
'W7', 'S7', 'W8', 'S8', 'W9', 'S9', 'W10', 'S10',
'W11', 'S11', 'W12', 'S12', 'W13', 'S13', 'W14'],
usecols=range(0, 42))
CParserError: Error tokenizing data. C error: Expected 53 fields in line 1605634, saw 54 Following does NOT work:
df = pd.read_csv(filename,
header=None)
CParserError: Error tokenizing data. C error: Expected 53 fields in line 1605634, saw 54
Hence, in your problem you have to pass usecols=range(0, 2)
There is no difference in terms of functionality
The addwithvalue
method takes an object as the value. There is no type data type checking. Potentially, that could lead to error if data type does not match with SQL table. The add
method requires that you specify the Database type first. This helps to reduce such errors.
For more detail Please click here
document.getElementById('log').innerHTML += '<br>Some new content!';
_x000D_
<div id="log">initial content</div>
_x000D_
If your TextView has fixed width, alternative solution can be to create a View which will look like an underline and position it right below your TextView.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/myTextView"
android:layout_width="20dp"
android:layout_height="wrap_content"/>
<View
android:layout_width="20dp"
android:layout_height="1dp"
android:layout_below="@+id/myTextView"
android:background="#CCCCCC"/>
</RelativeLayout>
Currently I Use following code :
Bitmap bMap = ThumbnailUtils.createVideoThumbnail(file.getAbsolutePath(), MediaStore.Video.Thumbnails.MICRO_KIND);
But I found better solution with Glide library with following code ( It also cache your image and have better performance than previous approach )
Glide.with(context)
.load(uri)
.placeholder(R.drawable.ic_video_place_holder)
.into(imageView);
You can use the code below:
a {
display: block;
width: 113px;
margin: auto;
}
By setting, in my case, the link to display:block
, it is easier
to position the link.
This works the same when you use a <div>
tag/class.
You can pick any width
you want.
For ICS I´ve implemented your code and made a class that extends AsyncTask
. I hope you appreciate it! Thanks for your code and solution.
public class UpdateApp extends AsyncTask<String,Void,Void>{
private Context context;
public void setContext(Context contextf){
context = contextf;
}
@Override
protected Void doInBackground(String... arg0) {
try {
URL url = new URL(arg0[0]);
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
String PATH = "/mnt/sdcard/Download/";
File file = new File(PATH);
file.mkdirs();
File outputFile = new File(file, "update.apk");
if(outputFile.exists()){
outputFile.delete();
}
FileOutputStream fos = new FileOutputStream(outputFile);
InputStream is = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = is.read(buffer)) != -1) {
fos.write(buffer, 0, len1);
}
fos.close();
is.close();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File("/mnt/sdcard/Download/update.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag android returned a intent error!
context.startActivity(intent);
} catch (Exception e) {
Log.e("UpdateAPP", "Update error! " + e.getMessage());
}
return null;
}
}
To use it, in your main activity call by this way:
atualizaApp = new UpdateApp();
atualizaApp.setContext(getApplicationContext());
atualizaApp.execute("http://serverurl/appfile.apk");
Maven 3 is more restrictive with the POM-Structure. You have to set versions of Plugins for instance.
With maven 3.1 these warnings may break you build. There are more changes between maven2 and maven3: https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes
It's possible to inject instance of ApplicationContext
class by using SpringClassRule
and SpringMethodRule
rules. It might be very handy if you would like to use
another non-Spring runners. Here's an example:
@ContextConfiguration(classes = BeanConfiguration.class)
public static class SpringRuleUsage {
@ClassRule
public static final SpringClassRule springClassRule = new SpringClassRule();
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
@Autowired
private ApplicationContext context;
@Test
public void shouldInjectContext() {
}
}
No, that's about as efficient as you're going to get. You could write a C program which could do the job a little faster (less startup time and processing arguments) but it will probably tend towards the same speed as sed as files get large (and I assume they're large if it's taking a minute).
But your question suffers from the same problem as so many others in that it pre-supposes the solution. If you were to tell us in detail what you're trying to do rather then how, we may be able to suggest a better option.
For example, if this is a file A that some other program B processes, one solution would be to not strip off the first line, but modify program B to process it differently.
Let's say all your programs append to this file A and program B currently reads and processes the first line before deleting it.
You could re-engineer program B so that it didn't try to delete the first line but maintains a persistent (probably file-based) offset into the file A so that, next time it runs, it could seek to that offset, process the line there, and update the offset.
Then, at a quiet time (midnight?), it could do special processing of file A to delete all lines currently processed and set the offset back to 0.
It will certainly be faster for a program to open and seek a file rather than open and rewrite. This discussion assumes you have control over program B, of course. I don't know if that's the case but there may be other possible solutions if you provide further information.
layout works the same as an master page. any css reference that layout has, any child pages will have.
Set the list style and left padding to nothing.
ul {
list-style: none;
padding-left: 0;
}?
ul {_x000D_
list-style: none;_x000D_
padding-left: 0;_x000D_
}
_x000D_
<ul>_x000D_
<li>a</li>_x000D_
<li>b</li>_x000D_
<li>c</li>_x000D_
</ul>
_x000D_
To maintain the bullets you can replace the list-style: none
with list-style-position: inside
or the shorthand list-style: inside
:
ul {
list-style-position: inside;
padding-left: 0;
}
ul {_x000D_
list-style-position: inside;_x000D_
padding-left: 0;_x000D_
}
_x000D_
<ul>_x000D_
<li>a</li>_x000D_
<li>b</li>_x000D_
<li>c</li>_x000D_
</ul>
_x000D_
let dict : [String : Any] = ["FirstName" : "Maninder" , "LastName" : "Singh" , "Address" : "Chandigarh"]
dict.forEach { print($0) }
Result would be
("FirstName", "Maninder") ("LastName", "Singh") ("Address", "Chandigarh")
Fixing Error code 1206: The number of locks exceeds the lock table size.
In my case, I work with MySQL Workbench (5.6.17) running on Windows with WampServer 2.5.
For Windows/WampServer you have to edit the my.ini file (not the my.cnf file)
To locate this file go to Menu Server/Server Status (in MySQL Workbench) and look under Server Directories/ Base Directory
In my.ini file there are defined sections for different settings, look for section [mysqld] (create it if it does not exist) and add the command: innodb_buffer_pool_size=4G
[mysqld]
innodb_buffer_pool_size=4G
The size of the buffer_pool file will depend on your specific machine, in most cases, 2G or 4G will fix the problem.
Remember to restart the server so it takes the new configuration, it corrected the problem for me.
Hope it helps!
In case anyone is still struggling with this, as I was all morning today, I have found a solution that works for me:
Installation instructions:
git clone https://github.com/gstarnberger/uncompyle.git
cd uncompyle/
sudo ./setup.py install
Once the program is installed (note: it will be installed to your system-wide-accessible Python packages, so it should be in your $PATH
), you can recover your Python files like so:
uncompyler.py thank_goodness_this_still_exists.pyc > recovered_file.py
The decompiler adds some noise mostly in the form of comments, however I've found it to be surprisingly clean and faithful to my original code. You will have to remove a little line of text beginning with +++ near the end of the recovered file to be able to run your code.
name
attribute points to the column containing the asociation, i.e. column name of the foreign keyreferencedColumnName
attribute points to the related column in asociated/referenced entity, i.e. column name of the primary keyYou are not required to fill the referencedColumnName
if the referenced entity has single column as PK, because there is no doubt what column it references (i.e. the Address
single column ID).
@ManyToOne
@JoinColumn(name="ADDR_ID")
public Address getAddress() { return address; }
However if the referenced entity has PK that spans multiple columns the order in which you specify @JoinColumn
annotations has significance. It might work without the referencedColumnName
specified, but that is just by luck. So you should map it like this:
@ManyToOne
@JoinColumns({
@JoinColumn(name="ADDR_ID", referencedColumnName="ID"),
@JoinColumn(name="ADDR_ZIP", referencedColumnName="ZIP")
})
public Address getAddress() { return address; }
or in case of ManyToMany
:
@ManyToMany
@JoinTable(
name="CUST_ADDR",
joinColumns=
@JoinColumn(name="CUST_ID"),
inverseJoinColumns={
@JoinColumn(name="ADDR_ID", referencedColumnName="ID"),
@JoinColumn(name="ADDR_ZIP", referencedColumnName="ZIP")
}
)
Two queries generated by Hibernate of the same join table mapping, both without referenced column specified. Only the order of @JoinColumn
annotations were changed.
/* load collection Client.emails */
select
emails0_.id_client as id1_18_1_,
emails0_.rev as rev18_1_,
emails0_.id_email as id3_1_,
email1_.id_email as id1_6_0_
from client_email emails0_
inner join email email1_ on emails0_.id_email=email1_.id_email
where emails0_.id_client='2' and
emails0_.rev='18'
/* load collection Client.emails */
select
emails0_.rev as rev18_1_,
emails0_.id_client as id2_18_1_,
emails0_.id_email as id3_1_,
email1_.id_email as id1_6_0_
from client_email emails0_
inner join email email1_ on emails0_.id_email=email1_.id_email
where emails0_.rev='2' and
emails0_.id_client='18'
We are querying a join table to get client's emails. The {2, 18}
is composite ID of Client. The order of column names is determined by your order of @JoinColumn
annotations. The order of both integers is always the same, probably sorted by hibernate and that's why proper alignment with join table columns is required and we can't or should rely on mapping order.
The interesting thing is the order of the integers does not match the order in which they are mapped in the entity - in that case I would expect {18, 2}
. So it seems the Hibernate is sorting the column names before it use them in query. If this is true and you would order your @JoinColumn
in the same way you would not need referencedColumnName
, but I say this only for illustration.
Properly filled referencedColumnName
attributes result in exactly same query without the ambiguity, in my case the second query (rev = 2
, id_client = 18
).
If you are using Windows, press Control+Alt+Delete
and select Dart Task inside Android Studio & Click End Task
. I tried many times it works.
/^[a-zA-Z]+$/
Off the top of my head.
Edit:
Or if you don't like the weird looking literal syntax you can do it like this
new RegExp("^[a-zA-Z]+$");
Even if negative integer is passed then it will give the negative integer Try This...
public int reverse(int result) {
long newNum=0,old=result;
result=(result>0) ? result:(0-result);
while(result!=0){
newNum*=10;
newNum+=result%10;
result/=10;
if(newNum>Integer.MAX_VALUE||newNum<Integer.MIN_VALUE)
return 0;
}
if(old > 0)
return (int)newNum;
else if(old < 0)
return (int)(newNum*-1);
else
return 0;
}
You can use "<pre>(.*?)</pre>"
, (replacing pre with whatever text you want) and extract the first group (for more specific instructions specify a language) but this assumes the simplistic notion that you have very simple and valid HTML.
As other commenters have suggested, if you're doing something complex, use a HTML parser.
GuySoft's idea is great, but I think the object does not necessarily have to inherit from Thread and start() could be removed from interface:
from threading import Thread
import queue
class ThreadWithReturnValue(object):
def __init__(self, target=None, args=(), **kwargs):
self._que = queue.Queue()
self._t = Thread(target=lambda q,arg1,kwargs1: q.put(target(*arg1, **kwargs1)) ,
args=(self._que, args, kwargs), )
self._t.start()
def join(self):
self._t.join()
return self._que.get()
def foo(bar):
print('hello {0}'.format(bar))
return "foo"
twrv = ThreadWithReturnValue(target=foo, args=('world!',))
print(twrv.join()) # prints foo
Just to make complete all answers, 'drawable' is, literally, a drawable image, not a complete and ready set of pixels, as .png
In other word words, drawable is only for vectorial images, just try right-click on 'drawable' and go New > Vector Asset, it will accept it, while Image Asset won't be added.
The data for 'drawing', generating the image is recorded on a XML file like this:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,
-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,
19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,
1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,
1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,
2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,
1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,
0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,
5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
</vector>
That's the code for ic_android_black_24dp
If its a maven project, add the below dependency in your pom file
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.4</version>
</dependency>
$("ul > li a")
But you would need to set a class on the root ul if you specifically want to target the outermost ul:
<ul class="rootlist">
...
Then it's:
$("ul.rootlist > li a")....
Another way of making sure you only have the root li elements:
$("ul > li a").not("ul li ul a")
It looks kludgy, but it should do the trick
The CSS tag 'margin' is actually a shorthand for the four separate margin values, top/left/bottom/right. Use css('marginTop')
, etc. - note they will have 'px' on the end if you have specified them that way.
Use parseInt()
around the result to turn it in to the number value.
NB. As noted by Omaty, the order of the shorthand 'margin' tag is:
top right bottom left
- the above list was not written in a way intended to be the list order, just a list of that specified in the tag.
Do you mean like this?
var hello1 = document.getElementById('hello1');
hello1.id = btoa(hello1.id);
To further the example, say you wanted to get all elements with the class 'abc'. We can use querySelectorAll()
to accomplish this:
HTML
<div class="abc"></div>
<div class="abc"></div>
JS
var abcElements = document.querySelectorAll('.abc');
// Set their ids
for (var i = 0; i < abcElements.length; i++)
abcElements[i].id = 'abc-' + i;
This will assign the ID 'abc-<index number>'
to each element. So it would come out like this:
<div class="abc" id="abc-0"></div>
<div class="abc" id="abc-1"></div>
To create an element and assign an id
we can use document.createElement()
and then appendChild()
.
var div = document.createElement('div');
div.id = 'hello1';
var body = document.querySelector('body');
body.appendChild(div);
Update
You can set the id
on your element like this if your script is in your HTML file.
<input id="{{str(product["avt"]["fto"])}}" >
<span>New price :</span>
<span class="assign-me">
<script type="text/javascript">
var s = document.getElementsByClassName('assign-me')[0];
s.id = btoa({{str(produit["avt"]["fto"])}});
</script>
Your requirements still aren't 100% clear though.
Put it inside a table and then do on her:
var tabPom = document.getElementById("tabPomId");
$(tabPom ).prop('disabled', true/false);
Are you sure that your configuration file (web.config) is at the right place and the connection string is really in the (generated) file? If you publish your file, the content of web.release.config might be copied.
The configuration and the access to the Connection string looks all right to me. I would always add a providername
<connectionStrings>
<add name="Dbconnection"
connectionString="Server=localhost; Database=OnlineShopping;
Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
I resolved my issue by following correct directions on pyodbc - Building wiki which states:
On Linux, pyodbc is typically built using the unixODBC headers, so you will need unixODBC and its headers installed. On a RedHat/CentOS/Fedora box, this means you would need to install unixODBC-devel:
yum install unixODBC-devel
To merge one branch into another, such as merging "feature_x" branch into "master" branch:
git checkout master
git merge feature_x
This page is the first result for several search engines when looking for "git merge one branch into another". However, the original question is more specific and special case than the title would suggest.
It is also more complex than both the subject and the search expression. As such, this is a minimal but explanatory answer for the benefit of most visitors.
$unit1 = "paragrahp1";
$unit2 = "paragrahp2";
echo '<p>'.$unit1.'</p>';
echo '<p>'.$unit2.'</p>';
Use Tag <p>
always when starting with a new line so you don't need to use /n type syntax.
You will get output from column
value 9 to 26 as you have mentioned OFFSET
as 8
Just simple as this
window.location.href='http://www.google.com/';
Well you seem to have mistaken them both for what they do.
$(window).height()
gets you an unit-less pixel value of the height of the (browser) window aka viewport. With respect to the web browsers the viewport here is visible portion of the canvas(which often is smaller than the document being rendered).
$(document).height()
returns an unit-less pixel value of the height of the document being rendered. However, if the actual document’s body height is less than the viewport height then it will return the viewport height instead.
Hope that clears things a little.
This is my solution:
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
// alert( pattern.test(emailAddress) );
return pattern.test(emailAddress);
};
Found that RegExp over here: http://mdskinner.com/code/email-regex-and-validation-jquery
I have head around lots of solutions and none of them works perfectly. I've used variation of solutions available in my project which is here as below. Please use this code inside class where you are initialising toolbar and drawer layout.
getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
drawerFragment.mDrawerToggle.setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);// show back button
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
} else {
//show hamburger
drawerFragment.mDrawerToggle.setDrawerIndicatorEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
drawerFragment.mDrawerToggle.syncState();
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawerFragment.mDrawerLayout.openDrawer(GravityCompat.START);
}
});
}
}
});
None of the existing answers involve using a comparator, and therefore cannot be used in binary trees or for sorting. So I'm just gonna leave this here:
public static int compareIntArrays(int[] a, int[] b) {
if (a == null) {
return b == null ? 0 : -1;
}
if (b == null) {
return 1;
}
int cmp = a.length - b.length;
if (cmp != 0) {
return cmp;
}
for (int i = 0; i < a.length; i++) {
cmp = Integer.compare(a[i], b[i]);
if (cmp != 0) {
return cmp;
}
}
return 0;
}
using (var file = File.Create("pricequote.txt"))
{
...........
}
using (var file = File.OpenRead("pricequote.txt"))
{
..........
}
Simple, easy and also disposes/cleans up the object once you are done with it.
You can, but you should not https://web.archive.org/web/20151009224806/http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/
Each object in mongo already has an id, and they are sortable in insertion order. What is wrong with getting collection of user objects, iterating over it and use this as incremented ID? Er go for kind of map-reduce job entirely
In addition to other answers here, if the value is an integral constant, a public enum in a class or struct will work. A variable - constant or otherwise - at the root of a namespace is another option, or a static public member of a class or struct is a third option.
MyClass::eSomeConst (enum)
MyNamespace::nSomeValue
MyStruct::nSomeValue (static)
It sets result
to the (unsigned) value resulting from putting the 8 bits of value
in the lowest 8 bits of result
.
The reason something like this is necessary is that byte
is a signed type in Java. If you just wrote:
int result = value;
then result
would end up with the value ff ff ff fe
instead of 00 00 00 fe
. A further subtlety is that the &
is defined to operate only on int
values1, so what happens is:
value
is promoted to an int
(ff ff ff fe
).0xff
is an int
literal (00 00 00 ff
).&
is applied to yield the desired value for result
.(The point is that conversion to int
happens before the &
operator is applied.)
1Well, not quite. The &
operator works on long
values as well, if either operand is a long
. But not on byte
. See the Java Language Specification, sections 15.22.1 and 5.6.2.
In your html :
<a href="javascript:void(0);" ng-click="go_back()">Go Back</a>
On your main controller :
$scope.go_back = function() {
$window.history.back();
};
When user click on Go Back link the controller function is called and it will go back to previous route.
Yes, this is possible. As previously noted by multiple users, there seems to be a problem with excel reading the correct Byte Order Mark when the file is encoded in UTF-8. With UTF-16 it does not seem to have a problem, so it is endemic to UTF-8. The solution I use for this is adding the BOM, TWICE. For this I execute the following sed command twice:
sed -I '1s/^/\xef\xbb\xbf/' *.csv
, where the wildcard can be replaced with any file name. However, this leads to a mutation of the sep= at the beginning of the .csv file. The .csv file will then open normally in excel, but with an extra row with "sep=" in the first cell. The "sep=" can also be removed in the source .csv itself, but when opening the file with VBA the delimiter should be specified:
Workbooks.Open(name, Format:=6, Delimiter:=";", Local:=True)
Format 6 is the .csv format. Set Local to true, in case there are dates in the file. If Local is not set to true the dates will be Americanized, which in some cases will corrupt the .csv format.
I made a little function for this purpose. It searches for a word in the input file and then adds it to the output file.
def searcher(outf, inf, string):
with open(outf, 'a') as f1:
if string in open(inf).read():
f1.write(string)
Not with CSS directly, you could set CSS properties via JavaScript based on the internal contents but in the end you would still need to be operating in the definitions of CSS.
Adding another answer as I think this is a bit simpler. A pull of repo_dest is done into repo_to_import and then a push --set-upstream url:repo_dest master is done.
This method has worked for me importing several smaller repos into a bigger one.
How to import: repo1_to_import to repo_dest
# checkout your repo1_to_import if you don't have it already
git clone url:repo1_to_import repo1_to_import
cd repo1_to_import
# now. pull all of repo_dest
git pull url:repo_dest
ls
git status # shows Your branch is ahead of 'origin/master' by xx commits.
# now push to repo_dest
git push --set-upstream url:repo_dest master
# repeat for other repositories you want to import
Rename or move files and dirs into desired position in original repo before you do the import. e.g.
cd repo1_to_import
mkdir topDir
git add topDir
git mv this that and the other topDir/
git commit -m"move things into topDir in preparation for exporting into new repo"
# now do the pull and push to import
The method described at the following link inspired this answer. I liked it as it seemed more simple. BUT Beware! There be dragons! https://help.github.com/articles/importing-an-external-git-repository git push --mirror url:repo_dest
pushes your local repo history and state to remote (url:repo_dest). BUT it deletes the old history and state of the remote. Fun ensues! :-E
You can use:
=IF(ISBLANK(A1),1,0)
but you should be careful what you mean by empty cell. I've been caught out by this before. If you want to know if a cell is truly blank, isblank
, as above, will work. Unfortunately, you sometimes also need to know if it just contains no useful data.
The expression:
=IF(ISBLANK(A1),TRUE,(TRIM(A1)=""))
will return true for cells that are either truly blank, or contain nothing but white space.
Here's the results when column A
contains varying amounts of spaces, column B
contains the length (so you know how many spaces) and column C
contains the result of the above expression:
<-A-> <-B-> <-C->
0 TRUE
1 TRUE
2 TRUE
3 TRUE
4 TRUE
5 TRUE
a 1 FALSE
<-A-> <-B-> <-C->
To return 1 if the cell is blank or white space and 0 otherwise:
=IF(ISBLANK(A1),1,if(TRIM(A1)="",1,0))
will do the trick.
This trick comes in handy when the cell that you're checking is actually the result of an Excel function. Many Excel functions (such as trim) will return an empty string rather than a blank cell.
You can see this in action with a new sheet. Leave cell A1
as-is and set A2
to =trim(a1)
.
Then set B1
to =isblank(a1)
and B2
to isblank(a2)
. You'll see that the former is true while the latter is false.
The OOM exception could be avoided by following the official guide to load large bitmap.
Don't run your code on the UI Thread. Use AsyncTask instead and you should be fine.
Now in ES6 you can create lazy cached properties. On first use the property evaluates once to become a normal static property. Result: The second time the math function overhead is skipped.
The magic is in the getter.
const foo = {
a: 5,
b: 6,
get c() {
delete this.c;
return this.c = this.a + this.b
}
};
In the arrow getter this
picks up the surrounding lexical scope.
foo // {a: 5, b: 6}
foo.c // 11
foo // {a: 5, b: 6 , c: 11}
For simple cases, I would also suggest looking at XmlOutput a fluent interface for building Xml.
XmlOutput is great for simple Xml creation with readable and maintainable code, while generating valid Xml. The orginal post has some great examples.
If your docker.service
enabled on system startup
$ sudo systemctl enable docker
and your services in your docker-compose.yml
has
restart: always
all of the services run when you reboot your system if you run below command only once
docker-compose up -d
var element = $("#parentDiv .myClassNameOfInterest")
//Extra currency symbol and currency formatting: "€3,311.50":
String result = (Decimal.Parse("000000331150") / 100).ToString("C");
//No currency symbol and no currency formatting: "3311.50"
String result = (Decimal.Parse("000000331150") / 100).ToString("f2");
There's most likely a more elegant way, but this does find every record with a letter in it, both upper or lower case:
select * from your_table
where UPPER(your_field) like '%A%'
or UPPER(your_field) like '%B%'
or UPPER(your_field) like '%C%'
or UPPER(your_field) like '%D%'
or UPPER(your_field) like '%E%'
or UPPER(your_field) like '%F%'
or UPPER(your_field) like '%G%'
or UPPER(your_field) like '%H%'
or UPPER(your_field) like '%I%'
or UPPER(your_field) like '%J%'
or UPPER(your_field) like '%K%'
or UPPER(your_field) like '%L%'
or UPPER(your_field) like '%M%'
or UPPER(your_field) like '%N%'
or UPPER(your_field) like '%O%'
or UPPER(your_field) like '%P%'
or UPPER(your_field) like '%Q%'
or UPPER(your_field) like '%R%'
or UPPER(your_field) like '%S%'
or UPPER(your_field) like '%T%'
or UPPER(your_field) like '%U%'
or UPPER(your_field) like '%V%'
or UPPER(your_field) like '%W%'
or UPPER(your_field) like '%X%'
or UPPER(your_field) like '%Y%'
or UPPER(your_field) like '%Z%'
The AWS cli does this (presumably without fetching and iterating through all keys in the bucket) when you run aws s3 ls s3://my-bucket/
, so I figured there must be a way using boto3.
It looks like they indeed use Prefix and Delimiter - I was able to write a function that would get me all directories at the root level of a bucket by modifying that code a bit:
def list_folders_in_bucket(bucket):
paginator = boto3.client('s3').get_paginator('list_objects')
folders = []
iterator = paginator.paginate(Bucket=bucket, Prefix='', Delimiter='/', PaginationConfig={'PageSize': None})
for response_data in iterator:
prefixes = response_data.get('CommonPrefixes', [])
for prefix in prefixes:
prefix_name = prefix['Prefix']
if prefix_name.endswith('/'):
folders.append(prefix_name.rstrip('/'))
return folders
INT(x) will make difference only in term of display, that is to show the number in x digits, and not restricted to 11. You pair it using ZEROFILL
, which will prepend the zeros until it matches your length.
So, for any number of x in INT(x)
ZEROFILL
will prepend zeros.INT(5) ZEROFILL with the stored value of 32 will show 00032
INT(5) with the stored value of 32 will show 32
INT with the stored value of 32 will show 32
INT(3) ZEROFILL with the stored value of 250000 will show 250000
INT(3) with the stored value of 250000 will show 250000
INT with the stored value of 250000 will show 250000
The actual value stored in database is not affected, the size is still the same, and any calculation will behave normally.
This also applies to BIGINT
, MEDIUMINT
, SMALLINT
, and TINYINT
.
I'd do it this way:
grid1.DataContext = dt.AsEnumerable().Where(x => x < 10).AsEnumerable().CopyToDataTable().AsDataView();
and do whatever query i want between the two AsEnumerable(). If you don't need space for query, you can just do directly this:
grid1.DataContext = dt.AsDataView();
All the previous posts bring valid points, but some don't answer the question precisely.
The question is: Why would someone prefer money when we already know it is a less precise data type and can cause errors if used in complex calculations?
You use money when you won't make complex calculations and can trade this precision for other needs.
For example, when you don't have to make those calculations, and need to import data from valid currency text strings. This automatic conversion works only with MONEY data type:
SELECT CONVERT(MONEY, '$1,000.68')
I know you can make your own import routine. But sometimes you don't want to recreate a import routine with worldwide specific locale formats.
Another example, when you don't have to make those calculations (you need just to store a value) and need to save 1 byte (money takes 8 bytes and decimal(19,4) takes 9 bytes). In some applications (fast CPU, big RAM, slow IO), like just reading huge amount of data, this can be faster too.
If your array is not initialized then it contains randoms values and cannot be checked !
To initialize your array with 0 values:
int array[5] = {0};
Then you can check if the value is 0:
array[4] == 0;
When you compare to NULL, it compares to 0 as the NULL is defined as integer value 0 or 0L.
If you have an array of pointers, better use the nullptr
value to check:
char* array[5] = {nullptr}; // we defined an array of char*, initialized to nullptr
if (array[4] == nullptr)
// do something
Here is a really simple way to do it :)
Clone the repository
git clone <repository_url>
List all branches
git branch -a
Checkout the branch that you want
git checkout <name_of_branch>
Simple & Best way:
onclick="parentNode.remove()"
Deletes the complete parent from html
This worked perfectly for me:
$ git reset -- foo/bar.txt
$ git checkout foo/bar.txt
here I'm providing solution to setup terraform enviroment variable in windows to beginners.
Open system variables, select the path > edit > new > place the terraform.exe file location like > C:\Programfile\terraform\
and Save it.
For example:
let myString = "Hello World"
let myMatch = myString.match(/H.*/)
console.log(myMatch)
Or
let myString = "Hello World"
let myVariable = "H"
let myReg = new RegExp(myVariable + ".*")
let myMatch = myString.match(myReg)
console.log(myMatch)
Even adding responseType, I dealt with it for days with no success. Finally I got it. Make sure that in your backend script you don't define header as -("Content-Type: application/json);
Becuase if you turn it to text but backend asks for json, it will return an error...
Looks fine to me:
You're sure you didn't on the settings globally or something? This is a clean installation of the beta on Windows 7. The developer tools report that the page is defaulting to IE9 Standard Mode.
I just solved this issue. The problem was in version conflict. Nodejs 10 installed with npm. So before installing nodejs - remove old npm. Or remove new node -> remove npm -> install node again.
This is the only way which helped me.
Try (maybe as root)
lsof -i -P
and grep the output for the port you are looking for.
For example to check for port 80 do
lsof -i -P | grep :80
PHPMailer handles errors nicely, also a good script to use for sending mail via SMTP...
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
Here is a demo react_hooks_debug_print.html
in react hooks that is based on Chris's answer. The json data example is from https://json.org/example.html.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- Don't use this in production: -->
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script src="https://raw.githubusercontent.com/cassiozen/React-autobind/master/src/autoBind.js"></script>
<script type="text/babel">
let styles = {
root: { backgroundColor: '#1f4662', color: '#fff', fontSize: '12px', },
header: { backgroundColor: '#193549', padding: '5px 10px', fontFamily: 'monospace', color: '#ffc600', },
pre: { display: 'block', padding: '10px 30px', margin: '0', overflow: 'scroll', }
}
let data = {
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": [
"GML",
"XML"
]
},
"GlossSee": "markup"
}
}
}
}
}
const DebugPrint = () => {
const [show, setShow] = React.useState(false);
return (
<div key={1} style={styles.root}>
<div style={styles.header} onClick={ ()=>{setShow(!show)} }>
<strong>Debug</strong>
</div>
{ show
? (
<pre style={styles.pre}>
{JSON.stringify(data, null, 2) }
</pre>
)
: null
}
</div>
)
}
ReactDOM.render(
<DebugPrint data={data} />,
document.getElementById('root')
);
</script>
</body>
</html>
Or in the following way, add the style into header:
<style>
.root { background-color: #1f4662; color: #fff; fontSize: 12px; }
.header { background-color: #193549; padding: 5px 10px; fontFamily: monospace; color: #ffc600; }
.pre { display: block; padding: 10px 30px; margin: 0; overflow: scroll; }
</style>
And replace DebugPrint
with the follows:
const DebugPrint = () => {
// https://stackoverflow.com/questions/30765163/pretty-printing-json-with-react
const [show, setShow] = React.useState(false);
return (
<div key={1} className='root'>
<div className='header' onClick={ ()=>{setShow(!show)} }>
<strong>Debug</strong>
</div>
{ show
? (
<pre className='pre'>
{JSON.stringify(data, null, 2) }
</pre>
)
: null
}
</div>
)
}
Here's what worked for me:
<pre class="prettyprint linenums">
<code class="language-xml"><?php echo htmlspecialchars(file_get_contents("example.xml"), ENT_QUOTES); ?></code>
</pre>
Using htmlspecialchars will prevent tags from being displayed as html and won't break anything. Note that I'm using Prettyprint to highlight the code ;)
While you could use a continue
, why not just inverse the logic in your if?
while(rs.next())
{
if(!f.exists() || f.isDirectory()){
//proceed
}
}
You don't even need an else {continue;}
as it will continue anyway if the if
conditions are not satisfied.
Create a file named "config.js" in ./src folder with this content:
module.exports = global.config = {
i18n: {
welcome: {
en: "Welcome",
fa: "??? ?????"
}
// rest of your translation object
}
// other global config variables you wish
};
In your main file "index.js" put this line:
import './config';
Everywhere you need your object use this:
global.config.i18n.welcome.en
This is a derivative of @Ralph suggestion that I've been using. Add the c:url
to the top of your JSP.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:url value="/" var="root" />
Then just reference the root variable in your page:
<link rel="stylesheet" href="${root}templates/style/main.css">
As you've indicated, you can't output NULL in an excel formula. I think this has to do with the fact that the formula itself causes the cell to not be able to be NULL. "" is the next best thing, but sometimes it's useful to use 0.
--EDIT--
Based on your comment, you might want to check out this link. http://peltiertech.com/WordPress/mind-the-gap-charting-empty-cells/
It goes in depth on the graphing issues and what the various values represent, and how to manipulate their output on a chart.
I'm not familiar with VSTO I'm afraid. So I won't be much help there. But if you are really placing formulas in the cell, then there really is no way. ISBLANK() only tests to see if a cell is blank or not, it doesn't have a way to make it blank. It's possible to write code in VBA (and VSTO I imagine) that would run on a worksheet_change event and update the various values instead of using formulas. But that would be cumbersome and performance would take a hit.
Assuming the element which is floated and will be centered is a div
with an id="content"
...
<body>
<div id="wrap">
<div id="content">
This will be centered
</div>
</div>
</body>
And apply the following CSS:
#wrap {
float: left;
position: relative;
left: 50%;
}
#content {
float: left;
position: relative;
left: -50%;
}
Here is a good reference regarding that.
Let a
be a string and b
the string you look for. Use a.substr
to get the last n characters of a
and compare them to b (where n is the length of b
)
Or use std::equal
(include <algorithm>
)
Ex:
bool EndsWith(const string& a, const string& b) {
if (b.size() > a.size()) return false;
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
}
Put following line into your ".profile" file.
Open .profile file and copy this line
find ~/ -name '.DS_Store' -delete
When you open terminal window it will automatically delete your .DS_Store file for you.
If you want to solve it in a two-liner you can do it like this:
with open('data.json') as f:
data = [json.loads(line) for line in f]
From the Java EE documentation:
public abstract boolean unique
(Optional) Whether the property is a unique key. This is a shortcut for the UniqueConstraint annotation at the table level and is useful for when the unique key constraint is only a single field. This constraint applies in addition to any constraint entailed by primary key mapping and to constraints specified at the table level.
See doc
you just need to use word boundary (\b
) instead of ^
and $
:
\bgarp\b
Change your Method as following and check it will work
private void initViews() {
inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.id_number_edit_text_custom, this, true);
View view = (View) inflater.inflate(R.layout.main, null);
editText = (EditText) view.findViewById(R.id.id_number_custom);
loadButton = (ImageButton) view.findViewById(R.id.load_data_button);
loadButton.setVisibility(RelativeLayout.INVISIBLE);
loadData();
}
I struggled with redirect not working for very long, none of what mentioned above was working for me, until I tried this:
Change:
return $this->redirect('site/secure');
to:
return $this->redirect(['site/secure']);
In other words, needed to enclose it within [] brackets! I am using PHP 7, might be the reason why?
Here is a way so that when you select an option, it turns black. When you change it back to the placeholder, it turns back into the placeholder color (in this case red).
http://jsfiddle.net/wFP44/166/
It requires the options to have values.
$('select').on('change', function() {_x000D_
if ($(this).val()) {_x000D_
return $(this).css('color', 'black');_x000D_
} else {_x000D_
return $(this).css('color', 'red');_x000D_
}_x000D_
});
_x000D_
select{_x000D_
color: red;_x000D_
}_x000D_
select option { color: black; }
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
<select>_x000D_
<option value="">Pick one...</option>_x000D_
<option value="test1">Test 1</option>_x000D_
<option value="test2">Test 2</option>_x000D_
<option value="test3">Test 3</option>_x000D_
</select>
_x000D_
I had the same problem, and "export LC_ALL=c"
didn't work for me.
Try export LC_ALL="en_US.UTF-8"
(it will work).
I'm assuming that by empty you mean "has no properties of its own".
// Speed up calls to hasOwnProperty
var hasOwnProperty = Object.prototype.hasOwnProperty;
function isEmpty(obj) {
// null and undefined are "empty"
if (obj == null) return true;
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length > 0) return false;
if (obj.length === 0) return true;
// If it isn't an object at this point
// it is empty, but it can't be anything *but* empty
// Is it empty? Depends on your application.
if (typeof obj !== "object") return true;
// Otherwise, does it have any properties of its own?
// Note that this doesn't handle
// toString and valueOf enumeration bugs in IE < 9
for (var key in obj) {
if (hasOwnProperty.call(obj, key)) return false;
}
return true;
}
Examples:
isEmpty(""), // true
isEmpty(33), // true (arguably could be a TypeError)
isEmpty([]), // true
isEmpty({}), // true
isEmpty({length: 0, custom_property: []}), // true
isEmpty("Hello"), // false
isEmpty([1,2,3]), // false
isEmpty({test: 1}), // false
isEmpty({length: 3, custom_property: [1,2,3]}) // false
If you only need to handle ECMAScript5 browsers, you can use Object.getOwnPropertyNames
instead of the hasOwnProperty
loop:
if (Object.getOwnPropertyNames(obj).length > 0) return false;
This will ensure that even if the object only has non-enumerable properties isEmpty
will still give you the correct results.
Use onclick="return location.reload();"
within the button tag.
<button id="refersh-page" name="refersh-page" type="button" onclick="return location.reload();">Refesh Page</button>
It may be worth considering if having your menu without any associated scope is the right way to go. Its not really the angular way.
But, if it is the way you need to go, then you can do it by adding the functions to $rootScope and then within those functions using $broadcast to send events. your controller then uses $on to listen for those events.
Another thing to consider if you do end up having your menu without a scope is that if you have multiple routes, then all of your controllers will have to have their own upate and get functions. (this is assuming you have multiple controllers)
This works on all current browsers on WinXP. Basically just checking what the current backgrond image is. If it's image1, show image2, otherwise show image1.
The jsapi stuff just loads jQuery from the Google CDN (easier for testing a misc file on the desktop).
The replace is for cross-browser compatibility (opera and ie add quotes to the url and firefox, chrome and safari remove quotes).
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.2.6");
google.setOnLoadCallback(function() {
var original_image = 'url(http://stackoverflow.com/Content/img/wmd/link.png)';
var second_image = 'url(http://stackoverflow.com/Content/img/wmd/code.png)';
$('.mydiv').click(function() {
if ($(this).css('background-image').replace(/"/g, '') == original_image) {
$(this).css('background-image', second_image);
} else {
$(this).css('background-image', original_image);
}
return false;
});
});
</script>
<style>
.mydiv {
background-image: url('http://stackoverflow.com/Content/img/wmd/link.png');
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div class="mydiv"> </div>
</body>
</html>
In IIS, you can specify a redirect to "certain" page based on error code. In you example, you can configure 404 - > Your customized 404 error page.
Just use jQuery's attr()
method
$(this).closest("tr").next().show().find('.longboxsmall').attr('disabled', 'disabled');
Alright guys, I found it out! I didn't really need to change the java.library.path but the "Native library location" of sqljdbc.jar
This is the best answer I could find: https://stackoverflow.com/a/958074/2000342
It works now, thanks for the support!
Mutable objects have fields that can be changed, immutable objects have no fields that can be changed after the object is created.
A very simple immutable object is a object without any field. (For example a simple Comparator Implementation).
class Mutable{
private int value;
public Mutable(int value) {
this.value = value;
}
//getter and setter for value
}
class Immutable {
private final int value;
public Immutable(int value) {
this.value = value;
}
//only getter
}
I am using husky and git-branch-is:
As of husky v1+:
// package.json
{
"husky": {
"hooks": {
"post-merge": "(git-branch-is master && npm version minor ||
(git-branch-is dev && npm --no-git-tag-version version patch)",
}
}
}
Prior to husky V1:
"scripts": {
...
"postmerge": "(git-branch-is master && npm version minor ||
(git-branch-is dev && npm --no-git-tag-version version patch)",
...
},
Read more about npm version
Webpack or Vue.js
If you are using webpack or Vue.js, you can display this in the UI using Auto inject version - Webpack plugin
NUXT
In nuxt.config.js
:
var WebpackAutoInject = require('webpack-auto-inject-version');
module.exports = {
build: {
plugins: [
new WebpackAutoInject({
// options
// example:
components: {
InjectAsComment: false
},
}),
]
},
}
Inside your template
for example in the footer:
<p> All rights reserved © 2018 [v[AIV]{version}[/AIV]]</p>
Something like this should work
$code = "screen new file.css";
if (!preg_match("/^[-_a-zA-Z0-9.]+$/", $code))
{
echo "not valid";
}
This will echo "not valid"
If your data is already serialized:
a) send a JSON response
public function someAction()
{
$response = new Response();
$response->setContent(file_get_contents('path/to/file'));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
b) send a JSONP response (with callback)
public function someAction()
{
$response = new Response();
$response->setContent('/**/FUNCTION_CALLBACK_NAME(' . file_get_contents('path/to/file') . ');');
$response->headers->set('Content-Type', 'text/javascript');
return $response;
}
If your data needs be serialized:
c) send a JSON response
public function someAction()
{
$response = new JsonResponse();
$response->setData([some array]);
return $response;
}
d) send a JSONP response (with callback)
public function someAction()
{
$response = new JsonResponse();
$response->setData([some array]);
$response->setCallback('FUNCTION_CALLBACK_NAME');
return $response;
}
e) use groups in Symfony 3.x.x
Create groups inside your Entities
<?php
namespace Mindlahus;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* Some Super Class Name
*
* @ORM able("table_name")
* @ORM\Entity(repositoryClass="SomeSuperClassNameRepository")
* @UniqueEntity(
* fields={"foo", "boo"},
* ignoreNull=false
* )
*/
class SomeSuperClassName
{
/**
* @Groups({"group1", "group2"})
*/
public $foo;
/**
* @Groups({"group1"})
*/
public $date;
/**
* @Groups({"group3"})
*/
public function getBar() // is* methods are also supported
{
return $this->bar;
}
// ...
}
Normalize your Doctrine Object inside the logic of your application
<?php
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
// For annotations
use Doctrine\Common\Annotations\AnnotationReader;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
...
$repository = $this->getDoctrine()->getRepository('Mindlahus:SomeSuperClassName');
$SomeSuperObject = $repository->findOneById($id);
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$encoder = new JsonEncoder();
$normalizer = new ObjectNormalizer($classMetadataFactory);
$callback = function ($dateTime) {
return $dateTime instanceof \DateTime
? $dateTime->format('m-d-Y')
: '';
};
$normalizer->setCallbacks(array('date' => $callback));
$serializer = new Serializer(array($normalizer), array($encoder));
$data = $serializer->normalize($SomeSuperObject, null, array('groups' => array('group1')));
$response = new Response();
$response->setContent($serializer->serialize($data, 'json'));
$response->headers->set('Content-Type', 'application/json');
return $response;
If you want to re-filter the json data you can use following method. Given example is getting all document data from couchdb.
{
Gson gson = new Gson();
String resultJson = restTemplate.getForObject(url+"_all_docs?include_docs=true", String.class);
JSONObject object = (JSONObject) new JSONParser().parse(resultJson);
JSONArray rowdata = (JSONArray) object.get("rows");
List<Object>list=new ArrayList<Object>();
for(int i=0;i<rowdata.size();i++) {
JSONObject index = (JSONObject) rowdata.get(i);
JSONObject data = (JSONObject) index.get("doc");
list.add(data);
}
// convert your list to json
String devicelist = gson.toJson(list);
return devicelist;
}
If the XML have identities with same name in different levels there is a solution. You don´t have to ever submit a raw XML (this PHP SOAP object don´t allows send a RAW XML), so you have to always translate your XML to a array, like the example below:
$originalXML = "
<xml>
<firstClient>
<name>someone</name>
<adress>R. 1001</adress>
</firstClient>
<secondClient>
<name>another one</name>
<adress></adress>
</secondClient>
</xml>"
//Translate the XML above in a array, like PHP SOAP function requires
$myParams = array('firstClient' => array('name' => 'someone',
'adress' => 'R. 1001'),
'secondClient' => array('name' => 'another one',
'adress' => ''));
$webService = new SoapClient($someURL);
$result = $webService->someWebServiceFunction($myParams);
or
$soapUrl = "http://privpakservices.schenker.nu/package/package_1.3/packageservices.asmx?op=SearchCollectionPoint";
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><SearchCollectionPoint xmlns="http://privpakservices.schenker.nu/"><customerID>XXX</customerID><key>XXXXXX-XXXXXX</key><serviceID></serviceID><paramID>0</paramID><address>RiksvŠgen 5</address><postcode>59018</postcode><city>Mantorp</city><maxhits>10</maxhits></SearchCollectionPoint></soap12:Body></soap12:Envelope>';
$headers = array(
"POST /package/package_1.3/packageservices.asmx HTTP/1.1",
"Host: privpakservices.schenker.nu",
"Content-Type: application/soap+xml; charset=utf-8",
"Content-Length: ".strlen($xml_post_string)
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$parser = simplexml_load_string($response2);
:hover
is a pseudoclass, so you can put your CSS declarations there:
a:hover {
color: #f00;
}
You can also use a list of selectors to apply CSS declarations to a hovered element or an element with a certain class:
.some-class,
a:hover {
color: #f00;
}
You could do the opposite of what you proposed.
location (/test)/ {
set $folder $1;
}
location (/test_/something {
set $folder $1;
}
In my case was a misspelling "Custom Class" name. Make sure that you check your storyboard for the custom classes that you defined.
Make the header looks like this for HttpClient in NG5:
let httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'apikey': this.apikey,
'appkey': this.appkey,
}),
params: new HttpParams().set('program_id', this.program_id)
};
You will be able to make api call with your localhost url, it works for me ..
I use SQL::Translator with DBIx::Class
I have DBIx::Class in my toolchain anyway, and combining it with SQL::Translator allows me to convert the schema into lots of different formats. Mostly initialization SQL scripts for different database servers (making it easy to develop on SQLite and move to Postgresql for production) but it can output GraphViz data too, so diagrams are trivial to generate.
To address the --rebase
vs. --merge
option:
Let's say you have super repository A and submodule B and want to do some work in submodule B. You've done your homework and know that after calling
git submodule update
you are in a HEAD-less state, so any commits you do at this point are hard to get back to. So, you've started work on a new branch in submodule B
cd B
git checkout -b bestIdeaForBEver
<do work>
Meanwhile, someone else in project A has decided that the latest and greatest version of B is really what A deserves. You, out of habit, merge the most recent changes down and update your submodules.
<in A>
git merge develop
git submodule update
Oh noes! You're back in a headless state again, probably because B is now pointing to the SHA associated with B's new tip, or some other commit. If only you had:
git merge develop
git submodule update --rebase
Fast-forwarded bestIdeaForBEver to b798edfdsf1191f8b140ea325685c4da19a9d437.
Submodule path 'B': rebased into 'b798ecsdf71191f8b140ea325685c4da19a9d437'
Now that best idea ever for B has been rebased onto the new commit, and more importantly, you are still on your development branch for B, not in a headless state!
(The --merge
will merge changes from beforeUpdateSHA to afterUpdateSHA into your working branch, as opposed to rebasing your changes onto afterUpdateSHA.)
You can use class(x) to check the variable type. If requirement is to check all variables type of a data frame then sapply(x, class) can be used.
Try this:
REGEXP '^[a-z0-9]+$'
As regexp is not case sensitive except for binary fields.
Edit -- just saw your comment about the performance problems associated with a potentially bad piece of input data. I don't know offhand how try/catch on parseInt compares to a regex. I would guess, based on very little hard knowledge, that regexes are not hugely performant, compared to try/catch, in Java.
Anyway, I'd just do this:
public Integer tryParse(Object obj) {
Integer retVal;
try {
retVal = Integer.parseInt((String) obj);
} catch (NumberFormatException nfe) {
retVal = 0; // or null if that is your preference
}
return retVal;
}
i was facing the same thing, with sort of the same .htaccess file for making pretty urls. after some hours of looking around and experimenting. i found out that the error was because of relatively linking files.
the browser will start fetching the same source html file for all the css, js and image files, when i would browse a few steps deep into the server.
to counter this you can either use the <base>
tag on your html source,
<base href="http://localhost/assets/">
and link to files like,
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/script.js"></script>
or use absolute links for all your files.
<link rel="stylesheet" type="text/css" href="http://localhost/assets/css/style.css" />
<script src="http://localhost/assets/js/script.js"></script>
<img src="http://localhost/assets/images/logo.png" />
As you are using Excel you do not need VBA to achieve this, you can simply use the built in "Clean()" function, this removes carriage returns, line feeds etc e.g:
=Clean(MyString)
Oracle has decided to fix Windows XP installation. As of the JRE 8u25 release in 10/15/2014 the code of the installer has been changes so that installation on Windows XP is again possible.
However, this does not mean that Oracle is continuing to support Windows XP. They make no guarantee about current and future releases of JRE8 being compatible with Windows XP. It looks like it's a run at your own risk kind of thing.
See the Oracle blog post here.
You can get the latest JRE8 right off the Oracle downloads site.
There are well maintained libraries that already do this. One example on the npm registry is merge-deep
From IOS7 :
self.navigationController.navigationBar.translucent = YES;
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.view.backgroundColor = [UIColor clearColor];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
Something like:
class TestClass {
private $var1;
private $var2;
private function TestClass($var1, $var2){
$this->var1 = $var1;
$this->var2 = $var2;
}
public static function create($var1, $var2){
if (is_numeric($var1)){
return new TestClass($var1, $var2);
}
else return NULL;
}
}
$myArray = array();
$myArray[] = TestClass::create(15, "asdf");
$myArray[] = TestClass::create(20, "asdfa");
$myArray[] = TestClass::create("a", "abcd");
print_r($myArray);
$myArray = array_filter($myArray, function($e){ return !is_null($e);});
print_r($myArray);
I think that there are situations where this constructions are preferable to arrays. You can move all the checking logic to the class.
Here, before the call to array_filter $myArray has 3 elements. Two correct objects and a NULL. After the call, only the 2 correct elements persist.
Use this query:
DELETE FROM tableName;
Note: To delete some specific record you can give the condition in where clause in the query also.
OR you can use this query also:
truncate tableName;
Also remember that you should not have any relationship with other table. If there will be any foreign key constraint in the table then those record will not be deleted and will give the error.
You can use string.indexOf('a')
.
If the char a
is present in string
:
it returns the the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
Run ps aux | grep nodejs
, find the PID of the process you're looking for, then run kill
starting with SIGTERM (kill -15 25239
). If that doesn't work then use SIGKILL instead, replacing -15
with -9
.
Use Not IsNull(Fields!W_O_Count.Value)
Here I am taking Mobile No From EditText It may start from +91 or 0 but i am getting actual 10 digits. Hope this will help you.
String mob=edit_mobile.getText().toString();
if (mob.length() >= 10) {
if (mob.contains("+91")) {
mob= mob.substring(3, 13);
}
if (mob.substring(0, 1).contains("0")) {
mob= mob.substring(1, 11);
}
if (mob.contains("+")) {
mob= mob.replace("+", "");
}
mob= mob.substring(0, 10);
Log.i("mob", mob);
}
using slice, apply and join method.
var print = Array.prototype.slice.apply( obj );
alert('length='+print.length+' list'+print.join());
You can do the same in python by simply importing the second file, code at the top level will run when imported. I'd suggest this is messy at best, and not a good programming practice. You would be better off organizing your code into modules
Example:
F1.py:
print "Hello, "
import f2
F2.py:
print "World!"
When run:
python ./f1.py
Hello,
World!
Edit to clarify: The part I was suggesting was "messy" is using the import
statement only for the side effect of generating output, not the creation of separate source files.
If using JDBC driver you may use function escape sequence like this:
select {fn MOD(5, 2)}
#Result 1
select mod(5, 2)
#SQL Error [195] [S00010]: 'mod' is not a recognized built-in function name.
just put
$a='Link1';
$b='Link2';
in your pass.php and you will get your answer and do a double quotation in your link.php:
echo '<a href="pass.php?link=' . $a . '">Link 1</a>';
I just want to share my solution, based on some of the functional features of last versions of JavaScript:
var str = "Test abc test test abc test test test abc test test abc";
var result = str.split(' ').reduce((a, b) => {
return b == 'abc' ? a : a + ' ' + b; })
console.warn(result)
You can add this in yourProject/app/build.gradle
inside android{}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
}
package main
import "fmt"
import "strconv"
func FloatToString(input_num float64) string {
// to convert a float number to a string
return strconv.FormatFloat(input_num, 'f', 6, 64)
}
func main() {
fmt.Println(FloatToString(21312421.213123))
}
If you just want as many digits precision as possible, then the special precision -1 uses the smallest number of digits necessary such that ParseFloat will return f exactly. Eg
strconv.FormatFloat(input_num, 'f', -1, 64)
Personally I find fmt
easier to use. (Playground link)
fmt.Printf("x = %.6f\n", 21312421.213123)
Or if you just want to convert the string
fmt.Sprintf("%.6f", 21312421.213123)
You have no need to do your User
class being IDisposable
since the class doesn't acquire any non-managed resources (file, database connection, etc.). Usually, we mark classes as
IDisposable
if they have at least one IDisposable
field or/and property.
When implementing IDisposable
, better put it according Microsoft typical scheme:
public class User: IDisposable {
...
protected virtual void Dispose(Boolean disposing) {
if (disposing) {
// There's no need to set zero empty values to fields
// id = 0;
// name = String.Empty;
// pass = String.Empty;
//TODO: free your true resources here (usually IDisposable fields)
}
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
}
It usually happens when the certificate does not match with the host name.
The solution would be to contact the host and ask it to fix its certificate.
Otherwise you can turn off cURL's verification of the certificate, use the -k
(or --insecure
) option.
Please note that as the option said, it is insecure. You shouldn't use this option because it allows man-in-the-middle attacks and defeats the purpose of HTTPS.
More can be found in here: http://curl.haxx.se/docs/sslcerts.html
Swift 2.0: Coloring Navigation Bar & buttons
navigationController?.navigationBar.barTintColor = UIColor.blueColor()
navigationController?.navigationBar.tintColor = UIColor.whiteColor()
navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
function getDatas() {
let cacheKey = 'memories';
if (cacheKey in localStorage) {
let datas = JSON.parse(localStorage.getItem(cacheKey));
// if expired
if (datas['expires'] < Date.now()) {
localStorage.removeItem(cacheKey);
getDatas()
} else {
setDatas(datas);
}
} else {
$.ajax({
"dataType": "json",
"success": function(datas, textStatus, jqXHR) {
let today = new Date();
datas['expires'] = today.setDate(today.getDate() + 7) // expires in next 7 days
setDatas(datas);
localStorage.setItem(cacheKey, JSON.stringify(datas));
},
"url": "http://localhost/phunsanit/snippets/PHP/json.json_encode.php",
});
}
}
function setDatas(datas) {
// display json as text
$('#datasA').text(JSON.stringify(datas));
// your code here
....
}
// call
getDatas();
If I understood you correctly, you need to convert your NSString
to int
? Try this peace of code:
NSString *stringWithNumberInside = [_returnedArguments objectAtIndex:2];
int number;
sscanf([stringWithNumberInside UTF8String], "%x", &flags);
String.Format("{0:#,###,###.##}", MyNumber)
That will give you commas at the relevant points.
A file can be tracked or not, you use hg add to track a file and hg remove or hg forget to un-track it. Using hg remove without flags will both delete the file and un-track it, hg forget will simply un-track it without deleting it.
I would use VMs. Create an XP (or whatever) VM using VMware Workstation or similar product, and snapshot it. That is your oldest version. Then perform the upgrades one at a time, and snapshot each time. Then you can switch to any snapshot you need later, or clone independent VMs based on all the snapshots so you can run them all at once. You probably want to test on different operating systems as well as different versions, so VMs generalize that solution as well rather than some one-off solution of hacking multiple IEs to coexist on a single instance of Windows.
Two ways.
i. You can put it in ApplicationController and add the filters in the controller
class ApplicationController < ActionController::Base def filter_method end end class FirstController < ApplicationController before_filter :filter_method end class SecondController < ApplicationController before_filter :filter_method end
But the problem here is that this method will be added to all the controllers since all of them extend from application controller
ii. Create a parent controller and define it there
class ParentController < ApplicationController def filter_method end end class FirstController < ParentController before_filter :filter_method end class SecondController < ParentController before_filter :filter_method end
I have named it as parent controller but you can come up with a name that fits your situation properly.
You can also define the filter method in a module and include it in the controllers where you need the filter
Be sure to check out verilog-mode and especially verilog-auto. http://www.veripool.org/wiki/verilog-mode/ It is a verilog mode for emacs, but plugins exist for vi(m?) for example.
An instantiation can be automated with AUTOINST. The comment is expanded with M-x verilog-auto
and can afterwards be manually edited.
subcomponent subcomponent_instance_name(/*AUTOINST*/);
Expanded
subcomponent subcomponent_instance_name (/*AUTOINST*/
//Inputs
.clk, (clk)
.rst_n, (rst_n)
.data_rx (data_rx_1[9:0]),
//Outputs
.data_tx (data_tx[9:0])
);
Implicit wires can be automated with /*AUTOWIRE*/
. Check the link for further information.
This answer is not relevant for particular recepient, but maybe useful for others. I had similiar issue with 'selecting' right 'option' by value returned from database. I solved it by adding additional tag with applied display:none.
<?php
$status = "NOT_ON_LIST";
$text = "<html>
<head>
</head>
<body>
<select id=\"statuses\">
<option value=\"status\" selected=\"selected\" style=\"display:none\">$status</option>
<option value=\"status\">OK</option>
<option value=\"status\">DOWN</option>
<option value=\"status\">UNKNOWN</option>
</select>
</body>
</html>";
print $text;
?>
In case on windows 7 gacutil.exe (to put assembly in GAC) and sn.exe(To ensure uniqueness of assembly) resides at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin
Then go to the path of gacutil as shown below execute the below command after replacing path of your assembly
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin>gacutil /i "replace with path of your assembly to be put into GAC"
int main()
{
int m;
while(cin>>m)
{
}
}
This would read from standard input if it space separated or line separated .
I faced the similar issue on new server that I built through automated scripts via vcenter api. Looks like the "Remote Procedure Call (RPC)" service may not be running on the remote machine. you need to wait for the service to come up to use the Get-WmiObject command. Hence I simply put the script into sleep for sometime and it worked.
I'd use standard javascript:
for (var m in myMap){
for (var i=0;i<myMap[m].length;i++){
... do something with myMap[m][i] ...
}
}
Note the different ways of treating objects and arrays.
This example is explained in the man flock, but it needs some impovements, because we should manage bugs and exit codes:
#!/bin/bash
#set -e this is useful only for very stupid scripts because script fails when anything command exits with status more than 0 !! without possibility for capture exit codes. not all commands exits >0 are failed.
( #start subprocess
# Wait for lock on /var/lock/.myscript.exclusivelock (fd 200) for 10 seconds
flock -x -w 10 200
if [ "$?" != "0" ]; then echo Cannot lock!; exit 1; fi
echo $$>>/var/lock/.myscript.exclusivelock #for backward lockdir compatibility, notice this command is executed AFTER command bottom ) 200>/var/lock/.myscript.exclusivelock.
# Do stuff
# you can properly manage exit codes with multiple command and process algorithm.
# I suggest throw this all to external procedure than can properly handle exit X commands
) 200>/var/lock/.myscript.exclusivelock #exit subprocess
FLOCKEXIT=$? #save exitcode status
#do some finish commands
exit $FLOCKEXIT #return properly exitcode, may be usefull inside external scripts
You can use another method, list processes that I used in the past. But this is more complicated that method above. You should list processes by ps, filter by its name, additional filter grep -v grep for remove parasite nad finally count it by grep -c . and compare with number. Its complicated and uncertain
http://www.gnu.org/software/make/manual/make.html#Recursion
subsystem:
cd subdir && $(MAKE)
or, equivalently, this :
subsystem:
$(MAKE) -C subdir
I could do this with a custom attribute as follows.
[AuthorizeUser(AccessLevel = "Create")]
public ActionResult CreateNewInvoice()
{
//...
return View();
}
Custom Attribute class as follows.
public class AuthorizeUserAttribute : AuthorizeAttribute
{
// Custom property
public string AccessLevel { get; set; }
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
var isAuthorized = base.AuthorizeCore(httpContext);
if (!isAuthorized)
{
return false;
}
string privilegeLevels = string.Join("", GetUserRights(httpContext.User.Identity.Name.ToString())); // Call another method to get rights of the user from DB
return privilegeLevels.Contains(this.AccessLevel);
}
}
You can redirect an unauthorised user in your custom AuthorisationAttribute
by overriding the HandleUnauthorizedRequest
method:
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.Result = new RedirectToRouteResult(
new RouteValueDictionary(
new
{
controller = "Error",
action = "Unauthorised"
})
);
}
Since API 8 (android 2.2) there is a pattern: android.util.Patterns.EMAIL_ADDRESS http://developer.android.com/reference/android/util/Patterns.html
So you can use it to validate yourEmailString:
private boolean isValidEmail(String email) {
Pattern pattern = Patterns.EMAIL_ADDRESS;
return pattern.matcher(email).matches();
}
returns true if the email is valid
UPD: This pattern source code is:
public static final Pattern EMAIL_ADDRESS
= Pattern.compile(
"[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
"\\@" +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
"(" +
"\\." +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
")+"
);
So you can build it yourself for compatibility with API < 8.
If you decide to use ggplot2
, you can set transparency of overlapping points using the alpha
argument.
e.g.
library(ggplot2)
ggplot(diamonds, aes(carat, price)) + geom_point(alpha = 1/40)
As the name suggests 'untracked files' are the files which are not being tracked by git. They are not in your staging area, and were not part of any previous commits. If you want them to be versioned (or to be managed by git) you can do so by telling 'git' by using 'git add'. Check this chapter Recording Changes to the Repository in the Progit book which uses a nice visual to provide a good explanation about recording changes to git repo and also explaining the terms 'tracked' and 'untracked'.
If you are happy just catching Control-C, it's a done deal. If you really want non-blocking I/O but you don't want the curses library, another alternative is to move lock, stock, and barrel to the AT&T sfio
library. It's nice library patterned on C stdio
but more flexible, thread-safe, and performs better. (sfio stands for safe, fast I/O.)
Microsoft SQL (AFAIK) does not allow you to alter the table and add a column after a specific column. Your best bet is using Sql Server Management Studio, or play around with either dropping and re-adding the table, or creating a new table and moving the data over manually. neither are very graceful.
MySQL does however:
ALTER TABLE mytable
ADD COLUMN new_column <type>
AFTER existing_column
If you want to test the apk, just add the -t
command line option.
Example command:
adb install -t .\app-debug.apk
I tried in online compiler https://www.onlinegdb.com/online_c++_compiler
int main()
{
cout<<"Hello World";
int x = 10;
int *p = &x;
printf("\nAddress of x is %p\n", &x); // 0x7ffc7df0ea54
printf("Address of p is %p\n", p); // 0x7ffc7df0ea54
return 0;
}
In order to checkout a git tag , you would execute the following command
git checkout tags/tag-name -b branch-name
eg as mentioned below.
git checkout tags/v1.0 -b v1.0-branch
To fetch the all tags use the command
git fetch --all --tags
You could also use in_array as follows:
<?php
$found = null;
$people = array(3,20,2);
$criminals = array( 2, 4, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
foreach($people as $num) {
if (in_array($num,$criminals)) {
$found[$num] = true;
}
}
var_dump($found);
// array(2) { [20]=> bool(true) [2]=> bool(true) }
While array_intersect is certainly more convenient to use, it turns out that its not really superior in terms of performance. I created this script too:
<?php
$found = null;
$people = array(3,20,2);
$criminals = array( 2, 4, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
$fastfind = array_intersect($people,$criminals);
var_dump($fastfind);
// array(2) { [1]=> int(20) [2]=> int(2) }
Then, I ran both snippets respectively at: http://3v4l.org/WGhO7/perf#tabs and http://3v4l.org/g1Hnu/perf#tabs and checked the performance of each. The interesting thing is that the total CPU time, i.e. user time + system time is the same for PHP5.6 and the memory also is the same. The total CPU time under PHP5.4 is less for in_array than array_intersect, albeit marginally so.
WebElement p= driver.findElement(By.id("your id name"));
p.sendKeys(Keys.chord(Keys.CONTROL, "a"), "55");
I solved this with a static class:
@SuppressWarnings("serial")
public class MimeTypes {
private static final HashMap<String, String> mimeTypes;
static {
mimeTypes = new HashMap<String, String>() {
{
put(".323", "text/h323");
put(".3g2", "video/3gpp2");
put(".3gp", "video/3gpp");
put(".3gp2", "video/3gpp2");
put(".3gpp", "video/3gpp");
put(".7z", "application/x-7z-compressed");
put(".aa", "audio/audible");
put(".AAC", "audio/aac");
put(".aaf", "application/octet-stream");
put(".aax", "audio/vnd.audible.aax");
put(".ac3", "audio/ac3");
put(".aca", "application/octet-stream");
put(".accda", "application/msaccess.addin");
put(".accdb", "application/msaccess");
put(".accdc", "application/msaccess.cab");
put(".accde", "application/msaccess");
put(".accdr", "application/msaccess.runtime");
put(".accdt", "application/msaccess");
put(".accdw", "application/msaccess.webapplication");
put(".accft", "application/msaccess.ftemplate");
put(".acx", "application/internet-property-stream");
put(".AddIn", "text/xml");
put(".ade", "application/msaccess");
put(".adobebridge", "application/x-bridge-url");
put(".adp", "application/msaccess");
put(".ADT", "audio/vnd.dlna.adts");
put(".ADTS", "audio/aac");
put(".afm", "application/octet-stream");
put(".ai", "application/postscript");
put(".aif", "audio/x-aiff");
put(".aifc", "audio/aiff");
put(".aiff", "audio/aiff");
put(".air", "application/vnd.adobe.air-application-installer-package+zip");
put(".amc", "application/x-mpeg");
put(".application", "application/x-ms-application");
put(".art", "image/x-jg");
put(".asa", "application/xml");
put(".asax", "application/xml");
put(".ascx", "application/xml");
put(".asd", "application/octet-stream");
put(".asf", "video/x-ms-asf");
put(".ashx", "application/xml");
put(".asi", "application/octet-stream");
put(".asm", "text/plain");
put(".asmx", "application/xml");
put(".aspx", "application/xml");
put(".asr", "video/x-ms-asf");
put(".asx", "video/x-ms-asf");
put(".atom", "application/atom+xml");
put(".au", "audio/basic");
put(".avi", "video/x-msvideo");
put(".axs", "application/olescript");
put(".bas", "text/plain");
put(".bcpio", "application/x-bcpio");
put(".bin", "application/octet-stream");
put(".bmp", "image/bmp");
put(".c", "text/plain");
put(".cab", "application/octet-stream");
put(".caf", "audio/x-caf");
put(".calx", "application/vnd.ms-office.calx");
put(".cat", "application/vnd.ms-pki.seccat");
put(".cc", "text/plain");
put(".cd", "text/plain");
put(".cdda", "audio/aiff");
put(".cdf", "application/x-cdf");
put(".cer", "application/x-x509-ca-cert");
put(".chm", "application/octet-stream");
put(".class", "application/x-java-applet");
put(".clp", "application/x-msclip");
put(".cmx", "image/x-cmx");
put(".cnf", "text/plain");
put(".cod", "image/cis-cod");
put(".config", "application/xml");
put(".contact", "text/x-ms-contact");
put(".coverage", "application/xml");
put(".cpio", "application/x-cpio");
put(".cpp", "text/plain");
put(".crd", "application/x-mscardfile");
put(".crl", "application/pkix-crl");
put(".crt", "application/x-x509-ca-cert");
put(".cs", "text/plain");
put(".csdproj", "text/plain");
put(".csh", "application/x-csh");
put(".csproj", "text/plain");
put(".css", "text/css");
put(".csv", "text/csv");
put(".cur", "application/octet-stream");
put(".cxx", "text/plain");
put(".dat", "application/octet-stream");
put(".datasource", "application/xml");
put(".dbproj", "text/plain");
put(".dcr", "application/x-director");
put(".def", "text/plain");
put(".deploy", "application/octet-stream");
put(".der", "application/x-x509-ca-cert");
put(".dgml", "application/xml");
put(".dib", "image/bmp");
put(".dif", "video/x-dv");
put(".dir", "application/x-director");
put(".disco", "text/xml");
put(".dll", "application/x-msdownload");
put(".dll.config", "text/xml");
put(".dlm", "text/dlm");
put(".doc", "application/msword");
put(".docm", "application/vnd.ms-word.document.macroEnabled.12");
put(".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
put(".dot", "application/msword");
put(".dotm", "application/vnd.ms-word.template.macroEnabled.12");
put(".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template");
put(".dsp", "application/octet-stream");
put(".dsw", "text/plain");
put(".dtd", "text/xml");
put(".dtsConfig", "text/xml");
put(".dv", "video/x-dv");
put(".dvi", "application/x-dvi");
put(".dwf", "drawing/x-dwf");
put(".dwp", "application/octet-stream");
put(".dxr", "application/x-director");
put(".eml", "message/rfc822");
put(".emz", "application/octet-stream");
put(".eot", "application/octet-stream");
put(".eps", "application/postscript");
put(".etl", "application/etl");
put(".etx", "text/x-setext");
put(".evy", "application/envoy");
put(".exe", "application/octet-stream");
put(".exe.config", "text/xml");
put(".fdf", "application/vnd.fdf");
put(".fif", "application/fractals");
put(".filters", "Application/xml");
put(".fla", "application/octet-stream");
put(".flr", "x-world/x-vrml");
put(".flv", "video/x-flv");
put(".fsscript", "application/fsharp-script");
put(".fsx", "application/fsharp-script");
put(".generictest", "application/xml");
put(".gif", "image/gif");
put(".group", "text/x-ms-group");
put(".gsm", "audio/x-gsm");
put(".gtar", "application/x-gtar");
put(".gz", "application/x-gzip");
put(".h", "text/plain");
put(".hdf", "application/x-hdf");
put(".hdml", "text/x-hdml");
put(".hhc", "application/x-oleobject");
put(".hhk", "application/octet-stream");
put(".hhp", "application/octet-stream");
put(".hlp", "application/winhlp");
put(".hpp", "text/plain");
put(".hqx", "application/mac-binhex40");
put(".hta", "application/hta");
put(".htc", "text/x-component");
put(".htm", "text/html");
put(".html", "text/html");
put(".htt", "text/webviewhtml");
put(".hxa", "application/xml");
put(".hxc", "application/xml");
put(".hxd", "application/octet-stream");
put(".hxe", "application/xml");
put(".hxf", "application/xml");
put(".hxh", "application/octet-stream");
put(".hxi", "application/octet-stream");
put(".hxk", "application/xml");
put(".hxq", "application/octet-stream");
put(".hxr", "application/octet-stream");
put(".hxs", "application/octet-stream");
put(".hxt", "text/html");
put(".hxv", "application/xml");
put(".hxw", "application/octet-stream");
put(".hxx", "text/plain");
put(".i", "text/plain");
put(".ico", "image/x-icon");
put(".ics", "application/octet-stream");
put(".idl", "text/plain");
put(".ief", "image/ief");
put(".iii", "application/x-iphone");
put(".inc", "text/plain");
put(".inf", "application/octet-stream");
put(".inl", "text/plain");
put(".ins", "application/x-internet-signup");
put(".ipa", "application/x-itunes-ipa");
put(".ipg", "application/x-itunes-ipg");
put(".ipproj", "text/plain");
put(".ipsw", "application/x-itunes-ipsw");
put(".iqy", "text/x-ms-iqy");
put(".isp", "application/x-internet-signup");
put(".ite", "application/x-itunes-ite");
put(".itlp", "application/x-itunes-itlp");
put(".itms", "application/x-itunes-itms");
put(".itpc", "application/x-itunes-itpc");
put(".IVF", "video/x-ivf");
put(".jar", "application/java-archive");
put(".java", "application/octet-stream");
put(".jck", "application/liquidmotion");
put(".jcz", "application/liquidmotion");
put(".jfif", "image/pjpeg");
put(".jnlp", "application/x-java-jnlp-file");
put(".jpb", "application/octet-stream");
put(".jpe", "image/jpeg");
put(".jpeg", "image/jpeg");
put(".jpg", "image/jpeg");
put(".js", "application/x-javascript");
put(".json", "application/json");
put(".jsx", "text/jscript");
put(".jsxbin", "text/plain");
put(".latex", "application/x-latex");
put(".library-ms", "application/windows-library+xml");
put(".lit", "application/x-ms-reader");
put(".loadtest", "application/xml");
put(".lpk", "application/octet-stream");
put(".lsf", "video/x-la-asf");
put(".lst", "text/plain");
put(".lsx", "video/x-la-asf");
put(".lzh", "application/octet-stream");
put(".m13", "application/x-msmediaview");
put(".m14", "application/x-msmediaview");
put(".m1v", "video/mpeg");
put(".m2t", "video/vnd.dlna.mpeg-tts");
put(".m2ts", "video/vnd.dlna.mpeg-tts");
put(".m2v", "video/mpeg");
put(".m3u", "audio/x-mpegurl");
put(".m3u8", "audio/x-mpegurl");
put(".m4a", "audio/m4a");
put(".m4b", "audio/m4b");
put(".m4p", "audio/m4p");
put(".m4r", "audio/x-m4r");
put(".m4v", "video/x-m4v");
put(".mac", "image/x-macpaint");
put(".mak", "text/plain");
put(".man", "application/x-troff-man");
put(".manifest", "application/x-ms-manifest");
put(".map", "text/plain");
put(".master", "application/xml");
put(".mda", "application/msaccess");
put(".mdb", "application/x-msaccess");
put(".mde", "application/msaccess");
put(".mdp", "application/octet-stream");
put(".me", "application/x-troff-me");
put(".mfp", "application/x-shockwave-flash");
put(".mht", "message/rfc822");
put(".mhtml", "message/rfc822");
put(".mid", "audio/mid");
put(".midi", "audio/mid");
put(".mix", "application/octet-stream");
put(".mk", "text/plain");
put(".mmf", "application/x-smaf");
put(".mno", "text/xml");
put(".mny", "application/x-msmoney");
put(".mod", "video/mpeg");
put(".mov", "video/quicktime");
put(".movie", "video/x-sgi-movie");
put(".mp2", "video/mpeg");
put(".mp2v", "video/mpeg");
put(".mp3", "audio/mpeg");
put(".mp4", "video/mp4");
put(".mp4v", "video/mp4");
put(".mpa", "video/mpeg");
put(".mpe", "video/mpeg");
put(".mpeg", "video/mpeg");
put(".mpf", "application/vnd.ms-mediapackage");
put(".mpg", "video/mpeg");
put(".mpp", "application/vnd.ms-project");
put(".mpv2", "video/mpeg");
put(".mqv", "video/quicktime");
put(".ms", "application/x-troff-ms");
put(".msi", "application/octet-stream");
put(".mso", "application/octet-stream");
put(".mts", "video/vnd.dlna.mpeg-tts");
put(".mtx", "application/xml");
put(".mvb", "application/x-msmediaview");
put(".mvc", "application/x-miva-compiled");
put(".mxp", "application/x-mmxp");
put(".nc", "application/x-netcdf");
put(".nsc", "video/x-ms-asf");
put(".nws", "message/rfc822");
put(".ocx", "application/octet-stream");
put(".oda", "application/oda");
put(".odc", "text/x-ms-odc");
put(".odh", "text/plain");
put(".odl", "text/plain");
put(".odp", "application/vnd.oasis.opendocument.presentation");
put(".ods", "application/oleobject");
put(".odt", "application/vnd.oasis.opendocument.text");
put(".one", "application/onenote");
put(".onea", "application/onenote");
put(".onepkg", "application/onenote");
put(".onetmp", "application/onenote");
put(".onetoc", "application/onenote");
put(".onetoc2", "application/onenote");
put(".orderedtest", "application/xml");
put(".osdx", "application/opensearchdescription+xml");
put(".p10", "application/pkcs10");
put(".p12", "application/x-pkcs12");
put(".p7b", "application/x-pkcs7-certificates");
put(".p7c", "application/pkcs7-mime");
put(".p7m", "application/pkcs7-mime");
put(".p7r", "application/x-pkcs7-certreqresp");
put(".p7s", "application/pkcs7-signature");
put(".pbm", "image/x-portable-bitmap");
put(".pcast", "application/x-podcast");
put(".pct", "image/pict");
put(".pcx", "application/octet-stream");
put(".pcz", "application/octet-stream");
put(".pdf", "application/pdf");
put(".pfb", "application/octet-stream");
put(".pfm", "application/octet-stream");
put(".pfx", "application/x-pkcs12");
put(".pgm", "image/x-portable-graymap");
put(".pic", "image/pict");
put(".pict", "image/pict");
put(".pkgdef", "text/plain");
put(".pkgundef", "text/plain");
put(".pko", "application/vnd.ms-pki.pko");
put(".pls", "audio/scpls");
put(".pma", "application/x-perfmon");
put(".pmc", "application/x-perfmon");
put(".pml", "application/x-perfmon");
put(".pmr", "application/x-perfmon");
put(".pmw", "application/x-perfmon");
put(".png", "image/png");
put(".pnm", "image/x-portable-anymap");
put(".pnt", "image/x-macpaint");
put(".pntg", "image/x-macpaint");
put(".pnz", "image/png");
put(".pot", "application/vnd.ms-powerpoint");
put(".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12");
put(".potx", "application/vnd.openxmlformats-officedocument.presentationml.template");
put(".ppa", "application/vnd.ms-powerpoint");
put(".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12");
put(".ppm", "image/x-portable-pixmap");
put(".pps", "application/vnd.ms-powerpoint");
put(".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12");
put(".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow");
put(".ppt", "application/vnd.ms-powerpoint");
put(".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12");
put(".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
put(".prf", "application/pics-rules");
put(".prm", "application/octet-stream");
put(".prx", "application/octet-stream");
put(".ps", "application/postscript");
put(".psc1", "application/PowerShell");
put(".psd", "application/octet-stream");
put(".psess", "application/xml");
put(".psm", "application/octet-stream");
put(".psp", "application/octet-stream");
put(".pub", "application/x-mspublisher");
put(".pwz", "application/vnd.ms-powerpoint");
put(".qht", "text/x-html-insertion");
put(".qhtm", "text/x-html-insertion");
put(".qt", "video/quicktime");
put(".qti", "image/x-quicktime");
put(".qtif", "image/x-quicktime");
put(".qtl", "application/x-quicktimeplayer");
put(".qxd", "application/octet-stream");
put(".ra", "audio/x-pn-realaudio");
put(".ram", "audio/x-pn-realaudio");
put(".rar", "application/octet-stream");
put(".ras", "image/x-cmu-raster");
put(".rat", "application/rat-file");
put(".rc", "text/plain");
put(".rc2", "text/plain");
put(".rct", "text/plain");
put(".rdlc", "application/xml");
put(".resx", "application/xml");
put(".rf", "image/vnd.rn-realflash");
put(".rgb", "image/x-rgb");
put(".rgs", "text/plain");
put(".rm", "application/vnd.rn-realmedia");
put(".rmi", "audio/mid");
put(".rmp", "application/vnd.rn-rn_music_package");
put(".roff", "application/x-troff");
put(".rpm", "audio/x-pn-realaudio-plugin");
put(".rqy", "text/x-ms-rqy");
put(".rtf", "application/rtf");
put(".rtx", "text/richtext");
put(".ruleset", "application/xml");
put(".s", "text/plain");
put(".safariextz", "application/x-safari-safariextz");
put(".scd", "application/x-msschedule");
put(".sct", "text/scriptlet");
put(".sd2", "audio/x-sd2");
put(".sdp", "application/sdp");
put(".sea", "application/octet-stream");
put(".searchConnector-ms", "application/windows-search-connector+xml");
put(".setpay", "application/set-payment-initiation");
put(".setreg", "application/set-registration-initiation");
put(".settings", "application/xml");
put(".sgimb", "application/x-sgimb");
put(".sgml", "text/sgml");
put(".sh", "application/x-sh");
put(".shar", "application/x-shar");
put(".shtml", "text/html");
put(".sit", "application/x-stuffit");
put(".sitemap", "application/xml");
put(".skin", "application/xml");
put(".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12");
put(".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide");
put(".slk", "application/vnd.ms-excel");
put(".sln", "text/plain");
put(".slupkg-ms", "application/x-ms-license");
put(".smd", "audio/x-smd");
put(".smi", "application/octet-stream");
put(".smx", "audio/x-smd");
put(".smz", "audio/x-smd");
put(".snd", "audio/basic");
put(".snippet", "application/xml");
put(".snp", "application/octet-stream");
put(".sol", "text/plain");
put(".sor", "text/plain");
put(".spc", "application/x-pkcs7-certificates");
put(".spl", "application/futuresplash");
put(".src", "application/x-wais-source");
put(".srf", "text/plain");
put(".SSISDeploymentManifest", "text/xml");
put(".ssm", "application/streamingmedia");
put(".sst", "application/vnd.ms-pki.certstore");
put(".stl", "application/vnd.ms-pki.stl");
put(".sv4cpio", "application/x-sv4cpio");
put(".sv4crc", "application/x-sv4crc");
put(".svc", "application/xml");
put(".swf", "application/x-shockwave-flash");
put(".t", "application/x-troff");
put(".tar", "application/x-tar");
put(".tcl", "application/x-tcl");
put(".testrunconfig", "application/xml");
put(".testsettings", "application/xml");
put(".tex", "application/x-tex");
put(".texi", "application/x-texinfo");
put(".texinfo", "application/x-texinfo");
put(".tgz", "application/x-compressed");
put(".thmx", "application/vnd.ms-officetheme");
put(".thn", "application/octet-stream");
put(".tif", "image/tiff");
put(".tiff", "image/tiff");
put(".tlh", "text/plain");
put(".tli", "text/plain");
put(".toc", "application/octet-stream");
put(".tr", "application/x-troff");
put(".trm", "application/x-msterminal");
put(".trx", "application/xml");
put(".ts", "video/vnd.dlna.mpeg-tts");
put(".tsv", "text/tab-separated-values");
put(".ttf", "application/octet-stream");
put(".tts", "video/vnd.dlna.mpeg-tts");
put(".txt", "text/plain");
put(".u32", "application/octet-stream");
put(".uls", "text/iuls");
put(".user", "text/plain");
put(".ustar", "application/x-ustar");
put(".vb", "text/plain");
put(".vbdproj", "text/plain");
put(".vbk", "video/mpeg");
put(".vbproj", "text/plain");
put(".vbs", "text/vbscript");
put(".vcf", "text/x-vcard");
put(".vcproj", "Application/xml");
put(".vcs", "text/plain");
put(".vcxproj", "Application/xml");
put(".vddproj", "text/plain");
put(".vdp", "text/plain");
put(".vdproj", "text/plain");
put(".vdx", "application/vnd.ms-visio.viewer");
put(".vml", "text/xml");
put(".vscontent", "application/xml");
put(".vsct", "text/xml");
put(".vsd", "application/vnd.visio");
put(".vsi", "application/ms-vsi");
put(".vsix", "application/vsix");
put(".vsixlangpack", "text/xml");
put(".vsixmanifest", "text/xml");
put(".vsmdi", "application/xml");
put(".vspscc", "text/plain");
put(".vss", "application/vnd.visio");
put(".vsscc", "text/plain");
put(".vssettings", "text/xml");
put(".vssscc", "text/plain");
put(".vst", "application/vnd.visio");
put(".vstemplate", "text/xml");
put(".vsto", "application/x-ms-vsto");
put(".vsw", "application/vnd.visio");
put(".vsx", "application/vnd.visio");
put(".vtx", "application/vnd.visio");
put(".wav", "audio/wav");
put(".wave", "audio/wav");
put(".wax", "audio/x-ms-wax");
put(".wbk", "application/msword");
put(".wbmp", "image/vnd.wap.wbmp");
put(".wcm", "application/vnd.ms-works");
put(".wdb", "application/vnd.ms-works");
put(".wdp", "image/vnd.ms-photo");
put(".webarchive", "application/x-safari-webarchive");
put(".webtest", "application/xml");
put(".wiq", "application/xml");
put(".wiz", "application/msword");
put(".wks", "application/vnd.ms-works");
put(".WLMP", "application/wlmoviemaker");
put(".wlpginstall", "application/x-wlpg-detect");
put(".wlpginstall3", "application/x-wlpg3-detect");
put(".wm", "video/x-ms-wm");
put(".wma", "audio/x-ms-wma");
put(".wmd", "application/x-ms-wmd");
put(".wmf", "application/x-msmetafile");
put(".wml", "text/vnd.wap.wml");
put(".wmlc", "application/vnd.wap.wmlc");
put(".wmls", "text/vnd.wap.wmlscript");
put(".wmlsc", "application/vnd.wap.wmlscriptc");
put(".wmp", "video/x-ms-wmp");
put(".wmv", "video/x-ms-wmv");
put(".wmx", "video/x-ms-wmx");
put(".wmz", "application/x-ms-wmz");
put(".wpl", "application/vnd.ms-wpl");
put(".wps", "application/vnd.ms-works");
put(".wri", "application/x-mswrite");
put(".wrl", "x-world/x-vrml");
put(".wrz", "x-world/x-vrml");
put(".wsc", "text/scriptlet");
put(".wsdl", "text/xml");
put(".wvx", "video/x-ms-wvx");
put(".x", "application/directx");
put(".xaf", "x-world/x-vrml");
put(".xaml", "application/xaml+xml");
put(".xap", "application/x-silverlight-app");
put(".xbap", "application/x-ms-xbap");
put(".xbm", "image/x-xbitmap");
put(".xdr", "text/plain");
put(".xht", "application/xhtml+xml");
put(".xhtml", "application/xhtml+xml");
put(".xla", "application/vnd.ms-excel");
put(".xlam", "application/vnd.ms-excel.addin.macroEnabled.12");
put(".xlc", "application/vnd.ms-excel");
put(".xld", "application/vnd.ms-excel");
put(".xlk", "application/vnd.ms-excel");
put(".xll", "application/vnd.ms-excel");
put(".xlm", "application/vnd.ms-excel");
put(".xls", "application/vnd.ms-excel");
put(".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12");
put(".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12");
put(".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
put(".xlt", "application/vnd.ms-excel");
put(".xltm", "application/vnd.ms-excel.template.macroEnabled.12");
put(".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template");
put(".xlw", "application/vnd.ms-excel");
put(".xml", "text/xml");
put(".xmta", "application/xml");
put(".xof", "x-world/x-vrml");
put(".XOML", "text/plain");
put(".xpm", "image/x-xpixmap");
put(".xps", "application/vnd.ms-xpsdocument");
put(".xrm-ms", "text/xml");
put(".xsc", "application/xml");
put(".xsd", "text/xml");
put(".xsf", "text/xml");
put(".xsl", "text/xml");
put(".xslt", "text/xml");
put(".xsn", "application/octet-stream");
put(".xss", "application/xml");
put(".xtp", "application/octet-stream");
put(".xwd", "image/x-xwindowdump");
put(".z", "application/x-compress");
put(".zip", "application/x-zip-compressed");
}
};
}
public static String getMimeType(String extension) {
if (extension == null) {
return null;
}
if (!extension.startsWith(".")) {
extension = "." + extension.toLowerCase(Locale.getDefault());
}
String mime = mimeTypes.get(extension);
return mime != null ? mime : "application/octet-stream";
}
}
Try:
ls -1 | grep -E "\.tar\.gz$" | xargs -n 1 tar xvfz
Then Try:
ls -1 | grep -E "\.tar\.gz$" | xargs -n 1 rm
This will untar all .tar.gz files in the current directory and then delete all the .tar.gz files. If you want an explanation, the "|" takes the stdout of the command before it, and uses that as the stdin of the command after it. Use "man command" w/o the quotes to figure out what those commands and arguments do. Or, you can research online.
What the provided links to comparisons/animations do not consider is when the amount of data exceed available memory --- at which point the number of passes over the data, i.e. I/O-costs, dominate the runtime. If you need to do that, read up on "external sorting" which usually cover variants of merge- and heap sorts.
http://corte.si/posts/code/visualisingsorting/index.html and http://corte.si/posts/code/timsort/index.html also have some cool images comparing various sorting algorithms.
The recommended way to create random integers with NumPy these days is to use numpy.random.Generator.integers
. (documentation)
import numpy as np
import pandas as pd
rng = np.random.default_rng()
df = pd.DataFrame(rng.integers(0, 100, size=(100, 4)), columns=list('ABCD'))
df
----------------------
A B C D
0 58 96 82 24
1 21 3 35 36
2 67 79 22 78
3 81 65 77 94
4 73 6 70 96
... ... ... ... ...
95 76 32 28 51
96 33 68 54 77
97 76 43 57 43
98 34 64 12 57
99 81 77 32 50
100 rows × 4 columns
You need to install all necessary packages with Android SDK Manager:
Android SDK Tools
Android SDK Platform-tools
Android SDK Build-tools
SDK Platform
ARM\Intel System Image
Android Support Repository
Android Support Library
The default namespace in Python is "__main__"
. When you use import scipy
, Python creates a separate namespace as your module name.
The rule in Pyhton is: when you want to call an attribute from another namespaces you have to use the fully qualified attribute name.
Simply declare this code to get device width
let deviceWidth = Dimensions.get('window').width
Maybe it's obviously but, Dimensions is an react-native import
import { Dimensions } from 'react-native'
Dimensions will not work without that
I'd recommend graphviz highly when you get to the point where you want to render your graphs.
And its companions: take a look at Laszlo Szathmary's GraphViz class, along with notugly.xls.
(Following is a late but complete answer)
FileReader.readAsBinaryString()
is deprecated. Don't use it! It's no longer in the W3C File API working draft:
void abort();
void readAsArrayBuffer(Blob blob);
void readAsText(Blob blob, optional DOMString encoding);
void readAsDataURL(Blob blob);
NB: Note that File
is a kind of extended Blob
structure.
Mozilla still implements readAsBinaryString()
and describes it in MDN FileApi documentation:
void abort();
void readAsArrayBuffer(in Blob blob); Requires Gecko 7.0
void readAsBinaryString(in Blob blob);
void readAsDataURL(in Blob file);
void readAsText(in Blob blob, [optional] in DOMString encoding);
The reason behind readAsBinaryString()
deprecation is in my opinion the following: the standard for JavaScript strings are DOMString
which only accept UTF-8 characters, NOT random binary data. So don't use readAsBinaryString(), that's not safe and ECMAScript-compliant at all.
We know that JavaScript strings are not supposed to store binary data but Mozilla in some sort can. That's dangerous in my opinion. Blob
and typed arrays
(ArrayBuffer
and the not-yet-implemented but not necessary StringView
) were invented for one purpose: allow the use of pure binary data, without UTF-8 strings restrictions.
XMLHttpRequest.send()
has the following invocations options:
void send();
void send(ArrayBuffer data);
void send(Blob data);
void send(Document data);
void send(DOMString? data);
void send(FormData data);
XMLHttpRequest.sendAsBinary()
has the following invocations options:
void sendAsBinary( in DOMString body );
sendAsBinary() is NOT a standard and may not be supported in Chrome.
So you have several options:
send()
the FileReader.result
of FileReader.readAsArrayBuffer ( fileObject )
. It is more complicated to manipulate (you'll have to make a separate send() for it) but it's the RECOMMENDED APPROACH.send()
the FileReader.result
of FileReader.readAsDataURL( fileObject )
. It generates useless overhead and compression latency, requires a decompression step on the server-side BUT it's easy to manipulate as a string in Javascript.sendAsBinary()
the FileReader.result
of FileReader.readAsBinaryString( fileObject )
MDN states that:
The best way to send binary content (like in files upload) is using ArrayBuffers or Blobs in conjuncton with the send() method. However, if you want to send a stringifiable raw data, use the sendAsBinary() method instead, or the StringView (Non native) typed arrays superclass.
merge into x as target using y as Source on target.ID = Source.ID
when not matched by target then insert
when matched then update
when not matched by source and target.ID is not null then
update whatevercolumn = 'isdeleted' ;
It's not generally correct that you can "remove an item from a database" with both methods. To be precise it is like so:
ObjectContext.DeleteObject(entity)
marks the entity as Deleted
in the context. (It's EntityState
is Deleted
after that.) If you call SaveChanges
afterwards EF sends a SQL DELETE
statement to the database. If no referential constraints in the database are violated the entity will be deleted, otherwise an exception is thrown.
EntityCollection.Remove(childEntity)
marks the relationship between parent and childEntity
as Deleted
. If the childEntity
itself is deleted from the database and what exactly happens when you call SaveChanges
depends on the kind of relationship between the two:
If the relationship is optional, i.e. the foreign key that refers from the child to the parent in the database allows NULL
values, this foreign will be set to null and if you call SaveChanges
this NULL
value for the childEntity
will be written to the database (i.e. the relationship between the two is removed). This happens with a SQL UPDATE
statement. No DELETE
statement occurs.
If the relationship is required (the FK doesn't allow NULL
values) and the relationship is not identifying (which means that the foreign key is not part of the child's (composite) primary key) you have to either add the child to another parent or you have to explicitly delete the child (with DeleteObject
then). If you don't do any of these a referential constraint is violated and EF will throw an exception when you call SaveChanges
- the infamous "The relationship could not be changed because one or more of the foreign-key properties is non-nullable" exception or similar.
If the relationship is identifying (it's necessarily required then because any part of the primary key cannot be NULL
) EF will mark the childEntity
as Deleted
as well. If you call SaveChanges
a SQL DELETE
statement will be sent to the database. If no other referential constraints in the database are violated the entity will be deleted, otherwise an exception is thrown.
I am actually a bit confused about the Remarks section on the MSDN page you have linked because it says: "If the relationship has a referential integrity constraint, calling the Remove method on a dependent object marks both the relationship and the dependent object for deletion.". This seems unprecise or even wrong to me because all three cases above have a "referential integrity constraint" but only in the last case the child is in fact deleted. (Unless they mean with "dependent object" an object that participates in an identifying relationship which would be an unusual terminology though.)
jQuery("#your_div_id").remove(); will completely remove the corresponding elements from the HTML DOM. So if you want to show the div on another event without a refresh, it will not be possible to retrieve the removed elements back unless you use AJAX.
jQuery("#your_div_id").toggle("slow"); will also could make unexpected results. As an Example when you select some element on your div which generates another div with a close button(which uses the same close functionality just as your previous div) it could make undesired behaviour.
So without using AJAX, a good solution for the close button would be as follows
HTML____________
<div id="your_div_id">
<span class="close_div" onclick="close_div(1)">✖</span>
</div>
JQUERY__________
function close_div(id) {
if(id === 1) {
jQuery("#your_div_id").hide();
}
}
Now you can show the div, when another event occures as you wish... :-)
You should use the built in line separator. The advantage is that you don't have to concern what system you code is running on, it will just work.
Since Java 1.7
System.lineSeparator()
Pre Java 1.7
System.getProperty("line.separator")
I got the answer.
Here is the code:
SELECT * FROM table
WHERE STR_TO_DATE(column, '%d/%m/%Y')
BETWEEN STR_TO_DATE('29/01/15', '%d/%m/%Y')
AND STR_TO_DATE('07/10/15', '%d/%m/%Y')
If you take 5 minutes to download visual studio and make a Console Application for this, your problem is solved.
using System;
using System.Linq;
using System.Diagnostics;
using System.IO;
namespace BgRunner
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting: " + String.Join(" ", args));
String arguments = String.Join(" ", args.Skip(1).ToArray());
String command = args[0];
Process p = new Process();
p.StartInfo = new ProcessStartInfo(command);
p.StartInfo.Arguments = arguments;
p.StartInfo.WorkingDirectory = Path.GetDirectoryName(command);
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.Start();
}
}
}
Examples of usage:
BgRunner.exe php/php-cgi -b 9999
BgRunner.exe redis/redis-server --port 3000
BgRunner.exe nginx/nginx
I have also experienced the same thing, hopefully a this helps.
cd /etc/init.d
./mysql start
please login to access mysql and phpmyadmin
I usually do like this:
from numpy import log as ln
Perhaps this can make you more comfortable.
This error can occur when you rename files outside of XCode. To solve it you can just remove the files from your project (Right Click - Delete and "Remove Reference").
Then after you can re-import the files in your project and everything will be OK.
For those checking this around the year 2020:
Microsoft's System.Text.Json namespace is the new king in town. In terms of performance, it is the best as far as I can tell:
var model = new Model
{
Name = "Test Name",
Age = 5
};
string json = JsonSerializer.Serialize(model);
As some others have mentioned, NewtonSoft.Json is a very nice library as well.
Do something like this,
HTML :
<div style="width:500px;">
<button type="submit" class="msgBtn" onClick="return false;" >Save</button>
<button type="submit" class="msgBtn2" onClick="return false;">Publish</button>
<button class="msgBtnBack">Back</button>
</div>
CSS :
div button{
display:inline-block;
}
Or
HTML :
<div style="width:500px;" id="container">
<div><button type="submit" class="msgBtn" onClick="return false;" >Save</button></div>
<div><button type="submit" class="msgBtn2" onClick="return false;">Publish</button></div>
<div><button class="msgBtnBack">Back</button></div>
</div>
CSS :
#container div{
display:inline-block;
width:130px;
}
I just found Scandinavian Keyboard as a fine solution to this problem. It do also have English and German keyboard, but neither Dutch nor Spanish - but I guess they could be added. And I guess there is other alternatives out there.
If you use spring this a better way
Is there any way to create form with multiple submit buttons on Spring MVC using annotations?
RRULE standard is built for exactly this requirement i.e. saving and understanding recurrences. Microsoft and google both use it in their calendar events. Please go through this document for more details. https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html
If you are using a strongly-typed dataset then you should do this:
If Not ediTransactionRow.Ispay_id1Null Then
'Do processing here
End If
You are getting the error because a strongly-typed data set retrieves the underlying value and exposes the conversion through the property. For instance, here is essentially what is happening:
Public Property pay_Id1 Then
Get
return DirectCast(me.GetValue("pay_Id1", short)
End Get
'Abbreviated for clarity
End Property
The GetValue method is returning DBNull which cannot be converted to a short.
Why not use the jQuery Event API?
http://learn.jquery.com/events/event-extensions/
I've used this simple event with success. It's clean, namespaceable and flexible enough to improve upon.
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
var eventType = isMobile ? "touchstart" : "click";
jQuery.event.special.touchclick = {
bindType: eventType,
delegateType: eventType
};
Notifications may not be shown if you show the notifications rapidly one after the other or cancel an existing one, then right away show it again (e.g. to trigger a heads-up-notification to notify the user about a change in an ongoing notification). In these cases the system may decide to just block the notification when it feels they might become too overwhelming/spammy for the user.
Please note, that at least on stock Android (tested with 10) from the outside this behavior looks a bit random: it just sometimes happens and sometimes it doesn't. My guess is, there is a very short time threshold during which you are not allowed to send too many notifications. Calling NotificationManager.cancel()
and then NotificationManager.notify()
might then sometimes cause this behavior.
If you have the option, when updating a notification don't cancel it before, but just call NotificationManager.notify()
with the updated notification. This doesn't seem to trigger the aforementioned blocking by the system.
This one just works by auto detecting the current user location.
import moment from "moment/min/moment-with-locales";
// Then use it as you always do.
moment(yourDate).format("MMMM Do YYYY, h:mm a")
// Month here is 1-indexed (January is 1, February is 2, etc). This is
// because we're using 0 as the day so that it returns the last day
// of the last month, so you have to add 1 to the month number
// so it returns the correct amount of days
function daysInMonth (month, year) {
return new Date(year, month, 0).getDate();
}
// July
daysInMonth(7,2009); // 31
// February
daysInMonth(2,2009); // 28
daysInMonth(2,2008); // 29
Using Django's session framework should cover most scenarios, but Django also now provide direct cookie manipulation methods on the request and response objects (so you don't need a helper function).
Setting a cookie:
def view(request):
response = HttpResponse('blah')
response.set_cookie('cookie_name', 'cookie_value')
Retrieving a cookie:
def view(request):
value = request.COOKIES.get('cookie_name')
if value is None:
# Cookie is not set
# OR
try:
value = request.COOKIES['cookie_name']
except KeyError:
# Cookie is not set
You can also do the following;
string json = myJObject.ToString(Newtonsoft.Json.Formatting.None);
puts true ? "true" : "false"
=> "true"
puts false ? "true" : "false"
=> "false"
The chosen answer (and most others) require at least two passes through the list.
Here's a one pass solution which might be a better choice for longer lists.
Edited: To address the two deficiencies pointed out by @John Machin. For (2) I attempted to optimize the tests based on guesstimated probability of occurrence of each condition and inferences allowed from predecessors. It was a little tricky figuring out the proper initialization values for max_val
and max_indices
which worked for all possible cases, especially if the max happened to be the first value in the list — but I believe it now does.
def maxelements(seq):
''' Return list of position(s) of largest element '''
max_indices = []
if seq:
max_val = seq[0]
for i,val in ((i,val) for i,val in enumerate(seq) if val >= max_val):
if val == max_val:
max_indices.append(i)
else:
max_val = val
max_indices = [i]
return max_indices
import gzip
f = gzip.open('file.txt.gz', 'rb')
file_content = f.read()
f.close()
for center and auto zoom on display markers
// map: an instance of google.maps.Map object
// latlng_points_array: an array of google.maps.LatLng objects
var latlngbounds = new google.maps.LatLngBounds( );
for ( var i = 0; i < latlng_points_array.length; i++ ) {
latlngbounds.extend( latlng_points_array[i] );
}
map.fitBounds( latlngbounds );
jQuery out of the box doesn't have the equivalent of a createElement. In fact the majority of jQuery's work is done internally using innerHTML over pure DOM manipulation. As Adam mentioned above this is how you can achieve similar results.
There are also plugins available that make use of the DOM over innerHTML like appendDOM, DOMEC and FlyDOM just to name a few. Performance wise the native jquery is still the most performant (mainly becasue it uses innerHTML)
SWT puts the necessary native DLLs into a JAR. Search for "org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar" for an example.
The DLLs must be in the root of the JAR, the JAR must be signed and the DLL must appear with checksum in the META-INF/MANIFEST.MF for the VM to pick them up.
PowerBI Embedded requires TLS 1.2.
The answer above by Etienne Faucher is your solution. quick link to above answer... quick link to above answer... ( https://stackoverflow.com/a/45442874 )
PowerBI Requires TLS 1.2 June 2020 - This Is your Answer - Consider Forcing your IIS runtime to get up to 4.6 to force the default TLS 1.2 behavior you are looking for from the framework. The above answer gives you a config change only solution.
Symptoms: Forced Closed Rejected TCP/IP Connection to Microsoft PowerBI Embedded that just shows up all of a sudden across your systems.
These PowerBI Calls just stop working with a Hard TCP/IP Close error like a firewall would block a connection. Usually the auth steps work - it is when you hit the service for specific workspace and report id's that it fails.
This is the 2020 note from Microsoft PowerBI about TLS 1.2 required
PowerBIClient
methods that show this problem
GetReportsInGroupAsync GetReportsInGroupAsAdminAsync GetReportsAsync GetReportsAsAdminAsync Microsoft.PowerBI.Api HttpClientHandler Force TLS 1.1 TLS 1.2
Search Error Terms to help people find this: System.Net.Http.HttpRequestException: An error occurred while sending the request System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Here are the differences. Note the newlines at the end.
> shell_exec('date')
string(29) "Wed Mar 6 14:18:08 PST 2013\n"
> exec('date')
string(28) "Wed Mar 6 14:18:12 PST 2013"
> shell_exec('whoami')
string(9) "mark\n"
> exec('whoami')
string(8) "mark"
> shell_exec('ifconfig')
string(1244) "eth0 Link encap:Ethernet HWaddr 10:bf:44:44:22:33 \n inet addr:192.168.0.90 Bcast:192.168.0.255 Mask:255.255.255.0\n inet6 addr: fe80::12bf:ffff:eeee:2222/64 Scope:Link\n UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\n RX packets:16264200 errors:0 dropped:1 overruns:0 frame:0\n TX packets:7205647 errors:0 dropped:0 overruns:0 carrier:0\n collisions:0 txqueuelen:1000 \n RX bytes:13151177627 (13.1 GB) TX bytes:2779457335 (2.7 GB)\n"...
> exec('ifconfig')
string(0) ""
Note that use of the backtick operator is identical to shell_exec()
.
Update: I really should explain that last one. Looking at this answer years later even I don't know why that came out blank! Daniel explains it above -- it's because exec
only returns the last line, and ifconfig
's last line happens to be blank.