Your example is basically what I'm using. It never works on the emulator, however, because the emulator doesn't have any ringtones by default, and content://settings/system/ringtone
doesn't resolve to anything playable. It works fine on my actual phone.
I had this same problem, read this post, but ended building this solution that selects the divs dynamically by fetching the ID from a custom class on the href
using JQuery's attr()
function.
Here's the JQuery:
$('a.custom_class').click(function(e) {
var div = $(this).attr('href');
$(div).toggle('fast');
e.preventDefault();
}
And you just have to create a link like this then in the HTML:
<a href="#" class="#1">Link Text</a>
<div id="1">Div Content</div>
I won't get setSelection() method directly , so i done like below and work like charm
EditText editText = (EditText)findViewById(R.id.edittext_id);
editText.setText("Updated New Text");
int position = editText.getText().length();
Editable editObj= editText.getText();
Selection.setSelection(editObj, position);
Simply add style="line-height:0"
to each cell. This works in IE because it sets the line-height of both existant and non-existant text to about 19px and that forces the cells to expand vertically in most versions of IE. Regardless of whether or not you have text this needs to be done for IE to correctly display rows less than 20px high.
Once you have obtained the context in your onTap() you can also do:
Intent myIntent = new Intent(mContext, theNewActivity.class);
mContext.startActivity(myIntent);
A simple Java code snippet for printing the pairs below:
public static void count_all_pairs_with_given_sum(int arr[], int S){
if(arr.length < 2){
return;
}
HashSet values = new HashSet(arr.length);
for(int value : arr)values.add(value);
for(int value : arr){
int difference = S - value;
if(values.contains(difference) && value<difference){
System.out.printf("(%d, %d) %n", value, difference);
}
}
}
In my case, database returned latin1
, when my browser expected utf8
.
So for MySQLi I did:
mysqli_set_charset($dblink, "utf8");
See http://php.net/manual/en/mysqli.set-charset.php for more info
IEEE 754 floating point is done in binary. There's no exact conversion from a given number of bits to a given number of decimal digits. 3 bits can hold values from 0 to 7, and 4 bits can hold values from 0 to 15. A value from 0 to 9 takes roughly 3.5 bits, but that's not exact either.
An IEEE 754 double precision number occupies 64 bits. Of this, 52 bits are dedicated to the significand (the rest is a sign bit and exponent). Since the significand is (usually) normalized, there's an implied 53rd bit.
Now, given 53 bits and roughly 3.5 bits per digit, simple division gives us 15.1429 digits of precision. But remember, that 3.5 bits per decimal digit is only an approximation, not a perfectly accurate answer.
Many (most?) debuggers actually look at the contents of the entire register. On an x86, that's actually an 80-bit number. The x86 floating point unit will normally be adjusted to carry out calculations to 64-bit precision -- but internally, it actually uses a couple of "guard bits", which basically means internally it does the calculation with a few extra bits of precision so it can round the last one correctly. When the debugger looks at the whole register, it'll usually find at least one extra digit that's reasonably accurate -- though since that digit won't have any guard bits, it may not be rounded correctly.
If you use Safari, you can write
console.log("your message here");
and it appears right on the console of the browser.
To refine the answer from Zed, and to answer your comment:
INSERT INTO dues_storage
SELECT d.*, CURRENT_DATE()
FROM dues d
WHERE id = 5;
See T.J. Crowder's comment
You can use following code for disabling OnScreen Keyboard.
InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(editText.getWindowToken(), 0);
You can try this with Color.FromArgb
:
Random rnd = new Random();
lbl.ForeColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
Just use :
android:backgroundTint="#f816a463"
Instead of:
android:background="#f816a463"
Don't forget to change your Button
to android.support.v7.widget.AppCompatButton
For me setting the path variables was enough for the solution:
Step 1) Install nodemon globally using npm install -g nodemon
Step 2) Set the ENVIRONMENT VARIABLES
, by adding npm path the PATH variable
1) Open Control Panel, search for environment variable
2) Click open the environment variable
3) Create new variable NPM
set it with the path of npm as appears from the nodemon installation cmd output (as seen from nodemon
installation screenshot):
4) Now add NPM
variable to the PATH
variables:
Step 3) Close the 'cmd' and open a fresh one and type nodemon --version
Now we have the nodemon ready to use :)
Simply put multidimensional arrays are similar to a table in DBMS.
Array of Array (jagged array) lets you have each element hold another array of the same type of variable length.
So, if you are sure that the structure of data looks like a table (fixed rows/columns), you can use a multi-dimensional array. Jagged array are fixed elements & each element can hold an array of variable length
E.g. Psuedocode:
int[,] data = new int[2,2];
data[0,0] = 1;
data[0,1] = 2;
data[1,0] = 3;
data[1,1] = 4;
Think of the above as a 2x2 table:
1 | 2 3 | 4
int[][] jagged = new int[3][];
jagged[0] = new int[4] { 1, 2, 3, 4 };
jagged[1] = new int[2] { 11, 12 };
jagged[2] = new int[3] { 21, 22, 23 };
Think of the above as each row having variable number of columns:
1 | 2 | 3 | 4 11 | 12 21 | 22 | 23
Even i had two forms one for desktop view and other for mobile view , Removed one formed worked for me . I dint knew asp.page should have only one form.
I have tried lots and lots of steps from different people posted on different websites. But none of them mention that I should add the certificate into the Trusted People keystore.
That's right, placing it under trusted CA is not enough for my case, I have to put the certs inside the Trusted People also.
That's:
To export the certificate:
I'm on IE9, Windows 7
That is an HTTP header. You would configure your webserver or webapp to send this header ideally. Perhaps in htaccess or PHP.
Alternatively you might be able to use
<head>...<meta http-equiv="Access-Control-Allow-Origin" content="*">...</head>
I do not know if that would work. Not all HTTP headers can be configured directly in the HTML.
This works as an alternative to many HTTP headers, but see @EricLaw's comment below. This particular header is different.
Caveat
This answer is strictly about how to set headers. I do not know anything about allowing cross domain requests.
About HTTP Headers
Every request and response has headers. The browser sends this to the webserver
GET /index.htm HTTP/1.1
Then the headers
Host: www.example.com
User-Agent: (Browser/OS name and version information)
.. Additional headers indicating supported compression types and content types and other info
Then the server sends a response
Content-type: text/html
Content-length: (number of bytes in file (optional))
Date: (server clock)
Server: (Webserver name and version information)
Additional headers can be configured for example Cache-Control
, it all depends on your language (PHP, CGI, Java, htaccess) and webserver (Apache, etc).
But if i take the piece of sql and run it from sql management studio, it will run without issue.
If you are at liberty to, change the service account to your own login, which would inherit your language/regional perferences.
The real crux of the issue is:
I use the following to convert -> date.Value.ToString("MM/dd/yyyy HH:mm:ss")
Please start using parameterized queries so that you won't encounter these issues in the future. It is also more robust, predictable and best practice.
As of my knowledge it is impossible to alter/modify a table type.You can create the type with a different name and then drop the old type and modify it to the new name
Credits to jkrajes
As per msdn, it is like 'The user-defined table type definition cannot be modified after it is created'.
jQuery(document).ready(function(){
jQuery(".head h3").html('Public Offers');
});
Math.Pow()
returns double
so nice would be to write like this:
double d = Math.Pow(100.00, 3.00);
Include the following function at the start of your code, whenever you want to busy wait. This is distinct from sleep, because the process will be utilizing 100% cpu while this function is running.
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock())
;
}
Note that the name sleep
for this function is misleading, since the CPU will not be sleeping at all.
I have found this better way , no need to remove data , just call the source of the remote content each time
$(document).ready(function() {
$('.class').click(function() {
var id = this.id;
//alert(id);checking that have correct id
$("#iframe").attr("src","url?id=" + id);
$('#Modal').modal({
show: true
});
});
});
How about using a Regex?
var result = Regex.Replace(input, "\r\n", String.Empty)
If you just want to remove the new line at the very end use this
var result = Regex.Replace(input, "\r\n$", String.Empty)
http://wiki.whatwg.org/wiki/Implementations_in_Web_browsers has information maintained by the WHATWG community (and everyone who drops by and edits it).
Disclaimer: I'm a member of that community.
If you didn't want to sign up for a service, I'd probably go back to the exchanges themselves; most of them aren't CAPTCHAed yet...
The symbol lookup page for:
etc...
public enum NewEnum {
ONE("test"),
TWO("test");
private String s;
private NewEnum(String s) {
this.s = s);
}
public String getS() {
return this.s;
}
}
I finally figured it out doing this:
var $your-original-element = $('.your-original-element');
var data = $your-original-element.select2('data')[0]['text'];
alert(data);
if you also want the value:
var value = $your-original-element.select2('data')[0]['id'];
alert(value);
If you want to escape characters with a \
, you have addcslashes()
. For example, if you want to escape only single quotes like the question, you can do:
echo addcslashes($value, "'");
And if you want to escape '
, "
, \
, and nul
(the byte null), you can use addslashes()
:
echo addslashes($value);
yes you can use custom font in your application
step by step following there:
Add your custom font files into your project in supporting files
Add a key to your Info.plist file called UIAppFonts.
Make this key an array
For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array
Save Info.plist Now in your application you can simply call [UIFont fontWithName:@"your Custom font Name" size:20] to get the custom font to use with your UILabels after applying this if your not getting correct font then you double click on the custom font , and see carefully top side font name is comming and copy this font , paste, here [UIFont fontWithName:@" here past your Custom font Name" size:20]
i hope you will get correct answer
For Excel 2010 it should be UTF-8. Instruction by MS :
http://msdn.microsoft.com/en-us/library/bb507946:
"The basic document structure of a SpreadsheetML document consists of the Sheets and Sheet elements, which reference the worksheets in the Workbook. A separate XML file is created for each Worksheet. For example, the SpreadsheetML for a workbook that has two worksheets name MySheet1 and MySheet2 is located in the Workbook.xml file and is shown in the following code example.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<workbook xmlns=http://schemas.openxmlformats.org/spreadsheetml/2006/main xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<sheets>
<sheet name="MySheet1" sheetId="1" r:id="rId1" />
<sheet name="MySheet2" sheetId="2" r:id="rId2" />
</sheets>
</workbook>
The worksheet XML files contain one or more block level elements such as SheetData. sheetData represents the cell table and contains one or more Row elements. A row contains one or more Cell elements. Each cell contains a CellValue element that represents the value of the cell. For example, the SpreadsheetML for the first worksheet in a workbook, that only has the value 100 in cell A1, is located in the Sheet1.xml file and is shown in the following code example.
<?xml version="1.0" encoding="UTF-8" ?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<sheetData>
<row r="1">
<c r="A1">
<v>100</v>
</c>
</row>
</sheetData>
</worksheet>
"
Detection of cell encodings:
If using maven, just add to your pom.xml:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0-b01</version>
</dependency>
Of course, you need to check the current version.
While the official docs are happy not to provide switch, I have seen a solution using dictionaries.
For example:
# define the function blocks
def zero():
print "You typed zero.\n"
def sqr():
print "n is a perfect square\n"
def even():
print "n is an even number\n"
def prime():
print "n is a prime number\n"
# map the inputs to the function blocks
options = {0 : zero,
1 : sqr,
4 : sqr,
9 : sqr,
2 : even,
3 : prime,
5 : prime,
7 : prime,
}
Then the equivalent switch block is invoked:
options[num]()
This begins to fall apart if you heavily depend on fall through.
For example to execute from terminal (Ubuntu Linux) or even (Windows console) a java file called filex.jar use this command:
java -jar filex.jar
The file will execute in terminal.
Hmm.
POSIX pthread_exit
description from http://pubs.opengroup.org/onlinepubs/009604599/functions/pthread_exit.html:
After a thread has terminated, the result of access to local (auto) variables of the thread is
undefined. Thus, references to local variables of the exiting thread should not be used for
the pthread_exit() value_ptr parameter value.
Which seems contrary to the idea that local main() thread variables will remain accessible.
private void ButtonClick(object sender, System.EventArgs e)
{
MyForm form = new MyForm();
form.Show(); // or form.ShowDialog(this);
}
Question is asking for two different things:
Second question has been already answered. For the first one, I would do it this way:
if($("#someElement").is(".test")){
// Has class test assigned, eventually combined with other classes
}
else{
// Does not have it
}
Updated Code : Swift 4.2/Swift 5
enum Suit: String, CaseIterable {
case spades = "?"
case hearts = "?"
case diamonds = "?"
case clubs = "?"
}
To access the Output as per question:
for suitKey in Suit.allCases {
print(suitKey.rawValue)
}
Output :
?
?
?
?
CaseIterable:
provides a collection of all of its values.
Types that conform to the CaseIterable protocol are typically enumerations without associated values. When using a CaseIterable type, you can access a collection of all of the type’s cases by using the type’s allCases property.
For accessing cases we are using .allCases. For more information click https://developer.apple.com/documentation/swift/caseiterable
If you have perl installed, then perl -i -n -e"print unless m{(ERROR|REFERENCE)}"
should do the trick.
Instead of using a bat file, you can simply create a Scheduled Task. Most of the time you define just one action. In this case, create two actions with the NET
command. The first one to stop the service, the second one to start the service. Give them a STOP
and START
argument, followed by the service name.
In this example we restart the Printer Spooler service.
NET STOP "Print Spooler"
NET START "Print Spooler"
Note: unfortunately NET RESTART <service name>
does not exist.
To adjust the length of the samples:
set key samplen X
(default is 4)
To adjust the vertical spacing of the samples:
set key spacing X
(default is 1.25)
and (for completeness), to adjust the fontsize:
set key font "<face>,<size>"
(default depends on the terminal)
And of course, all these can be combined into one line:
set key samplen 2 spacing .5 font ",8"
Note that you can also change the position of the key using set key at <position>
or any one of the pre-defined positions (which I'll just defer to help key
at this point)
Because that syntax simply isn't defined? Besides, x < y
evaluates as a bool, so what does bool < int
mean? It isn't really an overhead; besides, you could write a utility method if you really want - isBetween(10,x,20)
- I wouldn't myself, but hey...
In System.Diagnostics
,
Debug.Write()
Debug.WriteLine()
etc. will print to the Output window in VS.
You install as assemblies by using:
gacutil.exe
tool with the -i
option from the command line.%windir%\Assembly
(only up to .NET 3.5, CLR 2.0)You view the content of the GAC using:
gacutil.exe
tool with the -l
option.%windir%\assembly
using the Windows Explorer.Note that the (physical) GAC location has changed for .NET 4.0. It is no longer in %windir%\Assembly
, but now in %windir%\Microsoft.NET\assembly
. However, you should never write any code that depends on the physical location anyway, because given the tools available that is hardly necessary (some "cool" homegrown system diagnostics tools aside).
Modify the batch file to START
both programs, instead of START
ing one and CALL
ing another
start C:\Users\Yiwei\Downloads\putty.exe -load "MathCS-labMachine1"
start "" "C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow
If you run it like this, no CMD window will stay open after starting the program.
Do not bother with encoding. Use a text node instead. Data in text node is guaranteed to be treated as text.
document.body.appendChild(document.createTextNode("Your&funky<text>here"))
You get this warning message when the servlet api jar file has already been loaded in the container and you try to load it once again from lib
directory.
The Servlet specs say you are not allowed to have servlet.jar in your webapps
lib
directory.
servlet.jar
from your lib
directory.lib
directory scan for your build path and remove the jar.C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\project\WEB-INF\lib
If you are running a maven project, change the javax.servlet-api
dependency to scope provided
in you pom.xml since the container already provided the servlet jar in itself.
Everything seems to be perfect in your code except the fact that handleClick() isn't working because this function lacks a parameter in its function call invocation(but the function definition within has an argument which makes a function mismatch to occur).
The following is a sample working code for calculating all semester's total marks and corresponding grade. It demonstrates the use of a JavaScript function(call) within a html file and also solves the problem you are facing.
<!DOCTYPE html>
<html>
<head>
<title> Semester Results </title>
</head>
<body>
<h1> Semester Marks </h1> <br>
<script type = "text/javascript">
function checkMarks(total)
{
document.write("<h1> Final Result !!! </h1><br>");
document.write("Total Marks = " + total + "<br><br>");
var avg = total / 6.0;
document.write("CGPA = " + (avg / 10.0).toFixed(2) + "<br><br>");
if(avg >= 90)
document.write("Grade = A");
else if(avg >= 80)
document.write("Grade = B");
else if(avg >= 70)
document.write("Grade = C");
else if(avg >= 60)
document.write("Grade = D");
else if(avg >= 50)
document.write("Grade = Pass");
else
document.write("Grade = Fail");
}
</script>
<form name = "myform" action = "javascript:checkMarks(Number(s1.value) + Number(s2.value) + Number(s3.value) + Number(s4.value) + Number(s5.value) + Number(s6.value))"/>
Semester 1: <input type = "text" id = "s1"/> <br><br>
Semester 2: <input type = "text" id = "s2"/> <br><br>
Semester 3: <input type = "text" id = "s3"/> <br><br>
Semester 4: <input type = "text" id = "s4"/> <br><br>
Semester 5: <input type = "text" id = "s5"/> <br><br>
Semester 6: <input type = "text" id = "s6"/> <br><br><br>
<input type = "submit" value = "Submit"/>
</form>
</body>
</html>
Some advantages to the second option:
You can use this
inside onclick
to reference the anchor itself (doing the same in option 1 will give you window
instead).
You can set the href
to a non-JS compatible URL to support older browsers (or those that have JS disabled); browsers that support JavaScript will execute the function instead (to stay on the page you have to use onclick="return someFunction();"
and return false
from inside the function or onclick="return someFunction(); return false;"
to prevent default action).
I've seen weird stuff happen when using href="javascript:someFunction()"
and the function returns a value; the whole page would get replaced by just that value.
Pitfalls
Inline code:
Runs in document
scope as opposed to code defined inside <script>
tags which runs in window
scope; therefore, symbols may be resolved based on an element's name
or id
attribute, causing the unintended effect of attempting to treat an element as a function.
Is harder to reuse; delicate copy-paste is required to move it from one project to another.
Adds weight to your pages, whereas external code files can be cached by the browser.
What you could do is something like this (pseudocode):
<container table>
<tr>
<td>
<"300px" table>
<td>
<fixed layout table>
Basically, split up the table into two tables and have it contained by another table.
On iOS there is the switch UI component instead of a checkbox, look into the UISwitch
class.
The property on
(boolean) can be used to determine the state of the slider and about the saving of its state: That depends on how you save your other stuff already, its just saving a boolean value.
Spinner sp = (Spinner)findViewById(R.id.spinner);
sp.setSelection(pos);
here pos is integer (your array item position)
array is like below then pos = 0;
String str[] = new String{"Select Gender","male", "female" };
then in onItemSelected
@Override
public void onItemSelected(AdapterView<?> main, View view, int position,
long Id) {
if(position > 0){
// get spinner value
}else{
// show toast select gender
}
}
Check for log4j configuration files in your output (i.e. bin or target/classes) directory or within generated project artifacts (.jar/.war/.ear). If this is on your classpath it gets picked up by log4j.
I am using those commands on MacOs after getting the same error
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart
I like this better
func ^ (left:NSNumber, right: NSNumber) -> NSNumber {
return pow(left.doubleValue,right.doubleValue)
}
var a:NSNumber = 3
var b:NSNumber = 3
println( a^b ) // 27
RMDIR path_to_folder /S
ex. RMDIR "C:\tmp" /S
Note that you'll be prompted if you're really going to delete the "C:\tmp" folder. Combining it with /Q switch will remove the folder silently (ex. RMDIR "C:\tmp" /S /Q
)
Use font
property of UILabel
:
label.font = UIFont(name:"HelveticaNeue-Bold", size: 16.0)
or use default system font
to bold text:
label.font = UIFont.boldSystemFont(ofSize: 16.0)
Simply changing
public int compare(Dog d, Dog d1) {
return d.age - d1.age;
}
to
public int compare(Dog d, Dog d1) {
return d1.age - d.age;
}
should sort them in the reverse order of age if that is what you are looking for.
Update:
@Arian is right in his comments, one of the accepted ways of declaring a comparator for a dog would be where you declare it as a public static final field in the class itself.
class Dog implements Comparable<Dog> {
private String name;
private int age;
public static final Comparator<Dog> DESCENDING_COMPARATOR = new Comparator<Dog>() {
// Overriding the compare method to sort the age
public int compare(Dog d, Dog d1) {
return d.age - d1.age;
}
};
Dog(String n, int a) {
name = n;
age = a;
}
public String getDogName() {
return name;
}
public int getDogAge() {
return age;
}
// Overriding the compareTo method
public int compareTo(Dog d) {
return (this.name).compareTo(d.name);
}
}
You could then use it any where in your code where you would like to compare dogs as follows:
// Sorts the array list using comparator
Collections.sort(list, Dog.DESCENDING_COMPARATOR);
Another important thing to remember when implementing Comparable is that it is important that compareTo performs consistently with equals. Although it is not required, failing to do so could result in strange behaviour on some collections such as some implementations of Sets. See this post for more information on sound principles of implementing compareTo.
Update 2:
Chris is right, this code is susceptible to overflows for large negative values of age. The correct way to implement this in Java 7 and up would be Integer.compare(d.age, d1.age)
instead of d.age - d1.age
.
Update 3: With Java 8, your Comparator could be written a lot more succinctly as:
public static final Comparator<Dog> DESCENDING_COMPARATOR =
Comparator.comparing(Dog::getDogAge).reversed();
The syntax for Collections.sort
stays the same, but compare
can be written as
public int compare(Dog d, Dog d1) {
return DESCENDING_COMPARATOR.compare(d, d1);
}
Regarding the internal structure of a Python long, check sys.int_info (or sys.long_info for Python 2.7).
>>> import sys
>>> sys.int_info
sys.int_info(bits_per_digit=30, sizeof_digit=4)
Python either stores 30 bits into 4 bytes (most 64-bit systems) or 15 bits into 2 bytes (most 32-bit systems). Comparing the actual memory usage with calculated values, I get
>>> import math, sys
>>> a=0
>>> sys.getsizeof(a)
24
>>> a=2**100
>>> sys.getsizeof(a)
40
>>> a=2**1000
>>> sys.getsizeof(a)
160
>>> 24+4*math.ceil(100/30)
40
>>> 24+4*math.ceil(1000/30)
160
There are 24 bytes of overhead for 0 since no bits are stored. The memory requirements for larger values matches the calculated values.
If your numbers are so large that you are concerned about the 6.25% unused bits, you should probably look at the gmpy2 library. The internal representation uses all available bits and computations are significantly faster for large values (say, greater than 100 digits).
It depends on which character set you want to use.
There's no tab entity defined in ISO-8859-1 HTML - but there are a couple of whitespace characters other than
such as  
,  
,and  
.
In ASCII, 	
is a tab.
Here is a complete listing of HTML entities and a useful discussion of whitespace on Wikipedia.
I don't think that notation is available because—unlike say PHP or C—everything in Ruby is an object.
Sure you could use $var=0; $var++
in PHP, but that's because it's a variable and not an object. Therefore, $var = new stdClass(); $var++
would probably throw an error.
I'm not a Ruby or RoR programmer, so I'm sure someone can verify the above or rectify it if it's inaccurate.
SELECT *
FROM DUAL
CONNECT BY ROWNUM <= 9;
One more time: we all hate IE!
<div style="width:100%;background-color:blue;">
<div style="margin:0 auto;width:300px;background-color:red;">
Not Working
</div>
</div>
<div style="width:100%;background-color:green;text-align:center;">
<div style="margin:0 auto;width:300px;background-color:orange;text-align:left;">
Working, but dumb that you have to use text-align
</div>
</div>
I had the same issue as OP (I think!), but I couldn't get it to work in the way that Lastalda specified. I don't know if I have interpreted the question properly, but I have found another solution (it probably is a really bad way of doing it though).
This was the way that I did it:
plt.hist([1,11,21,31,41], bins=[0,10,20,30,40,50], weights=[10,1,40,33,6]);
Which creates this:
So the first parameter basically 'initialises' the bin - I'm specifically creating a number that is in between the range I set in the bins parameter.
To demonstrate this, look at the array in the first parameter ([1,11,21,31,41]) and the 'bins' array in the second parameter ([0,10,20,30,40,50]):
Then I'm using the 'weights' parameter to define the size of each bin. This is the array used for the weights parameter: [10,1,40,33,6].
So the 0 to 10 bin is given the value 10, the 11 to 20 bin is given the value of 1, the 21 to 30 bin is given the value of 40, etc.
Also, this might help finding the actual location the btsnoop_hci.log is being saved:
adb shell "cat /etc/bluetooth/bt_stack.conf | grep FileName"
Check if you mixed tabs and spaces, that is a frequent source of indentation errors.
the following code worked fine for me. kindly check other setting in your web config
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
From Get-ScriptDirectory to the Rescue blog entry ...
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
Make sure that in the path to the project there is no foldername having whitespace. While creating a project the specified path folders must not contain any space in their naming.
We can find the the mean of a row using the range function, i.e in your case, from the Y1961 column to the Y1965
df['mean'] = df.iloc[:, 0:4].mean(axis=1)
And if you want to select individual columns
df['mean'] = df.iloc[:, [0,1,2,3,4].mean(axis=1)
String[] value_split = rat_values.split(Pattern.quote("|"));
//System.out.println(Arrays.toString(rat_values.split(Pattern.quote("|")))); //(FOR GETTING OUTPUT)
String[] value_split = rat_values.split("\\|");
//System.out.println(Arrays.toString(rat_values.split("\\|"))); //(FOR GETTING OUTPUT)
public static String[] splitUsingTokenizer(String Subject, String Delimiters)
{
StringTokenizer StrTkn = new StringTokenizer(Subject, Delimiters);
ArrayList<String> ArrLis = new ArrayList<String>(Subject.length());
while(StrTkn.hasMoreTokens())
{
ArrLis.add(StrTkn.nextToken());
}
return ArrLis.toArray(new String[0]);
}
Arrays.asList(Pattern.compile("\\|").split(rat_values))
//System.out.println(Arrays.asList(Pattern.compile("\\|").split(rat_values))); //(FOR GETTING OUTPUT)
[Food 1 , Service 3 , Atmosphere 3 , Value for money 1 ]
create a folder inside htdocs, place your website there, access it via localhost or Internal IP (if you're behind a router) - check out this video demo here
Adding on to @[RichardTheKiwi]'s answer.
Whenever I search for a list of tables, in general I want to select from all of them or delete them. Below is a script that generates those scripts for you.
The generated select script also adds a tableName column so you know what table you're looking at:
select 'select ''' + name + ''' as TableName, * from ' + name as SelectTable,
'delete from ' + name as DeleteTable
from sys.tables
where name like '%xxxx%'
and is_ms_shipped = 0;
The problem is that you are using SingleOrDefault
. This method will only succeed when the collections contains exactly 0 or 1 element. I believe you are looking for FirstOrDefault
which will succeed no matter how many elements are in the collection.
This is in the JQuery documentation:
http://learn.jquery.com/using-jquery-core/faq/how-do-i-test-whether-an-element-exists/
alert( $( "#notAnElement" ).length ? 'Not null' : 'Null' );
Most of the answers describe some sort of recvall()
method. If your bottleneck when receiving data is creating the byte array in a for
loop, I benchmarked three approaches of allocating the received data in the recvall()
method:
Byte string method:
arr = b''
while len(arr) < msg_len:
arr += sock.recv(max_msg_size)
List method:
fragments = []
while True:
chunk = sock.recv(max_msg_size)
if not chunk:
break
fragments.append(chunk)
arr = b''.join(fragments)
Pre-allocated bytearray
method:
arr = bytearray(msg_len)
pos = 0
while pos < msg_len:
arr[pos:pos+max_msg_size] = sock.recv(max_msg_size)
pos += max_msg_size
Results:
Two way Approach to use objective-c objective-c
1
2
Now good to go Thanks
gitfox
is a tool to execute command on all subrepos
npm install gitfox -g
g pull
In Gradle implement this library :
implementation 'com.android.support:appcompat-v7:SDK_VER'
implementation 'com.android.support:design:SDK_VER'
implementation 'com.android.support:support-v4:SDK_VER'
implementation 'com.android.support:support-v13:SDK_VER'
implementation 'com.android.support:recyclerview-v7:SDK_VER'
In XML mention like this :
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recyclerView"/>
In Fragment we use recyclerView
like this :
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.YOUR_LAYOUT_NAME, container, false);
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
APICallMethod();
YOURADAPTER = new YOURADAPTER(getActivity(), YOUR_LIST); // you can use that adapter after for loop in response(APICALLMETHOD)
recyclerView.setAdapter(YOURADAPTER);
return rootView;
}
In Activity we use RecyclerView
like this :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.YOUR_LAYOUT_NAME);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
APICallMethod();
YOURADAPTER = new YOURADAPTER(ACTIVITY_NAME.this, YOUR_LIST); // you can use that adapter after for loop in response(APICALLMETHOD)
recyclerView.setAdapter(YOURADAPTER);
}
if you need horizontal RecyclerView
do this :
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManager);
APICallMethod();
YOURADAPTER = new YOURADAPTER(ACTIVITY_NAME.this, YOUR_LIST); // you can use that adapter after for loop in response(APICALLMETHOD)
recyclerView.setAdapter(YOURADAPTER);
if you want to use GridLayoutManager using RecyclerView
use like this :
RecyclerView recyclerView = findViewById(R.id.rvNumbers);
recyclerView.setLayoutManager(new GridLayoutManager(this, 3)); // 3 is number of columns.
adapter = new MyRecyclerViewAdapter(this, data);
recyclerView.setAdapter(adapter);
Another option to avoid nesting two different environments (like multicols
and enumerate
).
The environment called tasks
from the package with the same name seems to me very easy to customize thanks to a variety of options (pdf guide here).
This code:
\documentclass{article}
\usepackage{tasks}
%\settasks{style=itemize}
\begin{document}
Text text text text text text text text text text text text
text text text text text text text text text text text text
text text text text text text text text text text text text.
\begin{tasks}(2)
\task[*] a
\task[*] b
\task[*] c
\task[*] d
\task[*] e
\task[*] f
\end{tasks}
Text text text text text text text text text text text text
text text text text text text text text text text text text
text text text text text text text text text text text text.
\end{document}
produces this output
The package tasks
was updated in August 2020 and it was originally created specifically for horizontally columned lists (see the screenshot just above here), the motivations behind this are resumed in the guide. If such arrangement of the items/tasks is acceptable, then this may be a good choice since it keeps - IMHO - the code tidy and flexible.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Validation</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
var tags = document.getElementsByTagName("input");
var radiotags = document.getElementsByName("gender");
var compareValidator = ['compare'];
var formtag = document.getElementsByTagName("form");
function validation(){
for(var i=0;i<tags.length;i++){
var tagid = tags[i].id;
var tagval = tags[i].value;
var tagtit = tags[i].title;
var tagclass = tags[i].className;
//Validation for Textbox Start
if(tags[i].type == "text"){
if(tagval == "" || tagval == null){
var lbl = $(tags[i]).prev().text();
lbl = lbl.replace(/ : /g,'')
//alert("Please Enter "+lbl);
$(".span"+tagid).remove();
$("#"+tagid).after("<span style='color:red;' class='span"+tagid+"'>Please Enter "+lbl+"</span>");
$("#"+tagid).focus();
//return false;
}
else if(tagval != "" || tagval != null){
$(".span"+tagid).remove();
}
//Validation for compare text in two text boxes Start
//put two tags with same class name and put class name in compareValidator.
for(var j=0;j<compareValidator.length;j++){
if((tagval != "") && (tagclass.indexOf(compareValidator[j]) != -1)){
if(($('.'+compareValidator[j]).first().val()) != ($('.'+compareValidator[j]).last().val())){
$("."+compareValidator[j]+":last").after("<span style='color:red;' class='span"+tagid+"'>Invalid Text</span>");
$("span").prev("span").remove();
$("."+compareValidator[j]+":last").focus();
//return false;
}
}
}
//Validation for compare text in two text boxes End
//Validation for Email Start
if((tagval != "") && (tagclass.indexOf('email') != -1)){
//enter class = email where you want to use email validator
var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
if (reg.test(tagval)){
$(".span"+tagid).remove();
return true;
}
else{
$(".span"+tagid).remove();
$("#"+tagid).after("<span style='color:red;' class='span"+tagid+"'>Email is Invalid</span>");
$("#"+tagid).focus();
return false;
}
}
//Validation for Email End
}
//Validation for Textbox End
//Validation for Radio Start
else if(tags[i].type == "radio"){
//enter class = gender where you want to use gender validator
if((radiotags[0].checked == false) && (radiotags[1].checked == false)){
$(".span"+tagid).remove();
//$("#"+tagid").after("<span style='color:red;' class='span"+tagid+"'>Please Select Your Gender </span>");
$(".gender:last").next().after("<span style='color:red;' class='span"+tagid+"'> Please Select Your Gender</span>");
$("#"+tagid).focus();
i += 1;
}
else{
$(".span"+tagid).remove();
}
}
//Validation for Radio End
else{
}
}
//return false;
}
function Validate(){
if(!validation()){
return false;
}
return true;
}
function onloadevents(){
tags[tags.length -1].onclick = function(){
//return Validate();
}
for(var j=0;j<formtag.length;j++){
formtag[j].onsubmit = function(){
return Validate();
}
}
for(var i=0;i<tags.length;i++){
var tagid = tags[i].id;
var tagval = tags[i].value;
var tagtit = tags[i].title;
var tagclass = tags[i].className;
if((tags[i].type == "text") && (tagclass.indexOf('numeric') != -1)){
//enter class = numeric where you want to use numeric validator
document.getElementById(tagid).onkeypress = function(){
numeric(event);
}
}
}
}
function numeric(event){
var KeyBoardCode = (event.which) ? event.which : event.keyCode;
if (KeyBoardCode > 31 && (KeyBoardCode < 48 || KeyBoardCode > 57)){
event.preventDefault();
$(".spannum").remove();
//$(".numeric").after("<span class='spannum'>Numeric Keys Please</span>");
//$(".numeric").focus();
return false;
}
$(".spannum").remove();
return true;
}
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", onloadevents, false);
}
//window.onload = onloadevents;
</script>
</head>
<body>
<form method="post">
<label for="fname">Test 1 : </label><input type="text" title="Test 1" id="fname" class="form1"><br>
<label for="fname1">Test 2 : </label><input type="text" title="Test 2" id="fname1" class="form1 compare"><br>
<label for="fname2">Test 3 : </label><input type="text" title="Test 3" id="fname2" class="form1 compare"><br>
<label for="gender">Gender : </label>
<input type="radio" title="Male" id="fname3" class="gender" name="gender" value="Male"><label for="gender">Male</label>
<input type="radio" title="Female" id="fname4" class="gender" name="gender" value="Female"><label for="gender">Female</label><br>
<label for="fname5">Mobile : </label><input type="text" title="Mobile" id="fname5" class="numeric"><br>
<label for="fname6">Email : </label><input type="text" title="Email" id="fname6" class="email"><br>
<input type="submit" id="sub" value="Submit">
</form>
</body>
</html>
The answer you're looking for in 2020 and beyond:
setColorFilter(color, mode)
is deprecated since API 29 (as discussed here)button.setBackgroundColor(color)
messes with the button styleNow the proper way to set a buttons color is using BlendModeColorFilter()
(see documentation).
Usage:
btn.background.colorFilter = BlendModeColorFilter(color, BlendMode.MULTIPLY)
If you work with older APIs too:
fun setButtonColor(btn: Button, color: Int) {
if (Build.VERSION.SDK_INT >= 29)
btn.background.colorFilter = BlendModeColorFilter(color, BlendMode.MULTIPLY)
else
btn.background.setColorFilter(color, PorterDuff.Mode.MULTIPLY)
}
Please vote to help others finding this answer - it took me quite a while figuring this out ^^
Had the same problem, Uninstall Genymotion, install VirtualBox stand alone from https://www.virtualbox.org/wiki/Downloads then install the Genymotion package without VirtualBox.
I think you'll want to look at the <intent-filter>
element of your Mainfest file. Specifically, take a look at the documentation for the <data>
sub-element.
Basically, what you'll need to do is define your own scheme. Something along the lines of:
<intent-filter>
<data android:scheme="anton" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <--Not positive if this one is needed
...
</intent-filter>
Then you should be able to launch your app with links that begin with the anton:
URI scheme.
Of course. The whole idea of abstract classes is that they can contain some behaviour or data which you require all sub-classes to contain. Think of the simple example of WheeledVehicle - it should have a numWheels member variable. You want all sub classes to have this variable. Remember that abstract classes are a very useful feature when developing APIs, as they can ensure that people who extend your API won't break it.
You can use strcmp
:
break x:20 if strcmp(y, "hello") == 0
20
is line number, x
can be any filename and y
can be any variable.
It is standard matplotlib.pyplot:
...
import matplotlib.pyplot as plt
plt.ylim(10, 40)
Or simpler, as mwaskom comments below:
ax.set(ylim=(10, 40))
If you're just looking at values of cells you can store the values in an array of variant type. It seems that getting the value of an element in an array can be much faster than interacting with Excel, so you can see some difference in performance using an array of all cell values compared to repeatedly getting single cells.
Dim ValArray as Variant
ValArray = Range("A1:IV" & Rows.Count).Value
Then you can get a cell value just by checking ValArray( row , column )
For touch devices like iPad and iPhone we can use this code:
$(document).on('touchstart', function (event) {
var container = $("YOUR CONTAINER SELECTOR");
if (!container.is(e.target) && // If the target of the click isn't the container...
container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
If you're using ngRoute, you can inject $routeParams
into your controller
http://docs.angularjs.org/api/ngRoute/service/$routeParams
If you're using angular-ui-router, you can inject $stateParams
Try to avoid using string.Split for a general solution, because you'll use more memory everywhere you use the function -- the original string, and the split copy, both in memory. Trust me that this can be one hell of a problem when you start to scale -- run a 32-bit batch-processing app processing 100MB documents, and you'll crap out at eight concurrent threads. Not that I've been there before...
Instead, use an iterator like this;
public static IEnumerable<string> SplitToLines(this string input)
{
if (input == null)
{
yield break;
}
using (System.IO.StringReader reader = new System.IO.StringReader(input))
{
string line;
while( (line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
This will allow you to do a more memory efficient loop around your data;
foreach(var line in document.SplitToLines())
{
// one line at a time...
}
Of course, if you want it all in memory, you can do this;
var allTheLines = document.SplitToLines.ToArray();
Try this:
cc=is.na(DF$y)
m=which(cc==c("TRUE"))
DF=DF[-m,]
I had this issue when I was trying to render an object on a child component that was receiving props.
I fixed this when I realized that my code was trying to render an object and not the object key's value that I was trying to render.
You can change your PrintWriter and use method getAbsoluteFile(), this function returns the absolute File object of the given abstract pathname.
PrintWriter out = new PrintWriter(new FileWriter(log.getAbsoluteFile(), true));
Since Internet Explorer 11 (IE11+) came out and is not using the tag name of MSIE
anymore I came up with a variance of an older detection function:
navigator.sayswho= (function(){
var N= navigator.appName, ua= navigator.userAgent, tem;
// if IE11+
if (new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})").exec(ua) !== null) {
var M= ["Internet Explorer"];
if(M && (tem= ua.match(/rv:([0-9]{1,}[\.0-9]{0,})/))!= null) M[2]= tem[1];
M= M? [M[0], M[2]]: [N, navigator.appVersion,'-?'];
return M;
}
var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
return M;
})();
Note that On Error Resume Next
is not set globally. You can put your unsafe part of code eg into a function, which will interrupted immediately if error occurs, and call this function from sub containing precedent OERN
statement.
ErrCatch()
Sub ErrCatch()
Dim Res, CurrentStep
On Error Resume Next
Res = UnSafeCode(20, CurrentStep)
MsgBox "ErrStep " & CurrentStep & vbCrLf & Err.Description
End Sub
Function UnSafeCode(Arg, ErrStep)
ErrStep = 1
UnSafeCode = 1 / (Arg - 10)
ErrStep = 2
UnSafeCode = 1 / (Arg - 20)
ErrStep = 3
UnSafeCode = 1 / (Arg - 30)
ErrStep = 0
End Function
Have you tried os.mkdir?
You might also try this little code snippet:
mypath = ...
if not os.path.isdir(mypath):
os.makedirs(mypath)
makedirs creates multiple levels of directories, if needed.
First of all right click the tale select 'Edit All Rows', select 'Query Designer -> Pane -> SQL ', after that you can edit the query output in the grid.
Neither has anything specific to keyboard or mobile, other than the fact that for years ARM has had a pretty substantial advantage in terms of power consumption, which made it attractive for all sorts of battery operated devices.
As far as the actual differences: ARM has more registers, supported predication for most instructions long before Intel added it, and has long incorporated all sorts of techniques (call them "tricks", if you prefer) to save power almost everywhere it could.
There's also a considerable difference in how the two encode instructions. Intel uses a fairly complex variable-length encoding in which an instruction can occupy anywhere from 1 up to 15 byte. This allows programs to be quite small, but makes instruction decoding relatively difficult (as in: decoding instructions fast in parallel is more like a complete nightmare).
ARM has two different instruction encoding modes: ARM and THUMB. In ARM mode, you get access to all instructions, and the encoding is extremely simple and fast to decode. Unfortunately, ARM mode code tends to be fairly large, so it's fairly common for a program to occupy around twice as much memory as Intel code would. Thumb mode attempts to mitigate that. It still uses quite a regular instruction encoding, but reduces most instructions from 32 bits to 16 bits, such as by reducing the number of registers, eliminating predication from most instructions, and reducing the range of branches. At least in my experience, this still doesn't usually give quite as dense of coding as x86 code can get, but it's fairly close, and decoding is still fairly simple and straightforward. Lower code density means you generally need at least a little more memory and (generally more seriously) a larger cache to get equivalent performance.
At one time Intel put a lot more emphasis on speed than power consumption. They started emphasizing power consumption primarily on the context of laptops. For laptops their typical power goal was on the order of 6 watts for a fairly small laptop. More recently (much more recently) they've started to target mobile devices (phones, tablets, etc.) For this market, they're looking at a couple of watts or so at most. They seem to be doing pretty well at that, though their approach has been substantially different from ARM's, emphasizing fabrication technology where ARM has mostly emphasized micro-architecture (not surprising, considering that ARM sells designs, and leaves fabrication to others).
Depending on the situation, a CPU's energy consumption is often more important than its power consumption though. At least as I'm using the terms, power consumption refers to power usage on a (more or less) instantaneous basis. Energy consumption, however, normalizes for speed, so if (for example) CPU A consumes 1 watt for 2 seconds to do a job, and CPU B consumes 2 watts for 1 second to do the same job, both CPUs consume the same total amount of energy (two watt seconds) to do that job--but with CPU B, you get results twice as fast.
ARM processors tend to do very well in terms of power consumption. So if you need something that needs a processor's "presence" almost constantly, but isn't really doing much work, they can work out pretty well. For example, if you're doing video conferencing, you gather a few milliseconds of data, compress it, send it, receive data from others, decompress it, play it back, and repeat. Even a really fast processor can't spend much time sleeping, so for tasks like this, ARM does really well.
Intel's processors (especially their Atom processors, which are actually intended for low power applications) are extremely competitive in terms of energy consumption. While they're running close to their full speed, they will consume more power than most ARM processors--but they also finish work quickly, so they can go back to sleep sooner. As a result, they can combine good battery life with good performance.
So, when comparing the two, you have to be careful about what you measure, to be sure that it reflects what you honestly care about. ARM does very well at power consumption, but depending on the situation you may easily care more about energy consumption than instantaneous power consumption.
python
x = "http://xxxxxx"
y = "text title"
text_link = '<{}|{}>'.format(x,y)
post text_link in using python slack client
Here's a pretty clean CoffeeScript version of how you could do this:
Object::equals = (other) ->
typeOf = Object::toString
return false if typeOf.call(this) isnt typeOf.call(other)
return `this == other` unless typeOf.call(other) is '[object Object]' or
typeOf.call(other) is '[object Array]'
(return false unless this[key].equals other[key]) for key, value of this
(return false if typeof this[key] is 'undefined') for key of other
true
Here are the tests:
describe "equals", ->
it "should consider two numbers to be equal", ->
assert 5.equals(5)
it "should consider two empty objects to be equal", ->
assert {}.equals({})
it "should consider two objects with one key to be equal", ->
assert {a: "banana"}.equals {a: "banana"}
it "should consider two objects with keys in different orders to be equal", ->
assert {a: "banana", kendall: "garrus"}.equals {kendall: "garrus", a: "banana"}
it "should consider two objects with nested objects to be equal", ->
assert {a: {fruit: "banana"}}.equals {a: {fruit: "banana"}}
it "should consider two objects with nested objects that are jumbled to be equal", ->
assert {a: {a: "banana", kendall: "garrus"}}.equals {a: {kendall: "garrus", a: "banana"}}
it "should consider two objects with arrays as values to be equal", ->
assert {a: ["apple", "banana"]}.equals {a: ["apple", "banana"]}
it "should not consider an object to be equal to null", ->
assert !({a: "banana"}.equals null)
it "should not consider two objects with different keys to be equal", ->
assert !({a: "banana"}.equals {})
it "should not consider two objects with different values to be equal", ->
assert !({a: "banana"}.equals {a: "grapefruit"})
You can omit the -jar
option and start the jar file like this:
java -cp MyJar.jar;C:\externalJars\* mainpackage.MyMainClass
If you want to convert a property to an integer from properties file there are 2 solutions which I found:
Given scenario: customer.properties contains customer.id = 100 as a field and you want to access it in spring configuration file as integer.The property customerId is declared as type int in the Bean Customer
Solution 1:
<property name="customerId" value="#{T(java.lang.Integer).parseInt('${customer.id}')}" />
_x000D_
In the above line, the string value from properties file is converted to int type.
solution 2: Use some other extension inplace of propeties.For Ex.- If your properties file name is customer.properties then make it customer.details and in the configuration file use the below code
<property name="customerId" value="${customer.id}" />
_x000D_
Yes , Jared and Kelly Orr are right. I use the following code like in edit exception.
foreach (var issue in dinner.GetRuleViolations())
{
ModelState.AddModelError(issue.PropertyName, issue.ErrorMessage);
}
in stead of
ModelState.AddRuleViolations(dinner.GetRuleViolations());
A variation of the first answer that I found useful
Open your command prompt and enter (you dont have to be logged into your mysql server)
mysqldump -hlocalhost -u<root> -p<password> <dbname> --compact --no-data > </path_to_mydump/>mysql.dmp
Note that another approach is to keep with the 4.0 validation behaviour, but to define your own class that derives from RequestValidator
and set:
<httpRuntime requestValidationType="YourNamespace.YourValidator" />
(where YourNamespace.YourValidator
is well, you should be able to guess...)
This way you keep the advantages of 4.0s behaviour (specifically, that the validation happens earlier in the processing), while also allowing the requests you need to let through, through.
Scenario:
Your domain: mydomain.com
Domain you wish to send to: theirdomain.com
1. Determine the mail server you're sending to. Open a CMD prompt Type
NSLOOKUP
set q=mx
theirdomain.com
Response:
Non-authoritative answer:
theirdomain.com MX preference = 50, mail exchanger = mail.theirdomain.com
Nslookup_big
EDIT Be sure to type exit to terminate NSLOOKUP.
2. Connect to their mail server
SMTP communicates over port 25. We will now try to use TELNET to connect to their mail server "mail.theirdomain.com"
Open a CMD prompt
TELNET MAIL.THEIRDOMAIN.COM 25
You should see something like this as a response:
220 mx.google.com ESMTP 6si6253627yxg.6
Be aware that different servers will come up with different greetings but you should get SOMETHING. If nothing comes up at this point there are 2 possible problems. Port 25 is being blocked at your firewall, or their server is not responding. Try a different domain, if that works then it's not you.
3. Send an Email
Now, use simple SMTP commands to send a test email. This is very important, you CANNOT use the backspace key, it will work onscreen but not be interpreted correctly. You have to type these commands perfectly.
ehlo mydomain.com
mail from:<[email protected]>
rcpt to:<[email protected]>
data
This is a test, please do not respond
.
quit
So, what does that all mean? EHLO - introduce yourself to the mail server HELO can also be used but EHLO tells the server to use the extended command set (not that we're using that).
MAIL FROM - who's sending the email. Make sure to place this is the greater than/less than brackets as many email servers will require this (Postini).
RCPT TO - who you're sending it to. Again you need to use the brackets. See Step #4 on how to test relaying mail!
DATA - tells the SMTP server that what follows is the body of your email. Make sure to hit "Enter" at the end.
. - the period alone on the line tells the SMTP server you're all done with the data portion and it's clear to send the email.
quit - exits the TELNET session.
4. Test SMTP relay Testing SMTP relay is very easy, and simply requires a small change to the above commands. See below:
ehlo mydomain.com
mail from:<[email protected]>
rcpt to:<[email protected]>
data
This is a test, please do not respond
.
quit
See the difference? On the RCPT TO line, we're sending to a domain that is not controlled by the SMTP server we're sending to. You will get an immediate error is SMTP relay is turned off. If you're able to continue and send an email, then relay is allowed by that server.
If you had a function that takes:
1 millisecond to complete if you have 2 elements.
2 milliseconds to complete if you have 4 elements.
3 milliseconds to complete if you have 8 elements.
4 milliseconds to complete if you have 16 elements.
...
n milliseconds to complete if you have 2^n elements.
Then it takes log2(n) time. The Big O notation, loosely speaking, means that the relationship only needs to be true for large n, and that constant factors and smaller terms can be ignored.
The hardest part of truncating all tables is removing and re-ading the foreign key constraints.
The following query creates the drop & create statements for each constraint relating to each table name in @myTempTable. If you would like to generate these for all the tables, you may simple use information schema to gather these table names instead.
DECLARE @myTempTable TABLE (tableName varchar(200))
INSERT INTO @myTempTable(tableName) VALUES
('TABLE_ONE'),
('TABLE_TWO'),
('TABLE_THREE')
-- DROP FK Contraints
SELECT 'alter table '+quotename(schema_name(ob.schema_id))+
'.'+quotename(object_name(ob.object_id))+ ' drop constraint ' + quotename(fk.name)
FROM sys.objects ob INNER JOIN sys.foreign_keys fk ON fk.parent_object_id = ob.object_id
WHERE fk.referenced_object_id IN
(
SELECT so.object_id
FROM sys.objects so JOIN sys.schemas sc
ON so.schema_id = sc.schema_id
WHERE so.name IN (SELECT * FROM @myTempTable) AND sc.name=N'dbo' AND type in (N'U'))
-- CREATE FK Contraints
SELECT 'ALTER TABLE [PIMSUser].[dbo].[' +cast(c.name as varchar(255)) + '] WITH NOCHECK ADD CONSTRAINT ['+ cast(f.name as varchar(255)) +'] FOREIGN KEY (['+ cast(fc.name as varchar(255)) +'])
REFERENCES [PIMSUser].[dbo].['+ cast(p.name as varchar(255)) +'] (['+cast(rc.name as varchar(255))+'])'
FROM sysobjects f
INNER JOIN sys.sysobjects c ON f.parent_obj = c.id
INNER JOIN sys.sysreferences r ON f.id = r.constid
INNER JOIN sys.sysobjects p ON r.rkeyid = p.id
INNER JOIN sys.syscolumns rc ON r.rkeyid = rc.id and r.rkey1 = rc.colid
INNER JOIN sys.syscolumns fc ON r.fkeyid = fc.id and r.fkey1 = fc.colid
WHERE
f.type = 'F'
AND
cast(p.name as varchar(255)) IN (SELECT * FROM @myTempTable)
I then just copy out the statements to run - but with a bit of dev effort you could use a cursor to run them dynamically.
I had issues with the IsInternetAvailable answer not testing for cellular networks, rather only if wifi was connected. This answer works for both wifi and mobile data:
How to check network connection enable or disable in WIFI and 3G(data plan) in mobile?
With this code you can remove every item from your listbox ... Notice that you should write this code in the click event of your button :
if (listBox1.SelectedIndex != -1)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
Mac OS X 10.12 with Java 1.8:
$JAVA_HOME/jre/lib/security
cd $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
From there it's in:
./jre/lib/security
I have a cacerts keystore in there.
To specify this as a VM option:
-Djavax.net.ssl.trustStore=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/security/cacerts -Djavax.net.ssl.trustStorePassword=changeit
I'm not saying this is the correct way (Why doesn't java know to look within JAVA_HOME?), but this is what I had to do to get it working.
If your problem is not Maven related and you get the same NullPointerException running this in a browser (while running it from the IDE is fine), try this:
-> Netbeans -> Right-Click Project -> Properties -> Build -> Deployment -> Check "Request unrestricted access (Enable signing, self-signed)"
This is due to the @FXML Annotation needing permission to inject the value from the FXML markup (see http://docs.oracle.com/javafx/2/fxml_get_started/fxml_deployment.htm )
I was running my App on JDK8u31 and it would never run without the certificate in Chrome / Firefox / IE.
I have created tool similar to Ned Batchelder:
Searching .dll and .exe files in PATH
While my tool is primarly for searching of various dll versions it shows more info (date, size, version) but it do not use PATHEXT (I hope to update my tool soon).
These are timeout values enforced by JVM for TCP connection establishment and waiting on reading data from socket.
If the value is set to infinity, you will not wait forever. It simply means JVM doesn't have timeout and OS will be responsible for all the timeouts. However, the timeouts on OS may be really long. On some slow network, I've seen timeouts as long as 6 minutes.
Even if you set the timeout value for socket, it may not work if the timeout happens in the native code. We can reproduce the problem on Linux by connecting to a host blocked by firewall or unplugging the cable on switch.
The only safe approach to handle TCP timeout is to run the connection code in a different thread and interrupt the thread when it takes too long.
I solved a similar problem by updating the web.xml
declaration to Servlet 4.0 specification as follows (I use Tomcat 9) :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
<!-- ... (your content here) ... -->
</web-app>
You can check which servlet version Tomcat supports by refering to the chart on Tomcat's which version page.
I had the same question, and I tested 3 main solution :
(df != null) && (df.count > 0)
df.head(1).isEmpty()
as @hulin003 suggestdf.rdd.isEmpty()
as @Justin Pihony suggestand of course the 3 works, however in term of perfermance, here is what I found, when executing the these methods on the same DF in my machine, in terme of execution time :
therefore I think that the best solution is df.rdd.isEmpty()
as @Justin Pihony suggest
Note that HasValue
will return true for an empty Guid
.
bool validGuid = SomeProperty.HasValue && SomeProperty != Guid.Empty;
Here you go. This one is perfect ;-)
EDIT: see below comment - "Does not work with certain images, fails with: CGContextSetInterpolationQuality: invalid context 0x0 error"
// Resizes the image according to the given content mode, taking into account the image's orientation
- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode imageToScale:(UIImage*)imageToScale bounds:(CGSize)bounds interpolationQuality:(CGInterpolationQuality)quality {
//Get the size we want to scale it to
CGFloat horizontalRatio = bounds.width / imageToScale.size.width;
CGFloat verticalRatio = bounds.height / imageToScale.size.height;
CGFloat ratio;
switch (contentMode) {
case UIViewContentModeScaleAspectFill:
ratio = MAX(horizontalRatio, verticalRatio);
break;
case UIViewContentModeScaleAspectFit:
ratio = MIN(horizontalRatio, verticalRatio);
break;
default:
[NSException raise:NSInvalidArgumentException format:@"Unsupported content mode: %d", contentMode];
}
//...and here it is
CGSize newSize = CGSizeMake(imageToScale.size.width * ratio, imageToScale.size.height * ratio);
//start scaling it
CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width, newSize.height));
CGImageRef imageRef = imageToScale.CGImage;
CGContextRef bitmap = CGBitmapContextCreate(NULL,
newRect.size.width,
newRect.size.height,
CGImageGetBitsPerComponent(imageRef),
0,
CGImageGetColorSpace(imageRef),
CGImageGetBitmapInfo(imageRef));
CGContextSetInterpolationQuality(bitmap, quality);
// Draw into the context; this scales the image
CGContextDrawImage(bitmap, newRect, imageRef);
// Get the resized image from the context and a UIImage
CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap);
UIImage *newImage = [UIImage imageWithCGImage:newImageRef];
// Clean up
CGContextRelease(bitmap);
CGImageRelease(newImageRef);
return newImage;
}
You can use a jQuery plugin: jQuery Array Utilities
For example the code below
$.union([1, 2, 2, 3], [2, 3, 4, 5, 5])
will return [1,2,3,4,5]
Because of the definition of the semantics of nth-child
, I don't see how this is possible without including the length of the list of elements involved. The point of the semantics is to allow segregation of a bunch of child elements into repeating groups (edit - thanks BoltClock) or into a first part of some fixed length, followed by "the rest". You sort-of want the opposite of that, which is what nth-last-child
gives you.
Complate Angular Way ( Set/Get value by Id ):
// In Html tag
<button (click) ="setValue()">Set Value</button>
<input type="text" #userNameId />
// In component .ts File
export class testUserClass {
@ViewChild('userNameId') userNameId: ElementRef;
ngAfterViewInit(){
console.log(this.userNameId.nativeElement.value );
}
setValue(){
this.userNameId.nativeElement.value = "Sample user Name";
}
}
You may find your answer in the javadoc of Map#put(K, V) (which actually returns something):
public V put(K key, V value)
Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for this key, the old value is replaced by the specified value. (A map
m
is said to contain a mapping for a keyk
if and only ifm.containsKey(k)
would returntrue
.)Parameters:
key
- key with which the specified value is to be associated.
value
- value to be associated with the specified key.Returns:
previous value associated with specified key, ornull
if there was no mapping forkey
. (Anull
return can also indicate that the map previously associatednull
with the specifiedkey
, if the implementation supportsnull
values.)
So if you don't assign the returned value when calling mymap.put("1", "a string")
, it just becomes unreferenced and thus eligible for garbage collection.
I know this topic is old, but there are no correct answers.
rotation transform rotates the element from its center, so, a wider element will rotate this way:
Applying overflow: hidden
hides the longest dimension as you can see here:
img{_x000D_
border: 1px solid #000;_x000D_
transform: rotate(270deg);_x000D_
-ms-transform: rotate(270deg);_x000D_
-moz-transform: rotate(270deg);_x000D_
-webkit-transform: rotate(270deg);_x000D_
-o-transform: rotate(270deg);_x000D_
}_x000D_
.imagetest{_x000D_
overflow: hidden_x000D_
}
_x000D_
<article>_x000D_
<section class="photo">_x000D_
<div></div>_x000D_
<div class="imagetest">_x000D_
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSqVNRUwpfOwZ5n4kvVXea2VHd6QZGACVVaBOl5aJ2EGSG-WAIF" width=100%/>_x000D_
</div>_x000D_
</section>_x000D_
</article>
_x000D_
So, what I do is some calculations, in my example the picture is 455px width and 111px height and we have to add some margins based on these dimensions:
in CSS:
margin: calc((455px - 111px)/2) calc((111px - 455px)/2);
Result:
img{_x000D_
border: 1px solid #000;_x000D_
transform: rotate(270deg);_x000D_
-ms-transform: rotate(270deg);_x000D_
-moz-transform: rotate(270deg);_x000D_
-webkit-transform: rotate(270deg);_x000D_
-o-transform: rotate(270deg);_x000D_
/* 455 * 111 */_x000D_
margin: calc((455px - 111px)/2) calc((111px - 455px)/2);_x000D_
}
_x000D_
<article>_x000D_
<section class="photo">_x000D_
<div></div>_x000D_
<div class="imagetest">_x000D_
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSqVNRUwpfOwZ5n4kvVXea2VHd6QZGACVVaBOl5aJ2EGSG-WAIF" />_x000D_
</div>_x000D_
</section>_x000D_
</article>
_x000D_
I hope it helps someone!
the file is being opened and not closed for each call to the function also
Using openjdk-7 inside docker I have mounted a file with the content https://gist.github.com/dtelaroli/7d0831b1d5acc94c80209a5feb4e8f1c#file-jdk-security
#Location to mount
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/java.security
Thanks @luis-muñoz
Drop the public $bar;
declaration and it should work as expected.
You can also use reduce method:
>>> myList = [3, 5, 4, 9]
>>> myTotal = reduce(lambda x,y: x+y, myList)
>>> myTotal
21
Furthermore, you can modify the lambda function to do other operations on your list.
You should try using the option -i
for in-place editing.
QRGen is a good library that creates a layer on top of ZXing and makes QR Code generation in Java a piece of cake.
I think you're asking how to compute the mean of a variable in a data frame, given the name of the column. There are two typical approaches to doing this, one indexing with [[
and the other indexing with [
:
data(iris)
mean(iris[["Petal.Length"]])
# [1] 3.758
mean(iris[,"Petal.Length"])
# [1] 3.758
mean(iris[["Sepal.Width"]])
# [1] 3.057333
mean(iris[,"Sepal.Width"])
# [1] 3.057333
Once you have put the values into the JSONObject then put the JSONObject into the JSONArray staright after.
Something like this maybe:
jsonObj.put("value1", 1);
jsonObj.put("value2", 900);
jsonObj.put("value3", 1368349);
jsonArray.put(jsonObj);
Then create new JSONObject, put the other values into it and add it to the JSONArray:
jsonObj.put("value1", 2);
jsonObj.put("value2", 1900);
jsonObj.put("value3", 136856);
jsonArray.put(jsonObj);
package myguo;
import javax.swing.*;
public class MyGuo {
JFrame f;
JButton bt1 , bt2 ;
JTextField t1,t2;
JLabel l1,l2;
MyGuo(){
f=new JFrame("LOG IN FORM");
f.setLocation(500,300);
f.setSize(600,500);
f.setLayout(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
l1=new JLabel("NAME");
l1.setBounds(50,70,80,30);
l2=new JLabel("PASSWORD");
l2.setBounds(50,100,80,30);
t1=new JTextField();
t1.setBounds(140, 70, 200,30);
t2=new JTextField();
t2.setBounds(140, 110, 200,30);
bt1 =new JButton("LOG IN");
bt1.setBounds(150,150,80,30);
bt2 =new JButton("CLEAR");
bt2.setBounds(235,150,80,30);
f.add(l1);
f.add(l2);
f.add(t1);
f.add(t2);
f.add(bt1);
f.add(bt2);
f.setVisible(true);
}
public static void main(String[] args) {
MyGuo myGuo = new MyGuo();
}
}
Session.Clear();
In SQL without SELECT
you cannot result anything. Instead of IF-ELSE
block I prefer to use CASE
statement for this
SELECT CASE
WHEN EXISTS (SELECT 1
FROM tblGLUserAccess
WHERE GLUserName = 'xxxxxxxx') THEN 1
ELSE 2
END
It is also possible with Java 8 streams:
int[] a = IntStream.generate(() -> value).limit(count).toArray();
Probably, not the most efficient way to do the job, however.
.MERGE_MSG.swp is open in your git, you just need to delete this .swp file. In my case I used following command and it worked fine.
rm .MERGE_MSG.swp
For single arrays you can use implode, it has a cleaner result to print.
<?php
$msg = array('msg1','msg2','msg3');
echo implode('<br />',$msg);
echo '<br />----------------------<br/>';
echo nl2br(implode("\n",$msg));
echo '<br />----------------------<br/>';
?>
For multidimensional arrays you need to combine with some sort of loop.
<?php
$msgs[] = $msg;
$msgs[] = $msg;
$msgs[] = $msg;
$msgs[] = $msg;
$msgs[] = $msg;
foreach($msgs as $msg) {
echo implode('<br />',$msg);
echo '<br />----------------------<br/>';
}
?>
Adding a class with a width of 90% to your input element and adding the following input-icon class to your span would achieve what you want I think.
.input { width: 90%; }
.input-icon {
display: inline-block;
height: 22px;
width: 22px;
line-height: 22px;
text-align: center;
color: #000;
font-size: 12px;
font-weight: bold;
margin-left: 4px;
}
EDIT Per dan's suggestion, it would not be wise to use .input as the class name, some more specific would be advised. I was simply using .input as a generic placeholder for your css
I haven't used it yet but I would take a look at http://www.zoneminder.com/ The documentation explains you can install it on a modest machine with linux and use IP cameras for remote recording.
Andrew
You have a numpy array of strings, not floats. This is what is meant by dtype('<U9')
-- a little endian encoded unicode string with up to 9 characters.
try:
return sum(np.asarray(listOfEmb, dtype=float)) / float(len(listOfEmb))
However, you don't need numpy here at all. You can really just do:
return sum(float(embedding) for embedding in listOfEmb) / len(listOfEmb)
Or if you're really set on using numpy.
return np.asarray(listOfEmb, dtype=float).mean()
The MySQL dependency should be like the following syntax in the pom.xml file.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version>
</dependency>
Make sure the syntax, groupId, artifactId, Version has included in the dependancy.
Every class in Java has the toString()
method in it by default, which is called if you pass some object of that class to System.out.println()
. By default, this call returns the className@hashcode of that object.
{
SomeClass sc = new SomeClass();
// Class @ followed by hashcode of object in Hexadecimal
System.out.println(sc);
}
You can override the toString method of a class to get different output. See this example
class A {
String s = "I am just a object";
@Override
public String toString()
{
return s;
}
}
class B {
public static void main(String args[])
{
A obj = new A();
System.out.println(obj);
}
}
this seems to work as wel ->
@Override
public List<SomeObject> findAllForThisSpecificThing(String thing) {
final Query query = entityManager.createQuery(
"from " + getDomain().getSimpleName() + " t where t.thing = " + ((thing == null) ? " null" : " :thing"));
if (thing != null) {
query.setParameter("thing", thing);
}
return query.getResultList();
}
Btw, I'm pretty new at this, so if for any reason this isn't a good idea, let me know. Thanks.
itertools
provides the chain function for that:
From http://docs.python.org/library/itertools.html#recipes:
def flatten(listOfLists):
"Flatten one level of nesting"
return chain.from_iterable(listOfLists)
Note that the result is an iterable, so you may need list(flatten(...))
.
If you already have Java Development Kit on your PC and the bin directory is in your path (in most cases), you can use the command line:
jar xf test.zip
or if not in your path:
C:\Java\jdk1.6.0_03\bin>jar xf test.zip
Complete set of options for the jar tool available here.
Examples:
Extract jar file
jar x[v]f jarfile [inputfiles] [-Joption]
jar x[v] [inputfiles] [-Joption]
Make sure it's not blocked at your settings
http://www.howtogeek.com/howto/16404/how-to-disable-the-new-geolocation-feature-in-google-chrome/
You can just inject the DOCUMENT token into the constructor and use the same functions on it
import { Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
@Component({...})
export class AppCmp {
constructor(@Inject(DOCUMENT) document) {
document.getElementById('el');
}
}
Or if the element you want to get is in that component, you can use template references.
You can just do a cast
int val1 = 1;
float val2 = (float)val1;
or
decimal val3 = 3;
float val4 = (float)val3;
This problem was fixed for me by using http version of repository:
npm config set registry http://registry.npmjs.org/
I use the sync
subcommand of hub to automate this. I have alias git=hub
in my .bash_profile
, so the command I type is:
git sync
This updates all local branches that have a matching upstream branch. From the man page:
- If the local branch is outdated, fast-forward it;
- If the local branch contains unpushed work, warn about it;
- If the branch seems merged and its upstream branch was deleted, delete it.
It also handles stashing/unstashing uncommitted changes on the current branch.
I used to use a similar tool called git-up, but it's no longer maintained, and git sync
does almost exactly the same thing.
You just need to filter the cars that have a null
name:
requiredCars = cars.stream()
.filter(c -> c.getName() != null)
.filter(c -> c.getName().startsWith("M"));
I had a situation where i was working with a custom component and i needed to clear the form data.
But only if the page was in 'create' form state, and if the page was not being used to edit an existing item. So I made a method.
I called this method inside a watcher on custom component file, and not the vue page that uses the custom component. If that makes sense.
The entire form $ref was only available to me on the Base Custom Component.
<!-- Custom component HTML -->
<template>
<v-form ref="form" v-model="valid" @submit.prevent>
<slot v-bind="{ formItem, formState, valid }"></slot>
</v-form>
</template>
watch: {
value() {
// Some other code here
this.clearFormDataIfNotEdit(this)
// Some other code here too
}
}
... some other stuff ....
methods: {
clearFormDataIfNotEdit(objct) {
if (objct.formstate === 'create' && objct.formItem.id === undefined) {
objct.$refs.form.reset()
}
},
}
Basically i checked to see if the form data had an ID, if it did not, and the state was on create, then call the obj.$ref.form.reset()
if i did this directly in the watcher, then it would be this.$ref.form.reset()
obvs.
But you can only call the $ref from the page which it's referenced. Which is what i wanted to call out with this answer.
Asus Nexus 7 (2013) 32Gig: getMemoryClass()=192 maxMemory()=201326592
I made the mistake of prototyping my game on the Nexus 7, and then discovering it ran out of memory almost immediately on my wife's generic 4.04 tablet (memoryclass 48, maxmemory 50331648)
I'll need to restructure my project to load fewer resources when I determine memoryclass is low.
Is there a way in Java to see the current heap size? (I can see it clearly in the logCat when debugging, but I'd like a way to see it in code to adapt, like if currentheap>(maxmemory/2) unload high quality bitmaps load low quality
Yep, use dd in command line. Also I recommend to print useful image with ViM hotkeys available at http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
You don't need to encode data that is already encoded. When you try to do that, Python will first try to decode it to unicode
before it can encode it back to UTF-8. That is what is failing here:
>>> data = u'\u00c3' # Unicode data
>>> data = data.encode('utf8') # encoded to UTF-8
>>> data
'\xc3\x83'
>>> data.encode('utf8') # Try to *re*-encode it
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
Just write your data directly to the file, there is no need to encode already-encoded data.
If you instead build up unicode
values instead, you would indeed have to encode those to be writable to a file. You'd want to use codecs.open()
instead, which returns a file object that will encode unicode values to UTF-8 for you.
You also really don't want to write out the UTF-8 BOM, unless you have to support Microsoft tools that cannot read UTF-8 otherwise (such as MS Notepad).
For your MySQL insert problem, you need to do two things:
Add charset='utf8'
to your MySQLdb.connect()
call.
Use unicode
objects, not str
objects when querying or inserting, but use sql parameters so the MySQL connector can do the right thing for you:
artiste = artiste.decode('utf8') # it is already UTF8, decode to unicode
c.execute('SELECT COUNT(id) AS nbr FROM artistes WHERE nom=%s', (artiste,))
# ...
c.execute('INSERT INTO artistes(nom,status,path) VALUES(%s, 99, %s)', (artiste, artiste + u'/'))
It may actually work better if you used codecs.open()
to decode the contents automatically instead:
import codecs
sql = mdb.connect('localhost','admin','ugo&(-@F','music_vibration', charset='utf8')
with codecs.open('config/index/'+index, 'r', 'utf8') as findex:
for line in findex:
if u'#artiste' not in line:
continue
artiste=line.split(u'[:::]')[1].strip()
cursor = sql.cursor()
cursor.execute('SELECT COUNT(id) AS nbr FROM artistes WHERE nom=%s', (artiste,))
if not cursor.fetchone()[0]:
cursor = sql.cursor()
cursor.execute('INSERT INTO artistes(nom,status,path) VALUES(%s, 99, %s)', (artiste, artiste + u'/'))
artists_inserted += 1
You may want to brush up on Unicode and UTF-8 and encodings. I can recommend the following articles:
The exec
family of functions make your process execute a different program, replacing the old program it was running. I.e., if you call
execl("/bin/ls", "ls", NULL);
then the ls
program is executed with the process id, current working dir and user/group (access rights) of the process that called execl
. Afterwards, the original program is not running anymore.
To start a new process, the fork
system call is used. To execute a program without replacing the original, you need to fork
, then exec
.
I was facing same issue. I did not put @ResponseBody
since I was using @RestController
. But still I was getting error because I did not put the getter/setter
method for the Company class. So after putting the getter/setter
my problem was resolved.
temp = bankAccNos.contains(no) ? 1 : 2;
Dir.foreach("/home/mydir") do |fname|
puts fname
end
Since Google seems to like this answer...
If you're looking to match Bootstrap 4's naming convention, i.e. offset-*-#, here's that modification:
.offset-right-12 {
margin-right: 100%;
}
.offset-right-11 {
margin-right: 91.66666667%;
}
.offset-right-10 {
margin-right: 83.33333333%;
}
.offset-right-9 {
margin-right: 75%;
}
.offset-right-8 {
margin-right: 66.66666667%;
}
.offset-right-7 {
margin-right: 58.33333333%;
}
.offset-right-6 {
margin-right: 50%;
}
.offset-right-5 {
margin-right: 41.66666667%;
}
.offset-right-4 {
margin-right: 33.33333333%;
}
.offset-right-3 {
margin-right: 25%;
}
.offset-right-2 {
margin-right: 16.66666667%;
}
.offset-right-1 {
margin-right: 8.33333333%;
}
.offset-right-0 {
margin-right: 0;
}
@media (min-width: 576px) {
.offset-sm-right-12 {
margin-right: 100%;
}
.offset-sm-right-11 {
margin-right: 91.66666667%;
}
.offset-sm-right-10 {
margin-right: 83.33333333%;
}
.offset-sm-right-9 {
margin-right: 75%;
}
.offset-sm-right-8 {
margin-right: 66.66666667%;
}
.offset-sm-right-7 {
margin-right: 58.33333333%;
}
.offset-sm-right-6 {
margin-right: 50%;
}
.offset-sm-right-5 {
margin-right: 41.66666667%;
}
.offset-sm-right-4 {
margin-right: 33.33333333%;
}
.offset-sm-right-3 {
margin-right: 25%;
}
.offset-sm-right-2 {
margin-right: 16.66666667%;
}
.offset-sm-right-1 {
margin-right: 8.33333333%;
}
.offset-sm-right-0 {
margin-right: 0;
}
}
@media (min-width: 768px) {
.offset-md-right-12 {
margin-right: 100%;
}
.offset-md-right-11 {
margin-right: 91.66666667%;
}
.offset-md-right-10 {
margin-right: 83.33333333%;
}
.offset-md-right-9 {
margin-right: 75%;
}
.offset-md-right-8 {
margin-right: 66.66666667%;
}
.offset-md-right-7 {
margin-right: 58.33333333%;
}
.offset-md-right-6 {
margin-right: 50%;
}
.offset-md-right-5 {
margin-right: 41.66666667%;
}
.offset-md-right-4 {
margin-right: 33.33333333%;
}
.offset-md-right-3 {
margin-right: 25%;
}
.offset-md-right-2 {
margin-right: 16.66666667%;
}
.offset-md-right-1 {
margin-right: 8.33333333%;
}
.offset-md-right-0 {
margin-right: 0;
}
}
@media (min-width: 992px) {
.offset-lg-right-12 {
margin-right: 100%;
}
.offset-lg-right-11 {
margin-right: 91.66666667%;
}
.offset-lg-right-10 {
margin-right: 83.33333333%;
}
.offset-lg-right-9 {
margin-right: 75%;
}
.offset-lg-right-8 {
margin-right: 66.66666667%;
}
.offset-lg-right-7 {
margin-right: 58.33333333%;
}
.offset-lg-right-6 {
margin-right: 50%;
}
.offset-lg-right-5 {
margin-right: 41.66666667%;
}
.offset-lg-right-4 {
margin-right: 33.33333333%;
}
.offset-lg-right-3 {
margin-right: 25%;
}
.offset-lg-right-2 {
margin-right: 16.66666667%;
}
.offset-lg-right-1 {
margin-right: 8.33333333%;
}
.offset-lg-right-0 {
margin-right: 0;
}
}
@media (min-width: 1200px) {
.offset-xl-right-12 {
margin-right: 100%;
}
.offset-xl-right-11 {
margin-right: 91.66666667%;
}
.offset-xl-right-10 {
margin-right: 83.33333333%;
}
.offset-xl-right-9 {
margin-right: 75%;
}
.offset-xl-right-8 {
margin-right: 66.66666667%;
}
.offset-xl-right-7 {
margin-right: 58.33333333%;
}
.offset-xl-right-6 {
margin-right: 50%;
}
.offset-xl-right-5 {
margin-right: 41.66666667%;
}
.offset-xl-right-4 {
margin-right: 33.33333333%;
}
.offset-xl-right-3 {
margin-right: 25%;
}
.offset-xl-right-2 {
margin-right: 16.66666667%;
}
.offset-xl-right-1 {
margin-right: 8.33333333%;
}
.offset-xl-right-0 {
margin-right: 0;
}
}
You can use a simple, low-cost USB port reader like this test connects directly to your Android device; it has a utility app and an SDK you can use for app development: https://www.atlasrfidstore.com/sls-rfid-smartmicro-android-micro-usb-reader/
That's not what map does. You really want Array.filter
. Or if you really want to remove the elements from the original list, you're going to need to do it imperatively with a for loop.
While using TOP or a sub-query both work, I would break the problem into steps:
Find target record
SELECT MIN( date ) AS date, id
FROM myTable
WHERE id = 2
GROUP BY id
Join to get other fields
SELECT mt.id, mt.name, mt.score, mt.date
FROM myTable mt
INNER JOIN
(
SELECT MIN( date ) AS date, id
FROM myTable
WHERE id = 2
GROUP BY id
) x ON x.date = mt.date AND x.id = mt.id
While this solution, using derived tables, is longer, it is:
It is easier to test as parts of the query can be run standalone.
It is self documenting as the query directly reflects the requirement ie the derived table lists the row where id = 2 with the earliest date.
It is extendable as if another condition is required, this can be easily added to the derived table.
You might also try fixing the hosts file.
Keep the vhost file with the fully qualified domain and add the hostname in the hosts file /etc/hosts (debian)
ip.ip.ip.ip name name.domain.com
After restarting apache2, the error should be gone.
If you don't mind the commas and the brackets you can simply use:
System.out.println(Arrays.deepToString(twoDm).replace("], ", "]\n"));
-- Please look into these.
select FORMAT(1, 'd4');
select FORMAT(2, 'd4');
select FORMAT(12, 'd4');
select FORMAT(123, 'd4');
select FORMAT(1234, 'd4');
-- I hope these would help you
A hard reset will also resolve the problem
git reset --hard origin/master
If you are looking for the executable that npm installed, maybe because you would like to put it in your PATH, you can simply do
npm bin
or
npm bin -g
Not really. Fatal errors are called that, because they are fatal. You can't recover from them.
A portable approach that works equally well on Linux or Windows (where there is no /dev/null):
echo | gcc -dM -E -
For c++ you may use (replace c++11
with whatever version you use):
echo | gcc -x c++ -std=c++11 -dM -E -
It works by telling gcc to preprocess stdin (which is produced by echo) and print all preprocessor defines (search for -dletters
). If you want to know what defines are added when you include a header file you can use -dD
option which is similar to -dM but does not include predefined macros:
echo "#include <stdlib.h>" | gcc -x c++ -std=c++11 -dD -E -
Note, however, that empty input still produces lots of defines with -dD
option.
DLL Export Viewer by NirSoft can be used to display exported functions in a DLL.
This utility displays the list of all exported functions and their virtual memory addresses for the specified DLL files. You can easily copy the memory address of the desired function, paste it into your debugger, and set a breakpoint for this memory address. When this function is called, the debugger will stop in the beginning of this function.
Well you can use below command,
mysqldump --databases --user=root --password your_db_name > export_into_db.sql
and the generated file will be available in the same directory where you had ran this command.
You could find more on the official reference for mysqldump
: Import Export MySQL DB
Note: use --databases
instead of --database
since the last one is no more supported.
Enjoy :)
It turns out that lstlisting
is able to format code nicely, but requires a lot of tweaking.
Wikibooks has a good example for the parameters you can tweak.
You could use
protected $casts = [
'created_at' => "datetime:Y-m-d\TH:iPZ",
];
in your model class or any format following this link https://www.php.net/manual/en/datetime.format.php
$.browser
was deprecated in version 1.3 and removed in 1.9
You can verify this by viewing the documentation.
// just in case some one is searching for a solution
function get_parent_frame_dom_element(win)
{
win = (win || window);
var parentJQuery = window.parent.jQuery;
var ifrms = parentJQuery("iframe.upload_iframe");
for (var i = 0; i < ifrms.length; i++)
{
if (ifrms[i].contentDocument === win.document)
return ifrms[i];
}
return null;
}
As an alternative:
Using CROSS APPLY and VALUES performs this operation quite simply and efficiently with just a single pass of the table (unlike union queries that do one pass for every column)
SELECT
ca.ColName, ca.ColValue
FROM YOurTable
CROSS APPLY (
Values
('ScripName' , ScripName),
('ScripCode' , ScripCode),
('Price' , cast(Price as varchar(50)) )
) as CA (ColName, ColValue)
Personally I find this syntax easier than using unpivot.
NB: You must take care that all source columns are converted into compatible types for the single value column
You can include the ruby mathn
module.
require 'mathn'
This way, you are going to be able to make the division normally.
1/2 #=> (1/2)
(1/2) ** 3 #=> (1/8)
1/3*3 #=> 1
Math.sin(1/2) #=> 0.479425538604203
This way, you get exact division (class Rational) until you decide to apply an operation that cannot be expressed as a rational, for example Math.sin
.
m1 = (y2 - y1) / (x2 - x1)
if perpendicular two lines:
m1*m2 = -1
then
m2 = -1 / m1 //if (m1 == 0, then your line should have an equation like x = b)
y = m2*x + b //b is offset of new perpendicular line..
b is something if you want to pass it from a point you defined
We can use rename_with
to rename columns with a function (stringr
functions, for example).
Consider the following data df_1
:
df_1 <- data.frame(
x = replicate(n = 3, expr = rnorm(n = 3, mean = 10, sd = 1)),
y = sample(x = 1:2, size = 10, replace = TRUE)
)
names(df_1)
#[1] "x.1" "x.2" "x.3" "y"
Rename all variables with dplyr::everything()
:
library(tidyverse)
df_1 %>%
rename_with(.data = ., .cols = everything(.),
.fn = str_replace, pattern = '.*',
replacement = str_c('var', seq_along(.), sep = '_')) %>%
names()
#[1] "var_1" "var_2" "var_3" "var_4"
Rename by name particle with some dplyr
verbs (starts_with
, ends_with
, contains
, matches
, ...).
Example with .
(x
variables):
df_1 %>%
rename_with(.data = ., .cols = contains('.'),
.fn = str_replace, pattern = '.*',
replacement = str_c('var', seq_along(.), sep = '_')) %>%
names()
#[1] "var_1" "var_2" "var_3" "y"
Rename by class with many functions of class test, like is.integer
, is.numeric
, is.factor
...
Example with is.integer
(y
):
df_1 %>%
rename_with(.data = ., .cols = is.integer,
.fn = str_replace, pattern = '.*',
replacement = str_c('var', seq_along(.), sep = '_')) %>%
names()
#[1] "x.1" "x.2" "x.3" "var_1"
The warning:
Warning messages: 1: In stri_replace_first_regex(string, pattern, fix_replacement(replacement), : longer object length is not a multiple of shorter object length 2: In names[cols] <- .fn(names[cols], ...) : number of items to replace is not a multiple of replacement length
It is not relevant, as it is just an inconsistency of seq_along(.)
with the replace function.
JVM does not find java.exe
. It doesn't even call it. java.exe
is called by the operating system (Windows in this case).
JAVA_HOME
is just a convention, usually used by Tomcat, other Java EE app servers and build tools such as Gradle
to find where Java lives.
The important thing from your point of view is that the Java /bin
directory be on your PATH
so Windows can find the .exe
tools that ship with the JDK: javac.exe
, java.exe
, jar.exe
, etc.
In Java 8 you can use:
LocalDate date = LocalDate.now(); //2020-01-12
date.withDayOfMonth(1); //2020-01-01
I've managed to get it working using curl:
curl -u <username>:<password> https://myrepo.example/v1/repositories/<username>/<image_name>/tags
Note that image_name
should not contain user details etc. For example if you're pushing image named myrepo.example/username/x
then image_name
should be x
.
the small one implement by the OS
<RatingBar
android:id="@+id/ratingBar"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
#include<stdio.h>
int main()
{
int a,b,i,c,j;
printf("\n Enter the two no. in between you want to check:");
scanf("%d%d",&a,&c);
printf("%d-%d\n",a,c);
for(j=a;j<=c;j++)
{
b=0;
for(i=1;i<=c;i++)
{
if(j%i==0)
{
b++;
}
}
if(b==2)
{
printf("\nPrime number:%d\n",j);
}
else
{
printf("\n\tNot prime:%d\n",j);
}
}
}
Either use loop counting down over indices:
for (NSInteger i = array.count - 1; i >= 0; --i) {
or make a copy with the objects you want to keep.
In particular, do not use a for (id object in array)
loop or NSEnumerator
.
BEST ANSWER 1:
ActionNameSelectorAttribute
mentioned in
ANSWER 2
Reference: dotnet-tricks - Handling multiple submit buttons on the same form - MVC Razor
Second Approach
Adding a new Form for handling Cancel button click. Now, on Cancel button click we will post the second form and will redirect to the home page.
Third Approach: Client Script
<button name="ClientCancel" type="button"
onclick=" document.location.href = $('#cancelUrl').attr('href');">Cancel (Client Side)
</button>
<a id="cancelUrl" href="@Html.AttributeEncode(Url.Action("Index", "Home"))"
style="display:none;"></a>
All cookies expire as per the cookie specification, Maximum value you can set is
2^31 - 1 = 2147483647 = 2038-01-19 04:14:07
So Maximum cookie life time is
$.cookie('subscripted_24', true, { expires: 2147483647 });
Nice way to handle not found error in Django.
https://docs.djangoproject.com/en/3.1/topics/http/shortcuts/#get-object-or-404
from django.shortcuts import get_object_or_404
def get_data(request):
obj = get_object_or_404(Model, pk=1)
I think that this happens because you are running it on source mode with the dot
. myscript.sh
You should run that in a subshell:
/full/path/to/script/myscript.sh
'source' http://ss64.com/bash/source.html
It declares a type based on what is assigned to it in the initialisation.
A simple example is that the code:
var i = 53;
Will examine the type of 53, and essentially rewrite this as:
int i = 53;
Note that while we can have:
long i = 53;
This won't happen with var. Though it can with:
var i = 53l; // i is now a long
Similarly:
var i = null; // not allowed as type can't be inferred.
var j = (string) null; // allowed as the expression (string) null has both type and value.
This can be a minor convenience with complicated types. It is more important with anonymous types:
var i = from x in SomeSource where x.Name.Length > 3 select new {x.ID, x.Name};
foreach(var j in i)
Console.WriteLine(j.ID.ToString() + ":" + j.Name);
Here there is no other way of defining i
and j
than using var
as there is no name for the types that they hold.
For me, I got this same error in VS 2015 and just installed the VS 2015 update 1, though from another answer, VS is actually up to Update 3, now (after which, they got the error and had to install .NET Core). Had issues when it hit certain packages, like the Windows SDK ones, and had to point the installer back at the paths in my original CD, and for some, even that didn't work and had to skip them and re-download from an internet-connected computer, transfer them over, and run them later manually (computer was not connected to the internet to be able to download updated versions of the packages), but after doing all that and doing a reboot, the error was gone and my project loaded fine.
I suggest Arrays.toString(byte_array);
It depends on your purpose. For example, I wanted to save a byte array exactly like the format you can see at time of debug that is something like this : [1, 2, 3]
If you want to save exactly same value without converting the bytes to character format, Arrays.toString (byte_array)
does this,. But if you want to save characters instead of bytes, you should use String s = new String(byte_array)
. In this case, s
is equal to equivalent of [1, 2, 3]
in format of character.
I encountered the same error message after unpacking MinGW archives to C:\MinGW
and setting the path to environment variable as C:\MinGW\bin;
.
When I try to compile I get this error!
gcc: error: CreateProcess: No such file or directory
I finally figured out that some of the downloaded archives were reported broken while unpaking them to C:\MinGW
(yet I ignored this initially).
Once I deleted the broken files and re-downloaded the whole archives again from SourceForge, unpacked them to C:\MinGW successfully the error was gone, and the compiler worked fine and output my desired hello.exe
.
I ran this:
gcc hello.c -o hello
The result result was this (a blinking underscore):
_
This happens from time to time in Eclipse. In the "Project" menu there's a "Clean" option, that usually takes care of the problem.
How about list.Find(x => x.Name == "height").Value = 20;
This works fine. I know its an old post, but just wondered why hasn't anyone suggested this? Is there a drawback in this code?