Remove warnings.filterwarnings and add:
numpy.seterr(all='raise')
public class ZeroDivisionException extends ArithmeticException {
// ...
}
if (denominator == 0) {
throw new ZeroDivisionException();
}
Since you are explicitly also asking to handle columns that haven't yet been filled out, and I assume also don't want to mess with them if they have a word instead of a number, you might consider this:
=If(IsNumber(K23), If(K23 > 0, ........., 0), 0)
This just says... If K23 is a number; And if that number is greater than zero; Then do something ......... Otherwise, return zero.
In ........., you might put your division equation there, such as A1/K23
, and you can rest assured that K23 is a number which is greater than zero.
simple with generated links :) html:
<span class='preview' data-image-url="imageUrl.png" data-container="body" data-toggle="popover" data-placement="top" >preview</span>
js:
$('.preview').popover({
'trigger':'hover',
'html':true,
'content':function(){
return "<img src='"+$(this).data('imageUrl')+"'>";
}
});
I uninstall Only Android studio (keep the SDK and Emulator) and then reinstall it just android studio. took me 2 minutes and my android studio work again.
I had similar error: "Expecting value: line 1 column 1 (char 0)"
It helped for me to add "myfile.seek(0)", move the pointer to the 0 character
with open(storage_path, 'r') as myfile:
if len(myfile.readlines()) != 0:
myfile.seek(0)
Bank_0 = json.load(myfile)
Another option that may be suitable in this situation is using XML
The XML option to transposing rows into columns is basically an optimal version of the PIVOT in that it addresses the dynamic column limitation.
The XML version of the script addresses this limitation by using a combination of XML Path, dynamic T-SQL and some built-in functions (i.e. STUFF, QUOTENAME).
Vertical expansion
Similar to the PIVOT and the Cursor, newly added policies are able to be retrieved in the XML version of the script without altering the original script.
Horizontal expansion
Unlike the PIVOT, newly added documents can be displayed without altering the script.
Performance breakdown
In terms of IO, the statistics of the XML version of the script is almost similar to the PIVOT – the only difference is that the XML has a second scan of dtTranspose table but this time from a logical read – data cache.
You can find some more about these solutions (including some actual T-SQL exmaples) in this article: https://www.sqlshack.com/multiple-options-to-transposing-rows-into-columns/
First of all, sha256 is a hashing algorithm, not a type of encryption. An encryption would require having a way to decrypt the information back to its original value (collisions aside).
Looking at your code, it seems it should work if you are providing the correct parameter.
Try using a literal string in your code first, and verify its validity instead of using the $_POST[]
variable
Try moving the comparison from the database query to the code (get the hash for the given user and compare to the hash you have just calculated)
But most importantly before deploying this in any kind of public fashion, please remember to sanitize your inputs. Don't allow arbitrary SQL to be insert into the queries. The best idea here would be to use parameterized queries.
from pyspark.sql.functions import udf
from pyspark.sql.types import *
func_name = udf(
lambda val: val, # do sth to val
StringType()
)
df.withColumn('new_col', func_name(df.old_col))
If the file is copied from a network location, that is, another computer, Windows might have blocked that file. Right click on the file and click on the unblock button and see if it works.
<?php
function download_page($path){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$path);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$retValue = curl_exec($ch);
curl_close($ch);
return $retValue;
}
$sXML = download_page('http://alanstorm.com/atom');
$oXML = new SimpleXMLElement($sXML);
foreach($oXML->entry as $oEntry){
echo $oEntry->title . "\n";
}
Use <br />
OR <br>
-
<li>Post by<br /><a>Author</a></li>
OR
<li>Post by<br><a>Author</a></li>
or
make the a
element display:block;
<li>Post by <a style="display:block;">Author</a></li>
What you are looking for is 'type casting'. typecasting (putting the type you know you want in brackets) tells the compiler you know what you are doing and are cool with it. The old way that is inherited from C is as follows.
float var_a = 9.99;
int var_b = (int)var_a;
If you had only tried to write
int var_b = var_a;
You would have got a warning that you can't implicitly (automatically) convert a float
to an int
, as you lose the decimal.
This is referred to as the old way as C++ offers a superior alternative, 'static cast'; this provides a much safer way of converting from one type to another. The equivalent method would be (and the way you should do it)
float var_x = 9.99;
int var_y = static_cast<int>(var_x);
This method may look a bit more long winded, but it provides much better handling for situations such as accidentally requesting a 'static cast' on a type that cannot be converted. For more information on the why you should be using static cast, see this question.
Use the other answers if you don't mind losing local changes. This method can still wreck your remote if you choose the wrong commit hash to go back to.
If you just want to make the remote match a commit that's anywhere in your local repo:
git log
to find the commit you want to the remote to be at. git log -p
to see changes, or git log --graph --all --oneline --decorate
to see a compact tree.Run a command like:
git push --force <remote> <commit-ish>:<the remote branch>
e.g.
git push --force origin 606fdfaa33af1844c86f4267a136d4666e576cdc:master
or
git push --force staging v2.4.0b2:releases
I use convenient alias (git go
) for viewing history as in step 2, which can be added like so:
git config --global alias.go 'log --graph --all --decorate --oneline'`
Functions in Bash are not functions like in other language; they're actually commands. So functions are used as if they were binaries or scripts fetched from your path. From the perspective of your program logic there should be really no difference.
Shell commands are connected by pipes (aka streams), and not fundamental or user-defined data types, as in "real" programming languages. There is no such thing like a return value for a command, maybe mostly because there's no real way to declare it. It could occur on the man-page, or the --help
output of the command, but both are only human-readable and hence are written to the wind.
When a command wants to get input it reads it from its input stream, or the argument list. In both cases text strings have to be parsed.
When a command wants to return something it has to echo
it to its output stream. Another oftenly practiced way is to store the return value in dedicated, global variables. Writing to the output stream is clearer and more flexible, because it can take also binary data. For example, you can return a BLOB easily:
encrypt() {
gpg -c -o- $1 # encrypt data in filename to stdout (asks for a passphrase)
}
encrypt public.dat > private.dat # write function result to file
As others have written in this thread, the caller can also use command substitution $()
to capture the output.
Parallely, the function would "return" the exit code of gpg
(GnuPG). Think of the exit code as a bonus that other languages don't have, or, depending on your temperament, as a "Schmutzeffekt" of shell functions. This status is, by convention, 0 on success or an integer in the range 1-255 for something else. To make this clear: return
(like exit
) can only take a value from 0-255, and values other than 0 are not necessarily errors, as is often asserted.
When you don't provide an explicit value with return
the status is taken from the last command in a Bash statement/function/command and so forth. So there is always a status, and return
is just an easy way to provide it.
You'll first need to separate your numpy array into two separate arrays containing x and y values.
x = [1, 2, 3, 9]
y = [1, 4, 1, 3]
curve_fit also requires a function that provides the type of fit you would like. For instance, a linear fit would use a function like
def func(x, a, b):
return a*x + b
scipy.optimize.curve_fit(func, x, y)
will return a numpy array containing two arrays: the first will contain values for a
and b
that best fit your data, and the second will be the covariance of the optimal fit parameters.
Here's an example for a linear fit with the data you provided.
import numpy as np
from scipy.optimize import curve_fit
x = np.array([1, 2, 3, 9])
y = np.array([1, 4, 1, 3])
def fit_func(x, a, b):
return a*x + b
params = curve_fit(fit_func, x, y)
[a, b] = params[0]
This code will return a = 0.135483870968
and b = 1.74193548387
Here's a plot with your points and the linear fit... which is clearly a bad one, but you can change the fitting function to obtain whatever type of fit you would like.
It means you have a null reference somewhere in there. Can you debug the app and stop the debugger when it gets here and investigate? Probably img1
is null or ConfigurationManager.AppSettings.Get("Url")
is returning null.
I solved that adding a Web facet.
http://im4java.sourceforge.net/ - if you're running linux forking a new process isn't expensive.
With trackerless/DHT torrents, peer IP addresses are stored in the DHT using the BitTorrent infohash as the key. Since all a tracker does, basically, is respond to put/get requests, this functionality corresponds exactly to the interface that a DHT (distributed hash table) provides: it allows you to look up and store IP addresses in the DHT by infohash.
So a "get" request would look up a BT infohash and return a set of IP addresses. A "put" stores an IP address for a given infohash. This corresponds to the "announce" request you would otherwise make to the tracker to receive a dictionary of peer IP addresses.
In a DHT, peers are randomly assigned to store values belonging to a small fraction of the key space; the hashing ensures that keys are distributed randomly across participating peers. The DHT protocol (Kademlia for BitTorrent) ensures that put/get requests are routed efficiently to the peers responsible for maintaining a given key's IP address lists.
column-span: all; /* W3C */
-webkit-column-span: all; /* Safari & Chrome */
-moz-column-span: all; /* Firefox */
-ms-column-span: all; /* Internet Explorer */
-o-column-span: all; /* Opera */
http://www.quackit.com/css/css3/properties/css_column-span.cfm
You may want to clear your DropDown first $('#DropDownQuality').empty();
I had my controller in MVC return a select list with only one item.
$('#DropDownQuality').append(
$('<option></option>').val(data[0].Value).html(data[0].Text));
Try compiling your .NET assembly with the option --staticlink:"Namespace.Assembly"
. This forces the compiler to pull in all the dependencies at compile time. If it comes across a dependency that's not referenced it will give a warning or error message usually with the name of that assembly.
Namespace.Assembly
is the assembly you suspect as having the dependency problem. Typically just statically linking this assembly will reference all dependencies transitively.
$url = 'http://www.example.com';
$xml = simpleXML_load_file($url,"SimpleXMLElement",LIBXML_NOCDATA);
$url can be php file, as long as the file generate xml format data as output.
I get the same error. the solution is to put your script code before the end of body, not in the head section.
use pgAdmin or use pg_proc to get the source of your stored procedures. pgAdmin does the same.
if (select == "") {
alert("Please select a selection");
return false;
That should work for you. It just did for me.
BadImageFormatException occures when a 32bit (x86) dll calls a 64bit dll or vice versa. If using AnyCPU for your entry executable then when run on a 64bit machine it will run as 64bit, however if that then calls a 32bit dll you get the exception which is why AnyCPU isn't always the answer.
I tend to build everything as 32bit (x86) as we still have to interface with some old components done in VB6 (32bit (x86)). While performance might be better for 64bit machines if we where to build in AnyCPU reliability is more important for us.
I would suggest trying to build all you components in 32bit (x86), unless you are doing some really intensive stuff I doubt it will make much difference.
To call the method, you need to qualify function with self.
. In addition to that, if you want to pass a filename, add a filename
parameter (or other name you want).
class MyHandler(FileSystemEventHandler):
def on_any_event(self, event):
srcpath = event.src_path
print (srcpath, 'has been ',event.event_type)
print (datetime.datetime.now())
filename = srcpath[12:]
self.dropbox_fn(filename) # <----
def dropbox_fn(self, filename): # <-----
print('In dropbox_fn:', filename)
JSON.parse
is the opposite of JSON.stringify
.
You can use a CSS3 transition
for this. Have a look at this example:
Here is the main code:
#box {
position : relative;
width : 100px;
height : 100px;
background-color : gray;
border : 5px solid black;
-webkit-transition : border 500ms ease-out;
-moz-transition : border 500ms ease-out;
-o-transition : border 500ms ease-out;
transition : border 500ms ease-out;
}
#box:hover {
border : 10px solid red;
}
Here's a short one-liner with es6!
const nums = [
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC9233F2015",
"AC9233F2015",
"AC9233F2015",
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC8818E2",
"AC8818E2",
"AC8818E2",
"AC8818E2",
"AC9233F2015",
"AC9233F2015",
"AC9233F2015",
"AC9233F2015",
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC8818E2",
"AC8818E2",
"AC9233F2015",
"AC9233F2015",
"AC8818E1",
"AC8818E1",
"AC8818E1",
"AC8818E2",
"AC8818E2",
"AC8818E2",
"AC8818E2",
"ACB098F25",
"ACB098F25",
"ACB098F25",
"ACB098F25",
"AC8818E2",
"AC8818E2",
"AC8818E1",
"AC8818E1",
"AC8818E1",
]
Set is a new data object introduced in ES6. Because Set only lets you store unique values. When you pass in an array, it will remove any duplicate values.
export const $uniquenums = [...new Set(nums)].sort();
You should read up on the onclick
html attribute and the window.open()
documentation. Below is what you want.
<a href='#' onclick='window.open("http://www.google.com", "myWin", "scrollbars=yes,width=400,height=650"); return false;'>1</a>
_x000D_
JSFiddle: http://jsfiddle.net/TBcVN/
Here is one way to do it
_,_,rest = s.partition(start)
result,_,_ = rest.partition(end)
print result
Another way using regexp
import re
print re.findall(re.escape(start)+"(.*)"+re.escape(end),s)[0]
or
print re.search(re.escape(start)+"(.*)"+re.escape(end),s).group(1)
I actually came across something like this not too long ago... check it out over on msdn (see the first answer)
in summary:
.cer - certificate stored in the X.509 standard format. This certificate contains information about the certificate's owner... along with public and private keys.
.pvk - files are used to store private keys for code signing. You can also create a certificate based on .pvk private key file.
.pfx - stands for personal exchange format. It is used to exchange public and private objects in a single file. A pfx file can be created from .cer file. Can also be used to create a Software Publisher Certificate.
I summarized the info from the page based on the suggestion from the comments.
I think you can use the "engines" field:
{ "engines" : { "node" : ">=0.12" } }
As you're saying your code definitely won't work with any lower versions, you probably want the "engineStrict" flag too:
{ "engineStrict" : true }
Documentation for the package.json file can be found on the npmjs site
Update
engineStrict
is now deprecated, so this will only give a warning. It's now down to the user to run npm config set engine-strict true
if they want this.
Update 2
As ben pointed out below, creating a .npmrc
file at the root of your project (the same level as your package.json file) with the text engine-strict=true
will force an error during installation if the Node version is not compatible.
In addition to the plt.axvline
and plt.plot((x1, x2), (y1, y2))
OR plt.plot([x1, x2], [y1, y2])
as provided in the answers above, one can also use
plt.vlines(x_pos, ymin=y1, ymax=y2)
to plot a vertical line at x_pos
spanning from y1
to y2
where the values y1
and y2
are in absolute data coordinates.
In my case, the problem I had was due to a dependency I was trying to import (BottomNavigationViewEx).
This dependency requires to be downloaded from jitpack.io and maven.google.com, and I was putting this config in buildscript section:
buildscript {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" } // this is incorrect
maven { url "https://maven.google.com" } // this is incorrect
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
which it was incorrect, I need to remove these two maven lines and include them in the right section, 'allprojects':
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
Hope it helps somebody as same for me.
Just ran into this problem myself and it turned out to be that my site in IIS was set up to use anonymous authentication with a specific network account. I had been forced to reset the password on that account, and so IIS was failing because it was using the old one. Once I updated the site with the new password (or even better, changed it to use Network Service instead), all worked again.
@Html.Partial("nameOfPartial", Model)
Update
protected string RenderPartialViewToString(string viewName, object model)
{
if (string.IsNullOrEmpty(viewName))
viewName = ControllerContext.RouteData.GetRequiredString("action");
ViewData.Model = model;
using (StringWriter sw = new StringWriter()) {
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
viewResult.View.Render(viewContext, sw);
return sw.GetStringBuilder().ToString();
}
}
If you're using MySQL, then you can use insert ... on duplicate.
First You have to check that is the Docker Database port is Available in your system by following command -
sudo iptables -L -n
Sample OUTPUT:
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 172.17.0.2 tcp dpt:3306
ACCEPT tcp -- 0.0.0.0/0 172.17.0.3 tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 172.17.0.3 tcp dpt:22
Here 3306
is used as Docker Database Port on 172.17.0.2 IP, If this port is not available Run the following command -
sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
Now, You can easily access the Docker Database from your local system by following configuration
host: 172.17.0.2
adapter: mysql
database: DATABASE_NAME
port: 3307
username: DATABASE_USER
password: DATABASE_PASSWORD
encoding: utf8
First You have to check that is the Docker Database port is Available in your firewall by following command -
sudo firewall-cmd --list-all
Sample OUTPUT:
target: default
icmp-block-inversion: no
interfaces: eno79841677
sources:
services: dhcpv6-client ssh
**ports: 3307/tcp**
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules:
Here 3307
is used as Docker Database Port on 172.17.0.2 IP, If this port is not available Run the following command -
sudo firewall-cmd --zone=public --add-port=3307/tcp
In server, You can add the port permanently
sudo firewall-cmd --permanent --add-port=3307/tcp
sudo firewall-cmd --reload
Now, You can easily access the Docker Database from your local system by the above configuration.
Note that the names generated by the RTTI feature of C++ is not portable. For example, the class
MyNamespace::CMyContainer<int, test_MyNamespace::CMyObject>
will have the following names:
// MSVC 2003:
class MyNamespace::CMyContainer[int,class test_MyNamespace::CMyObject]
// G++ 4.2:
N8MyNamespace8CMyContainerIiN13test_MyNamespace9CMyObjectEEE
So you can't use this information for serialization. But still, the typeid(a).name() property can still be used for log/debug purposes
The code which David Hedlund has posted gave me the error:
Unable to add window — token null is not valid
If you are getting the same error use the below code. It works!!
runOnUiThread(new Runnable() {
@Override
public void run() {
if (!isFinishing()){
new AlertDialog.Builder(YourActivity.this)
.setTitle("Your Alert")
.setMessage("Your Message")
.setCancelable(false)
.setPositiveButton("ok", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Whatever...
}
}).show();
}
}
});
After adding the icon to the toolbar and when modifying the selected icon, the ampersand in the name input is specifying that the next character is the character used along with Alt for the shortcut. Since you must select a display option from the Modify Selection drop down menu that includes displaying the text, you could also write &C in the name field and get the same result as &Comment Block (without the lengthy text).
You can use the --prefix
option:
mkdir -p ./install/here/node_modules
npm install --prefix ./install/here <package>
The package(s) will then be installed in ./install/here/node_modules
. The mkdir
is needed since npm might otherwise choose an already existing node_modules
directory higher up in the hierarchy. (See npm documentation on folders.)
I faced the same issue. Just download and install the SQL Server suite from the following link :http://www.microsoft.com/en-US/download/details.aspx?id=42299
restart your SSMS and you should be able to "Register Local Servers" via right-click on "Local Servers Groups", select "tasks", click "register local servers"
Try following code. It is working for me....
UPDATE TableOne
SET
field1 =(SELECT TableTwo.field1 FROM TableTwo WHERE TableOne.id=TableTwo.id),
field2 =(SELECT TableTwo.field2 FROM TableTwo WHERE TableOne.id=TableTwo.id)
WHERE TableOne.id = (SELECT TableTwo.id
FROM TableTwo
WHERE TableOne.id = TableTwo.id)
you can use this too
echo substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], '.', -5));
The difference is that a nested class declaration that is also static can be instantiated outside of the enclosing class.
When you have a nested class declaration that is not static, also known as an inner class, Java won't let you instantiate it except via the enclosing class. The object created out of the inner class is linked to the object created from the outer class, so the inner class can reference the fields of the outer.
But if it's static, then the link does not exist, the outer fields cannot be accessed (except via an ordinary reference like any other object) and you can therefore instantiate the nested class by itself.
As mentioned by many, "ctor" and double TAB works in Visual Studio 2017, but it only creates the constructor with none of the attributes.
To auto-generate with attributes (if there are any), just click on an empty line below them and press Ctrl + .. It'll display a small pop-up from which you can select the "Generate Constructor..." option.
package com.adil.util;
/**
* The Class RandomColor.
*
* @author Adil OUIDAD
* @URL : http://kizana.fr
*/
public class RandomColor {
/**
* Gets the random color.
*
* @return the random color
*/
public static String getRandomColor() {
String[] letters = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
String color = "#";
for (int i = 0; i < 6; i++ ) {
color += letters[(int) Math.round(Math.random() * 15)];
}
return color;
}
}
In Internet Explorer 9 (and 8), the console
object is only exposed when the developer tools are opened for a particular tab. If you hide the developer tools window for that tab, the console
object remains exposed for each page you navigate to. If you open a new tab, you must also open the developer tools for that tab in order for the console
object to be exposed.
The console
object is not part of any standard and is an extension to the Document Object Model. Like other DOM objects, it is considered a host object and is not required to inherit from Object
, nor its methods from Function
, like native ECMAScript functions and objects do. This is the reason apply
and call
are undefined on those methods. In IE 9, most DOM objects were improved to inherit from native ECMAScript types. As the developer tools are considered an extension to IE (albeit, a built-in extension), they clearly didn't receive the same improvements as the rest of the DOM.
For what it's worth, you can still use some Function.prototype
methods on console
methods with a little bind()
magic:
var log = Function.prototype.bind.call(console.log, console);
log.apply(console, ["this", "is", "a", "test"]);
//-> "thisisatest"
In my case ; what solved my issue was.....
You may had json like this, the keys without " double quotations....
{ name: "test", phone: "2324234" }
So try any online Json Validator to make sure you have right syntax...
Yes, something like this:
SELECT
id,
action_heading,
CASE
WHEN action_type = 'Income' THEN action_amount
ELSE NULL
END AS income_amt,
CASE
WHEN action_type = 'Expense' THEN action_amount
ELSE NULL
END AS expense_amt
FROM tbl_transaction;
As other answers have pointed out, MySQL also has the IF()
function to do this using less verbose syntax. I generally try to avoid this because it is a MySQL-specific extension to SQL that isn't generally supported elsewhere. CASE
is standard SQL and is much more portable across different database engines, and I prefer to write portable queries as much as possible, only using engine-specific extensions when the portable alternative is considerably slower or less convenient.
On Windows OS without Service.
start.bat
@ECHO OFF
call run.bat start
stop.bat:
@ECHO OFF
call run.bat stop
run.bat
@ECHO OFF
IF "%1"=="start" (
ECHO start myapp
start "myapp" java -jar -Dspring.profiles.active=staging myapp.jar
) ELSE IF "%1"=="stop" (
ECHO stop myapp
TASKKILL /FI "WINDOWTITLE eq myapp"
) ELSE (
ECHO please, use "run.bat start" or "run.bat stop"
)
pause
One should NEVER call System.exit(0)
for these reasons:
Quitting the program "normally" provides the same exit code to the operating system as System.exit(0)
so it is redundant.
If your program cannot quit "normally" you have lost control of your development [design]. You should have always full control of the system state.
By the way: Returning other return codes than 0 does make sense if you want to indicate abnormal program termination.
You can use the fmt=
parameter and fill the value based on the following table :
http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
Ex : your URL would become :
http://www.youtube.com/embed/FqRgAs0SOpU?fmt=35
Try with the relative path using *
@ContextConfiguration(locations = {
"classpath*:spring/applicationContext.xml",
"classpath*:spring/applicationContext-jpa.xml",
"classpath*:spring/applicationContext-security.xml" })
If not look if your xml are really on resources/spring/.
Finally try just on without location
@ContextConfiguration({"classpath*:spring/applicationContext.xml"})
The other error that you´re showing is because you have this tag duplicated on applicationContext.xml and applicationContext-security.xml
Duplicate <global-method-security>
In case you also need to check if nextProps.blog
is not undefined
; you can do that in a single if
statement, like this:
if (typeof nextProps.blog !== "undefined" && typeof nextProps.blog.content !== "undefined") {
//
}
And, when an undefined
, empty
or null
value is not expected; you can make it more concise:
if (nextProps.blog && nextProps.blog.content) {
//
}
cursor:pointer
doesn't work when you're using Chrome's mobile emulator.
Os X Mojave 10.14 has:
Error: The Command Line Tools header package must be installed on Mojave.
Solution. Go to
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
location and install the package manually. And brew will start working and we can run:
brew uninstall --force git
brew cleanup --force -s git
brew prune
brew install git
Use command
google-chrome-stable
We can also use command
google-chrome
To open terminal but in my case when I make an interrupt ctrl + c
then it get closed so I would recommend to use google-chrome-stable
instead of google-chrome
I just had to deal with it myself. After all I found this method most easy and useful. Just add
overflow-x: hidden;
To your outer parent. In my case it looks like this:
<body style="overflow-x: hidden;">
You have to use overflow-x
because if you use simply use overflow
you disable the vertical scrolling too, namely overflow-y
If the vertical scrolling is still disabled you can enable it explicitly with:
overflow-y: scroll;
I know its somewhat not a proper way because if everything was setup well one would not have to use this quick and dirty method.
One way would be to just escape the quotes properly:
<input type="button" value="click" id="mybtn"
onclick="myfunction('/myController/myAction',
'myfuncionOnOK(\'/myController2/myAction2\',
\'myParameter2\');',
'myfuncionOnCancel(\'/myController3/myAction3\',
\'myParameter3\');');">
In this case, though, I think a better way to handle this would be to wrap the two handlers in anonymous functions:
<input type="button" value="click" id="mybtn"
onclick="myfunction('/myController/myAction',
function() { myfuncionOnOK('/myController2/myAction2',
'myParameter2'); },
function() { myfuncionOnCancel('/myController3/myAction3',
'myParameter3'); });">
And then, you could call them from within myfunction
like this:
function myfunction(url, onOK, onCancel)
{
// Do whatever myfunction would normally do...
if (okClicked)
{
onOK();
}
if (cancelClicked)
{
onCancel();
}
}
That's probably not what myfunction
would actually look like, but you get the general idea. The point is, if you use anonymous functions, you have a lot more flexibility, and you keep your code a lot cleaner as well.
You can use string utf8_encode( string $data )
function to accomplish what you want. It is for a single string. You can write your own function using which you can convert an array with the help of utf8_encode function.
\b <= this is a word boundary.
Matches at a position that is followed by a word character but not preceded by a word character, or that is preceded by a word character but not followed by a word character.
\w <= stands for "word character".
It always matches the ASCII characters [A-Za-z0-9_]
Is there anything specific you are trying to match?
Some useful regex websites for beginners or just to wet your appetite.
I found this to be a very useful book:
There is no typedef in java as of 1.6, what you can do is make a wrapper class for what you want since you can't subclass final classes (Integer, Double, etc)
You can stop catching the exception, or - if you need to catch it (to do some custom handling), you can re-raise:
try:
doSomeEvilThing()
except Exception, e:
handleException(e)
raise
Note that typing raise
without passing an exception object causes the original traceback to be preserved. Typically it is much better than raise e
.
Of course - you can also explicitly call
import sys
sys.exit(exitCodeYouFindAppropriate)
This causes SystemExit exception to be raised, and (unless you catch it somewhere) terminates your application with specified exit code.
You can trap unhandled exceptions at different levels:
AppDomain.CurrentDomain.UnhandledException
From all threads in the AppDomain.Dispatcher.UnhandledException
From a single specific UI dispatcher thread.Application.Current.DispatcherUnhandledException
From the main UI dispatcher thread in your WPF application.TaskScheduler.UnobservedTaskException
from within each AppDomain that uses a task scheduler for asynchronous operations.You should consider what level you need to trap unhandled exceptions at.
Deciding between #2 and #3 depends upon whether you're using more than one WPF thread. This is quite an exotic situation and if you're unsure whether you are or not, then it's most likely that you're not.
Here is a small improvement trick that allows sort 'val' inside the groups:
# 1. Data set
set.seed(100)
df <- data.frame(
cat = c(rep("aaa", 5), rep("ccc", 5), rep("bbb", 5)),
val = runif(15))
# 2. 'dplyr' approach
df %>%
arrange(cat, val) %>%
group_by(cat) %>%
mutate(id = row_number())
I answered a virtually identical question just the other day: Save CSV files into mysql database
MySQL has a feature LOAD DATA INFILE
, which allows it to import a CSV file directly in a single SQL query, without needing it to be processed in a loop via your PHP program at all.
Simple example:
<?php
$query = <<<eof
LOAD DATA INFILE '$fileName'
INTO TABLE tableName
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(field1,field2,field3,etc)
eof;
$db->query($query);
?>
It's as simple as that.
No loops, no fuss. And much much quicker than parsing it in PHP.
MySQL manual page here: http://dev.mysql.com/doc/refman/5.1/en/load-data.html
Hope that helps
Product -> Archive, later, press the distribute button and check the option Export as Application or what you want
There is also a plot.background
option in addition to panel.background
:
df <- data.frame(y=d,x=1)
p <- ggplot(df) + stat_boxplot(aes(x = x,y=y))
p <- p + opts(
panel.background = theme_rect(fill = "transparent",colour = NA), # or theme_blank()
panel.grid.minor = theme_blank(),
panel.grid.major = theme_blank(),
plot.background = theme_rect(fill = "transparent",colour = NA)
)
#returns white background
png('tr_tst2.png',width=300,height=300,units="px",bg = "transparent")
print(p)
dev.off()
For some reason, the uploaded image is displaying differently than on my computer, so I've omitted it. But for me, I get a plot with an entirely gray background except for the box part of the boxplot which is still white. That can be changed using the fill aesthetic in the boxplot geom as well, I believe.
Edit
ggplot2 has since been updated and the opts()
function has been deprecated. Currently, you would use theme()
instead of opts()
and element_rect()
instead of theme_rect()
, etc.
Here is a really simple, but very effective, example. Once you have the basics down you can easily build off of it.
There are two main parts to using a Cursor Adapter with SQLite:
Create a proper Cursor from the Database.
Create a custom Cursor Adapter that takes the Cursor data from the database and pairs it with the View you intend to represent the data with.
In your Activity:
SQLiteOpenHelper sqLiteOpenHelper = new SQLiteOpenHelper(
context, DATABASE_NAME, null, DATABASE_VERSION);
SQLiteDatabase sqLiteDatabase = sqLiteOpenHelper.getReadableDatabase();
String query = "SELECT * FROM clients ORDER BY company_name ASC"; // No trailing ';'
Cursor cursor = sqLiteDatabase.rawQuery(query, null);
ClientCursorAdapter adapter = new ClientCursorAdapter(
this, R.layout.clients_listview_row, cursor, 0 );
this.setListAdapter(adapter);
Note: Extending from ResourceCursorAdapter
assumes you use XML to create your views.
public class ClientCursorAdapter extends ResourceCursorAdapter {
public ClientCursorAdapter(Context context, int layout, Cursor cursor, int flags) {
super(context, layout, cursor, flags);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView name = (TextView) view.findViewById(R.id.name);
name.setText(cursor.getString(cursor.getColumnIndex("name")));
TextView phone = (TextView) view.findViewById(R.id.phone);
phone.setText(cursor.getString(cursor.getColumnIndex("phone")));
}
}
let a = $("<a>bfCaptchaEntry</a>");
a.attr("onClick", "function(" + someParameter+ ")");
You could set the path to a constant like this and set it using express.
const viewsPath = path.join(__dirname, '../views')
app.set('view engine','hbs')
app.set('views', viewsPath)
app.get('/', function(req, res){
res.render("index");
});
This worked for me
I assume you have different sized images. I tested this myself, and it works as you describe (always centered, images widths appropriately)
/*CSS*/
div.c-wrapper{
width: 80%; /* for example */
margin: auto;
}
.carousel-inner > .item > img,
.carousel-inner > .item > a > img{
width: 100%; /* use this, or not */
margin: auto;
}
<!--html-->
<div class="c-wrapper">
<div id="carousel-example-generic" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/600x400">
<div class="carousel-caption">
hello
</div>
</div>
<div class="item">
<img src="http://placehold.it/500x400">
<div class="carousel-caption">
hello
</div>
</div>
<div class="item">
<img src="http://placehold.it/700x400">
<div class="carousel-caption">
hello
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="icon-next"></span>
</a>
</div>
</div>
This creates a "jump" due to variable heights... to solve that, try something like this: Select the tallest image of a list
Or use media-query to set your own fixed height.
The method boolean shouldOverrideUrlLoading(WebView view, String url)
was deprecated in API 24. If you are supporting new devices you should use boolean shouldOverrideUrlLoading (WebView view, WebResourceRequest request)
.
You can use both by doing something like this:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
newsItem.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
view.loadUrl(request.getUrl().toString());
return true;
}
});
} else {
newsItem.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
}
I recommend the following syntax for readability.
<? if ($condition): ?>
<p>Content</p>
<? elseif ($other_condition): ?>
<p>Other Content</p>
<? else: ?>
<p>Default Content</p>
<? endif; ?>
Note, omitting php
on the open tags does require that short_open_tags
is enabled in your configuration, which is the default. The relevant curly-brace-free conditional syntax is always enabled and can be used regardless of this directive.
Its also possible to use dynamic SQL and execute it with the exec command:
declare @sql nvarchar(200), @count int
set @count = 10
set @sql = N'select top ' + cast(@count as nvarchar(4)) + ' * from table'
exec (@sql)
Java Character class has an isLetterOrDigit method since version 1.0.2
Worth mentioning: you should download the x64 version!
From the main download page (https://www.iis.net/downloads/microsoft/url-rewrite) click "additional downloads" (under the main download button) and download the x64 version (because for some reason - the default download version is x86)
I had the same problem. When I tried the accepted answer (rockyb), I got the message that the package was already installed and assigned to my project. When I checked the references list, it was NOT referenced, however.
The Microsoft.Web.Infrastructure was installed in my solution's packages folder. Instead of using NuGet to add the package, I just used the Add Reference option. On the left side of the pop-up window, I chose Browse, and then pressed the Browse button on the bottom of the window. I navigated to the packages folder under the folder that my solution was in, then drilled down to the ...\mysolution\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40 and clicked on the Microsoft.Web.Infrastructure.dll. After clicking OK, the package showed up in my References list. I used the Web Deploy Package option to deploy my website and everything worked.
After Add this to your web.config file and configure according to your service name and contract name.
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyService.MyService" behaviorConfiguration="metadataBehavior">
<endpoint
address="" <!-- don't put anything here - Cassini will determine address -->
binding="basicHttpBinding"
contract="MyService.IMyService"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
Please add this in your Service.svc
using System.ServiceModel.Description;
Hope it will helps you.
Use like this,
HTML:
<input type="text" disabled="disabled" class="inputDisabled" value="">
<div id="edit">edit</div>
JS:
$('#edit').click(function(){ // click to
$('.inputDisabled').attr('disabled',false); // removing disabled in this class
});
Try to using application/* instead. And use JSON.maybeJson() to check the data structure in the controller.
Of what i've seen of @Patrik's solution and @Zac's addition, the code provided still has a big problem :
If min==3
then it's impossible to type any number starting with 1 or 2 (ex: 15, 23)
If min>=10
then it's impossible to type anything as every number will have to start with 1,2,3...
In my understanding we cannot achieve the min-max limitation of an EditText
's value with simple use of the class InputFilterMinMax
, at least not for the min Value, because when user is typing a positive number, the value goes growing and we can easily perform an on-the-fly test to check if it's reached the limit or went outside the range and block entries that do not comply. Testing the min value is a different story as we cannot be sure if the user has finished typing or not and therefore cannot decide if we should block or not.
It's not exactly what OP requested but for validation purposes i've combined in my solution an InputFilter
to test max values, with an OnFocusChangeListener
to re-test for min value when the EditText
loses the focus assuming the user's finished typing and it's something like this :
package test;
import android.text.InputFilter;
import android.text.Spanned;
public class InputFilterMax implements InputFilter {
private int max;
public InputFilterMax(int max) {
this.max = max;
}
public InputFilterMax(String max) {
this.max = Integer.parseInt(max);
}
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
try {
String replacement = source.subSequence(start, end).toString();
String newVal = dest.toString().substring(0, dstart) + replacement +dest.toString().substring(dend, dest.toString().length());
int input = Integer.parseInt(newVal);
if (input<=max)
return null;
} catch (NumberFormatException nfe) { }
//Maybe notify user that the value is not good
return "";
}
}
And OnFocusChangeListenerMin
package test;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnFocusChangeListener;
public class OnFocusChangeListenerMin implements OnFocusChangeListener {
private int min;
public OnFocusChangeListenerMin(int min) {
this.min = min;
}
public OnFocusChangeListenerMin(String min) {
this.min = Integer.parseInt(min);
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus) {
String val = ((EditText)v).getText().toString();
if(!TextUtils.isEmpty(val)){
if(Integer.valueOf(val)<min){
//Notify user that the value is not good
}
}
}
}
}
Then in Activity set the InputFilterMax
and theOnFocusChangeListenerMin
to EditText
note : You can 2 both min and max in onFocusChangeListener
.
mQteEditText.setOnFocusChangeListener( new OnFocusChangeListenerMin('20');
mQteEditText.setFilters(new InputFilter[]{new InputFilterMax(getActivity(),'50')});
We request that the developer asking for the pull request state that they would like the branch deleted. Most of the time this is the case. There are times when a branch is needed (e.g. copying the changes to another release branch).
My fingers have memorized our process:
git checkout <feature-branch>
git pull
git checkout <release-branch>
git pull
git merge --no-ff <feature-branch>
git push
git tag -a branch-<feature-branch> -m "Merge <feature-branch> into <release-branch>"
git push --tags
git branch -d <feature-branch>
git push origin :<feature-branch>
A branch is for work. A tag marks a place in time. By tagging each branch merge we can resurrect a branch if that is needed. The branch tags have been used several times to review changes.
The easiest process to symbolicate crash logs:
Wait for 5secs. Bang! the application calls in stack trace will be symbolicated! You may still see a lot of symbols though! those are internal library and framework calls.
This is the easiest one, tried and tested!
class MathsOperations:
def __init__ (self, x, y):
self.a = x
self.b = y
def testAddition (self):
return (self.a + self.b)
def testMultiplication (self):
return (self.a * self.b)
then
temp = MathsOperations()
print(temp.testAddition())
did you try this ?
$("#yourdiv").load(url, function(){
your functions goes here !!!
});
I got similar results:
2 * (i * i): 0.458765943 s, n=119860736
2 * i * i: 0.580255126 s, n=119860736
I got the SAME results if both loops were in the same program, or each was in a separate .java file/.class, executed on a separate run.
Finally, here is a javap -c -v <.java>
decompile of each:
3: ldc #3 // String 2 * (i * i):
5: invokevirtual #4 // Method java/io/PrintStream.print:(Ljava/lang/String;)V
8: invokestatic #5 // Method java/lang/System.nanoTime:()J
8: invokestatic #5 // Method java/lang/System.nanoTime:()J
11: lstore_1
12: iconst_0
13: istore_3
14: iconst_0
15: istore 4
17: iload 4
19: ldc #6 // int 1000000000
21: if_icmpge 40
24: iload_3
25: iconst_2
26: iload 4
28: iload 4
30: imul
31: imul
32: iadd
33: istore_3
34: iinc 4, 1
37: goto 17
vs.
3: ldc #3 // String 2 * i * i:
5: invokevirtual #4 // Method java/io/PrintStream.print:(Ljava/lang/String;)V
8: invokestatic #5 // Method java/lang/System.nanoTime:()J
11: lstore_1
12: iconst_0
13: istore_3
14: iconst_0
15: istore 4
17: iload 4
19: ldc #6 // int 1000000000
21: if_icmpge 40
24: iload_3
25: iconst_2
26: iload 4
28: imul
29: iload 4
31: imul
32: iadd
33: istore_3
34: iinc 4, 1
37: goto 17
FYI -
java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
Normally, Visual Studio creates it automatically if you add three single comment-markers above the thing you like to comment (method, class).
In C# this would be ///
.
If Visual Studio doesn't do this, you can enable it in
Options->Text Editor->C#->Advanced
and check
Generate XML documentation comments for ///
There is no way to get the memory address of a value in Python 2.7 in general. In Jython or PyPy, the implementation doesn't even know your value's address (and there's not even a guarantee that it will stay in the same place—e.g., the garbage collector is allowed to move it around if it wants).
However, if you only care about CPython, id
is already returning the address. If the only issue is how to format that integer in a certain way… it's the same as formatting any integer:
>>> hex(33)
0x21
>>> '{:#010x}'.format(33) # 32-bit
0x00000021
>>> '{:#018x}'.format(33) # 64-bit
0x0000000000000021
… and so on.
However, there's almost never a good reason for this. If you actually need the address of an object, it's presumably to pass it to ctypes
or similar, in which case you should use ctypes.addressof
or similar.
1,new Long(intValue);
2,Long.valueOf(intValue);
Many remote consoles work fine. http://farjs.com is my project, and I was able to successfully debug issues specific to Crome iOS and not happening in safari using it. (and probably all other mobile browsers)
The problem is that injecting the debugging code is slightly tricky since Chrome doesn't allow you to install bookmarklets.
Instead you could open one tab on the page that you would debug, and another on farjs.com and then click "the bookmarklet"
Copy the bookmarklet JS code, get back to the first tab, with the page that should be debugged, and paste the bookmarklet code in the location bar.
Last step is to scroll to the beginning of the location bar and add "javascript:", since Chrome will remove it.
For the ones that want to create a calculated column in a table to store the age:
CASE WHEN DateOfBirth< DATEADD(YEAR, (DATEPART(YEAR, GETDATE()) - DATEPART(YEAR, DateOfBirth))*-1, GETDATE())
THEN DATEPART(YEAR, GETDATE()) - DATEPART(YEAR, DateOfBirth)
ELSE DATEPART(YEAR, GETDATE()) - DATEPART(YEAR, DateOfBirth) -1 END
I had a similar issue, but in my case it turned out that I used case insensitive collation - utf8_general_ci
.
Thus, when I tried to insert two strings which were different in a case-sensitive comparison, but the same in the case-insensitive one, MySQL fired the error and I couldn't understand what a problem, because I used a case-sensitive search.
The solution is to change the collation of a table, e.g. I used utf8_bin
which is case-sensitive (or utf8_general_cs
should be appropriate one too).
What about?
If oSheet.QueryTables.Count > 0 Then
oCmbBox.AddItem oSheet.Name
End If
Or
If oSheet.ListObjects.Count > 0 Then
'// Source type 3 = xlSrcQuery
If oSheet.ListObjects(1).SourceType = 3 Then
oCmbBox.AddItem oSheet.Name
End IF
End IF
Most of the solutions are working but why take so efforts while we also can get mime type very easily. In System.Web assembly, there is method for getting the mime type from file name. eg:
string mimeType = MimeMapping.GetMimeMapping(filename);
Can you try this,
echo date("Y-m-d H:i:s", 1388516401);
As noted by theGame,
This means that you pass in a string value for the time, and optionally a value for the current time, which is a UNIX timestamp. The value that is returned is an integer which is a UNIX timestamp.
echo strtotime("2014-01-01 00:00:01");
This will return into the value 1388516401, which is the UNIX timestamp for the date 2014-01-01. This can be confirmed using the date() function as like below:
echo date('Y-m-d', 1198148400); // echos 2014-01-01
In HTML 4, the type attribute is required. In my experience, all browsers will default to text/javascript if it is absent, but that behaviour is not defined anywhere. While you can in theory leave it out and assume it will be interpreted as JavaScript, it's invalid HTML, so why not add it.
In HTML 5, the type attribute is optional and defaults to text/javascript
Use <script type="text/javascript">
or simply <script>
(if omitted, the type is the same). Do not use <script language="JavaScript">
; the language attribute is deprecated
Ref :
http://social.msdn.microsoft.com/Forums/vstudio/en-US/65aaf5f3-09db-4f7e-a32d-d53e9720ad4c/script-languagejavascript-or-script-typetextjavascript-?forum=netfxjscript
and
Difference between <script> tag with type and <script> without type?
Do you need type attribute at all?
I am using HTML5- No
I am not using HTML5 - Yes
When you create an object myObj
as you have, think of it more like a dictionary. In this case, it has two keys, name
, and age
.
You can access these dictionaries in two ways:
myObj[name]
); ormyObj.name
); do note that some properties are reserved, so the first method is preferred.You should be able to access it as a property without any problems. However, to access it as an array, you'll need to treat the key like a string.
myObj["name"]
Otherwise, javascript will assume that name
is a variable, and since you haven't created a variable called name
, it won't be able to access the key you're expecting.
You can use closures to pass parameters:
iframe.document.addEventListener('click', function(event) {clic(this.id);}, false);
However, I recommend that you use a better approach to access your frame (I can only assume that you are using the DOM0 way of accessing frame windows by their name - something that is only kept around for backwards compatibility):
document.getElementById("myFrame").contentDocument.addEventListener(...);
Approach
Console.WriteLine( $" {inputNumber} / {i} = { inputNumber / i} (remainder: {inputNumber % i})" );
Console.Write( "Enter a Positive Number: " );
int inputNumber = Convert.ToInt32( Console.ReadLine() );
int counter = 0;
for ( int i = 1; i <= inputNumber; i++ ) {
if ( inputNumber == 0 || inputNumber == 1 || counter > 2 ) { break; }
if ( inputNumber % i == 0 ) { counter++; }
}
if ( counter == 2 ) {
Console.WriteLine( $"{inputNumber} is a prime number." );
} else if ( inputNumber == 1 || inputNumber == 0 ) {
Console.WriteLine( $"{inputNumber} is neither prime nor composite." );
} else {
Console.WriteLine( $"{inputNumber} is not a prime number. (It is a composite number)" );
}
My reference: https://www.tutorialspoint.com/Chash-Program-to-check-if-a-number-is-prime-or-not
Here is example which can give you some hints to iterate through existing array and add items to new array. I use UnderscoreJS Module to use as my utility file.
You can download from (https://npmjs.org/package/underscore)
$ npm install underscore
Here is small snippet to demonstrate how you can do it.
var _ = require("underscore");
var calendars = [1, "String", {}, 1.1, true],
newArray = [];
_.each(calendars, function (item, index) {
newArray.push(item);
});
console.log(newArray);
See this section on the MediaWiki docs
These are the key parameters.
prop=revisions&rvprop=content&rvsection=0
rvsection = 0 specifies to only return the lead section.
See this example.
To get the HTML, you can use similarly use action=parse http://en.wikipedia.org/w/api.php?action=parse§ion=0&prop=text&page=pizza
Note, that you'll have to strip out any templates or infoboxes.
theBoolean ^= true;
Fewer keystrokes if your variable is longer than four letters
Edit: code tends to return useful results when used as Google search terms. The code above doesn't. For those who need it, it's bitwise XOR as described here.
You need to include the library path (-L/usr/local/lib/)
gcc -o Opentest Opentest.c -L/usr/local/lib/ -lssl -lcrypto
It works for me.
for property, value in vars(theObject).items():
print(property, ":", value)
Be aware that in some rare cases there's a __slots__
property, such classes often have no __dict__
.
Enclose <img>
in <a>
tag.
<a href="http://www.google.com.pk"><img src="smiley.gif"></a>
it will open link on same tab, and if you want to open link on new tab then use target="_blank"
<a href="http://www.google.com.pk" target="_blank"><img src="smiley.gif"></a>
That query is failing and returning false
.
Put this after mysqli_query()
to see what's going on.
if (!$check1_res) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
For more information:
<table>
<tr>
<td align="right" style="height:26px;">Is Calender Required?:</td>
<td align="left">
@Html.RadioButton("rdbCalenderRequested", "True", new { id = "rdbCalenderRequested_1" })@:Yes
@Html.RadioButton("rdbCalenderRequested", "False", new { id = "rdbCalenderRequested_2" }) @:No
</td>
<td align="right" style="height:26px;">Is Special Pooja?:</td>
<td align="left">
@Html.RadioButton("rdbPoojaRequested", "True", new { id = "rdbPoojaRequested_1" })@:Yes
@Html.RadioButton("rdbPoojaRequested", "False", new { id = "rdbPoojaRequested_2" }) @:No
</td>
</tr>
</table>
It depends on your purpose. If you program for the Web, avoid indexOf
, it isn't supported by Internet Explorer 6 (lot of them still used!), or do conditional use:
if (yourArray.indexOf !== undefined) result = yourArray.indexOf(target);
else result = customSlowerSearch(yourArray, target);
indexOf
is probably coded in native code, so it is faster than anything you can do in JavaScript (except binary search/dichotomy if the array is appropriate).
Note: it is a question of taste, but I would do a return false;
at the end of your routine, to return a true Boolean...
I use MacTex, and my editor is TexShop. It probably has to do with what compiler you are using. When I use pdftex, the command:
\includegraphics[height=60mm, width=100mm]{number2.png}
works fine, but when I use "Tex and Ghostscript", I get the same error as you, about not being able to get the size information. Use pdftex.
Incidentally, you can change this in TexShop from the "Typeset" menu.
Hope this helps.
The simple solution would be to use a ItemListener
. When the state changes, you would simply check the currently selected item and set the text accordingly
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class TestComboBox06 {
public static void main(String[] args) {
new TestComboBox06();
}
public TestComboBox06() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
} catch (InstantiationException ex) {
} catch (IllegalAccessException ex) {
} catch (UnsupportedLookAndFeelException ex) {
}
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(new TestPane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
public class TestPane extends JPanel {
private JComboBox cb;
private JTextField field;
public TestPane() {
cb = new JComboBox(new String[]{"Item 1", "Item 2"});
field = new JTextField(12);
add(cb);
add(field);
cb.setSelectedItem(null);
cb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
Object item = cb.getSelectedItem();
if ("Item 1".equals(item)) {
field.setText("20");
} else if ("Item 2".equals(item)) {
field.setText("30");
}
}
});
}
}
}
A better solution would be to create a custom object that represents the value to be displayed and the value associated with it...
Updated
Now I no longer have a 10 month chewing on my ankles, I updated the example to use a ListCellRenderer
which is a more correct approach then been lazy and overriding toString
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class TestComboBox06 {
public static void main(String[] args) {
new TestComboBox06();
}
public TestComboBox06() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
} catch (InstantiationException ex) {
} catch (IllegalAccessException ex) {
} catch (UnsupportedLookAndFeelException ex) {
}
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(new TestPane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
public class TestPane extends JPanel {
private JComboBox cb;
private JTextField field;
public TestPane() {
cb = new JComboBox(new Item[]{
new Item("Item 1", "20"),
new Item("Item 2", "30")});
cb.setRenderer(new ItemCelLRenderer());
field = new JTextField(12);
add(cb);
add(field);
cb.setSelectedItem(null);
cb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
Item item = (Item)cb.getSelectedItem();
field.setText(item.getValue());
}
});
}
}
public class Item {
private String value;
private String text;
public Item(String text, String value) {
this.text = text;
this.value = value;
}
public String getText() {
return text;
}
public String getValue() {
return value;
}
}
public class ItemCelLRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
if (value instanceof Item) {
setText(((Item)value).getText());
}
return this;
}
}
}
Use et.setBackgroundResource(R.color.white);
You may use Oracle pipelined functions
Basically, when you would like a PLSQL (or java or c) routine to be the «source» of data -- instead of a table -- you would use a pipelined function.
Simple Example - Generating Some Random Data
How could you create N unique random numbers depending on the input argument?
create type array
as table of number;
create function gen_numbers(n in number default null)
return array
PIPELINED
as
begin
for i in 1 .. nvl(n,999999999)
loop
pipe row(i);
end loop;
return;
end;
Suppose we needed three rows for something. We can now do that in one of two ways:
select * from TABLE(gen_numbers(3));
COLUMN_VALUE
1
2
3
or
select * from TABLE(gen_numbers)
where rownum <= 3;
COLUMN_VALUE
1
2
3
In selenium python, you need to set desired_capabilities
as:
desired_capabilities = {
"acceptInsecureCerts": True
}
My issue was as simple as having a null reference that didn't show up in the returned message, I had to debug my API to see it.
In bootstrap you can use .text-center
to align center. also add .row
and .col-md-*
to your code.
align=
is deprecated,
Added .col-xs-*
for demo
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="footer">
<div class="container">
<div class="row">
<div class="col-xs-4">
<p>Hello there</p>
</div>
<div class="col-xs-4 text-center">
<a href="#" class="btn btn-warning" onclick="changeLook()">Re</a>
<a href="#" class="btn btn-warning" onclick="changeBack()">Rs</a>
</div>
<div class="col-xs-4 text-right">
<a href="#"><i class="fa fa-facebook-square fa-2x"></i></a>
<a href="#"><i class="fa fa-twitter fa-2x"></i></a>
<a href="#"><i class="fa fa-google-plus fa-2x"></i></a>
</div>
</div>
</div>
</div>
_x000D_
For those who are reading this and want to use the new version of bootstrap (beta version), you can do the above in a simpler way, using Boostrap Flexbox utilities classes
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container footer">
<div class="d-flex justify-content-between">
<div class="p-1">
<p>Hello there</p>
</div>
<div class="p-1">
<a href="#" class="btn btn-warning" onclick="changeLook()">Re</a>
<a href="#" class="btn btn-warning" onclick="changeBack()">Rs</a>
</div>
<div class="p-1">
<a href="#"><i class="fa fa-facebook-square fa-2x"></i></a>
<a href="#"><i class="fa fa-twitter fa-2x"></i></a>
<a href="#"><i class="fa fa-google-plus fa-2x"></i></a>
</div>
</div>
</div>
_x000D_
I am new to Python, but after my brief research I found out that this is typical of sockets being binded. It just so happens that the socket is still being used and you may have to wait to use it. Or, you can just add:
tcpSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
This should make the port available within a shorter time. In my case, it made the port available almost immediately.
your code compiles here fine (even with that line uncommented. had to change it to
num3 = 100000000000000000000;
to start getting the warning.
For current window, you can use this:
var hash = window.location.hash.substr(1);
To get the hash value of the main window, use this:
var hash = window.top.location.hash.substr(1);
If you have a string with an URL/hash, the easiest method is:
var url = 'https://www.stackoverflow.com/questions/123/abc#10076097';
var hash = url.split('#').pop();
If you're using jQuery, use this:
var hash = $(location).attr('hash');
I could find this solution and is working fine:
cd /Applications/Python\ 3.7/
./Install\ Certificates.command
InetAddress.getLocalHost().getHostName() is the best way out of the two as this is the best abstraction at the developer level.
This is how managed to change my data table row background (DataTables 1.10.19)
$('#memberList').DataTable({
"processing": true,
"serverSide": true,
"pageLength":25,
"ajax":{
"dataType": "json",
"type": "POST",
"url": mainUrl+"/getMember",
},
"columns": [
{ "data": "id" },
{ "data": "name" },
{ "data": "email" },
{ "data": "phone" },
{ "data": "country_id" },
{ "data": "created_at" },
{ "data": "action" },
],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
switch(aData['country_id']){
case 1:
$('td', nRow).css('background-color', '#dacfcf')
break;
}
}
});
You can use fnRowCallback
method function to change the background.
check your casing, the name is typically stored in upper case
SELECT * FROM all_source WHERE name = 'DAILY_UPDATE' ORDER BY TYPE, LINE;
no problem doing it with asp.... it's most natural to do so with MVC, but can be done with standard asp as well.
The MVC framework has all sorts of helper classes for JSON, if you can, I'd suggest sussing in some MVC-love, if not, you can probably easily just get the JSON helper classes used by MVC in and use them in the context of asp.net.
edit:
here's an example of how to return JSON data with MVC. This would be in your controller class. This is out of the box functionality with MVC--when you crate a new MVC project this stuff gets auto-created so it's nothing special. The only thing that I"m doing is returning an actionResult that is JSON. The JSON method I'm calling is a method on the Controller class. This is all very basic, default MVC stuff:
public ActionResult GetData()
{
var data = new { Name="kevin", Age=40 };
return Json(data, JsonRequestBehavior.AllowGet);
}
This return data could be called via JQuery as an ajax call thusly:
$.get("/Reader/GetData/", function(data) { someJavacriptMethodOnData(data); });
The syntax to store the command output into a variable is var=$(command)
.
So you can directly do:
result=$(ls -l | grep -c "rahul.*patle")
And the variable $result
will contain the number of matches.
The key is the parameters :
If you provide Parameters [ Height="" , Width="" ] , then it will open in new windows.
If you DON'T provide Parameters , then it will open in new tab.
Tested in Chrome and Firefox
In the following code:
def f(x) -> int:
return int(x)
the -> int
just tells that f()
returns an integer (but it doesn't force the function to return an integer). It is called a return annotation, and can be accessed as f.__annotations__['return']
.
Python also supports parameter annotations:
def f(x: float) -> int:
return int(x)
: float
tells people who read the program (and some third-party libraries/programs, e. g. pylint) that x
should be a float
. It is accessed as f.__annotations__['x']
, and doesn't have any meaning by itself. See the documentation for more information:
https://docs.python.org/3/reference/compound_stmts.html#function-definitions https://www.python.org/dev/peps/pep-3107/
You can simply use %
Modulus operator to check divisibility.
For example: n % 2 == 0
means n is exactly divisible by 2 and n % 2 != 0
means n is not exactly divisible by 2.
The Python idiom for opening a file and reading it line-by-line is:
with open('filename') as f:
for line in f:
do_something(line)
The file will be automatically closed at the end of the above code (the with
construct takes care of that).
Finally, it is worth noting that line
will preserve the trailing newline. This can be easily removed using:
line = line.rstrip()
The reason is because Fibonacci sequence starts with two known entities, 0 and 1. Your code only checks for one of them (being one).
Change your code to
int fib(int x) {
if (x == 0)
return 0;
if (x == 1)
return 1;
return fib(x-1)+fib(x-2);
}
To include both 0 and 1.
As of PowerShell 2, simple:
$recipients = $addresses -split "; "
Note that the right hand side is actually a case-insensitive regular expression, not a simple match. Use csplit
to force case-sensitivity. See about_Split for more details.
Just worth mentioning that while others suggest tempering with files, I was able to resolve this issue by installing a missing plugin (ionic framework)
Hopefully it helps someone.
cordova plugin add cordova-support-google-services --save
Laravel Framework 5.6.26
return more than one array then we use compact('array1', 'array2', 'array3', ...)
to return view.
viewblade
is the frontend (view) blade.
return view('viewblade', compact('view1','view2','view3','view4'));
Websockets and SSE (Server Sent Events) are both capable of pushing data to browsers, however they are not competing technologies.
Websockets connections can both send data to the browser and receive data from the browser. A good example of an application that could use websockets is a chat application.
SSE connections can only push data to the browser. Online stock quotes, or twitters updating timeline or feed are good examples of an application that could benefit from SSE.
In practice since everything that can be done with SSE can also be done with Websockets, Websockets is getting a lot more attention and love, and many more browsers support Websockets than SSE.
However, it can be overkill for some types of application, and the backend could be easier to implement with a protocol such as SSE.
Furthermore SSE can be polyfilled into older browsers that do not support it natively using just JavaScript. Some implementations of SSE polyfills can be found on the Modernizr github page.
Gotchas:
www.example1.com
and another 6 SSE connections to www.example2.com
(thanks Phate).HTML5Rocks has some good information on SSE. From that page:
Server-Sent Events vs. WebSockets
Why would you choose Server-Sent Events over WebSockets? Good question.
One reason SSEs have been kept in the shadow is because later APIs like WebSockets provide a richer protocol to perform bi-directional, full-duplex communication. Having a two-way channel is more attractive for things like games, messaging apps, and for cases where you need near real-time updates in both directions. However, in some scenarios data doesn't need to be sent from the client. You simply need updates from some server action. A few examples would be friends' status updates, stock tickers, news feeds, or other automated data push mechanisms (e.g. updating a client-side Web SQL Database or IndexedDB object store). If you'll need to send data to a server, XMLHttpRequest is always a friend.
SSEs are sent over traditional HTTP. That means they do not require a special protocol or server implementation to get working. WebSockets on the other hand, require full-duplex connections and new Web Socket servers to handle the protocol. In addition, Server-Sent Events have a variety of features that WebSockets lack by design such as automatic reconnection, event IDs, and the ability to send arbitrary events.
Advantages of SSE over Websockets:
Advantages of Websockets over SSE:
Ideal use cases of SSE:
SSE gotchas:
You have most of the code…
CURLOPT_HTTPHEADER
for curl_setopt()
takes an array with each header as an element. You have one element with multiple headers.
You also need to add the Authorization header to your $header
array.
$header = array();
$header[] = 'Content-length: 0';
$header[] = 'Content-type: application/json';
$header[] = 'Authorization: OAuth SomeHugeOAuthaccess_tokenThatIReceivedAsAString';
curl
sends POST requests with the default content type of application/x-www-form-urlencoded
. If you want to send a JSON request, you will have to specify the correct content type header:
$ curl -vX POST http://server/api/v1/places.json -d @testplace.json \
--header "Content-Type: application/json"
But that will only work if the server accepts json input. The .json
at the end of the url may only indicate that the output is json, it doesn't necessarily mean that it also will handle json input. The API documentation should give you a hint on whether it does or not.
The reason you get a 401
and not some other error is probably because the server can't extract the auth_token
from your request.
After trying a lot of things I find a way that works. I share it here if it is useful to anyone. You can see it here working: http://jsbin.com/iquviq/30/edit
.content {
width: 200px;
height: 600px;
background-color: blue;
position: absolute; /*Can also be `fixed`*/
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
/*Solves a problem in which the content is being cut when the div is smaller than its' wrapper:*/
max-width: 100%;
max-height: 100%;
overflow: auto;
}
There needs to be some type of backend framework to send the email. This can be done via PHP/ASP.NET, or with the local mail client. If you want the user to see nothing, the best way is to tap into those by an AJAX call to a separate send_email file.
The correct way of building client/server Microsoft Access applications where the data is stored in a RDBMS is to use the Linked Table method. This ensures Data Isolation and Concurrency is maintained between the Microsoft Access client application and the RDBMS data with no additional and unnecessary programming logic and code which makes maintenance more difficult, and adds to development time.
see: http://claysql.blogspot.com/2014/08/normal-0-false-false-false-en-us-x-none.html
Problem Cause
In mac os image rendering back end of matplotlib (what-is-a-backend to render using the API of Cocoa by default). There are Qt4Agg and GTKAgg and as a back-end is not the default. Set the back end of macosx that is differ compare with other windows or linux os.
Solution
~/.matplotlib
. ~/.matplotlib/matplotlibrc
there and add the following code: backend: TkAgg
From this link you can try different diagrams.
I have tried all the above steps mentioned but nothing worked for me. Finally, restarting the computer worked for this issue :D
New method for an old question
It seems like in the answers provided the issue was always how the box border would either be visible on the left and right of the object or you'd have to inset it so far that it didn't shadow the whole length of the container properly.
This example uses the :after
pseudo element along with a linear gradient with transparency in order to put a drop shadow on a container that extends exactly to the sides of the element you wish to shadow.
Worth noting with this solution is that if you use padding on the element that you wish to drop shadow, it won't display correctly. This is because the after
pseudo element appends it's content directly after the elements inner content. So if you have padding, the shadow will appear inside the box. This can be overcome by eliminating padding on outer container (where the shadow applies) and using an inner container where you apply needed padding.
Example with padding and background color on the shadowed div:
If you want to change the depth of the shadow, simply increase the height
style in the after
pseudo element. You can also obviously darken, lighten, or change colors in the linear gradient styles.
body {_x000D_
background: #eee;_x000D_
}_x000D_
_x000D_
.bottom-shadow {_x000D_
width: 80%;_x000D_
margin: 0 auto;_x000D_
}_x000D_
_x000D_
.bottom-shadow:after {_x000D_
content: "";_x000D_
display: block;_x000D_
height: 8px;_x000D_
background: transparent;_x000D_
background: -moz-linear-gradient(top, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0) 100%); /* FF3.6-15 */_x000D_
background: -webkit-linear-gradient(top, rgba(0,0,0,0.4) 0%,rgba(0,0,0,0) 100%); /* Chrome10-25,Safari5.1-6 */_x000D_
background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%,rgba(0,0,0,0) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */_x000D_
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000',GradientType=0 ); /* IE6-9 */_x000D_
}_x000D_
_x000D_
.bottom-shadow div {_x000D_
padding: 18px;_x000D_
background: #fff;_x000D_
}
_x000D_
<div class="bottom-shadow">_x000D_
<div>_x000D_
Shadows, FTW!_x000D_
</div>_x000D_
</div>
_x000D_
Here's another one-liner approach to throw out there:
next((some_list.pop(i) for i, l in enumerate(some_list) if l == thing), None)
It doesn't create a list copy, doesn't make multiple passes through the list, doesn't require additional exception handling, and returns the matched object or None if there isn't a match. Only issue is that it makes for a long statement.
In general, when looking for a one-liner solution that doesn't throw exceptions, next() is the way to go, since it's one of the few Python functions that supports a default argument.
jQuery will do the job. You can use either jQuery.ajax function, which is general one for performing ajax calls, or its wrappers: jQuery.get, jQuery.post for getting/posting data. Its very easy to use, for example, check out this tutorial, which shows how to use jQuery with PHP.
Use the sign of the determinant of vectors (AB,AM)
, where M(X,Y)
is the query point:
position = sign((Bx - Ax) * (Y - Ay) - (By - Ay) * (X - Ax))
It is 0
on the line, and +1
on one side, -1
on the other side.
Bundles can be used to send arbitrary data from one activity to another by way of Intents. When you broadcast an Intent, interested Activities (and other BroadcastRecievers) will be notified of this. An intent can contain a Bundle so that you can send extra data along with the Intent.
Bundles are key-value mappings, so in a way they are like a Hash, but they are not strictly limited to a single String / Foo object mapping. Note that only certain data types are considered "Parcelable" and they are explicitly spelled out in the Bundle API.
Visual Studio 2015/2017's live debugger is injecting code that contains the deprecated call.
My guess at a "bulletproof way to do this" (think CIA finding Waldo in any satellite image any time, not just a single image without competing elements, like striped shirts)... I would train a Boltzmann machine on many images of Waldo - all variations of him sitting, standing, occluded, etc.; shirt, hat, camera, and all the works. You don't need a large corpus of Waldos (maybe 3-5 will be enough), but the more the better.
This will assign clouds of probabilities to various elements occurring in whatever the correct arrangement, and then establish (via segmentation) what an average object size is, fragment the source image into cells of objects which most resemble individual people (considering possible occlusions and pose changes), but since Waldo pictures usually include a LOT of people at about the same scale, this should be a very easy task, then feed these segments of the pre-trained Boltzmann machine. It will give you probability of each one being Waldo. Take one with the highest probability.
This is how OCR, ZIP code readers, and strokeless handwriting recognition work today. Basically you know the answer is there, you know more or less what it should look like, and everything else may have common elements, but is definitely "not it", so you don't bother with the "not it"s, you just look of the likelihood of "it" among all possible "it"s you've seen before" (in ZIP codes for example, you'd train BM for just 1s, just 2s, just 3s, etc., then feed each digit to each machine, and pick one that has most confidence). This works a lot better than a single neural network learning features of all numbers.
I have the similar problem and fixed it by temporarily disabling my antivirus(Kaspersky Free 18.0.0.405). This AV has HTTPS interception module that automatically self-sign all certificates it finds in HTTPS responses.
Wget from Cygwin does not know anything about AV root certificate, so when it finds that website's certificate was signed with non trust certificate it prints that error.
To fix this permanently without disabling AV you should copy the AV root certificate from Windows certificate store to /etc/pki/ca-trust/source/anchors
as .pem file(base64 encoding) and run update-ca-trust
There are four ways to create a singleton in Java.
Eager initialization singleton
public class Test {
private static final Test test = new Test();
private Test() {
}
public static Test getTest() {
return test;
}
}
Lazy initialization singleton (thread safe)
public class Test {
private static volatile Test test;
private Test() {
}
public static Test getTest() {
if(test == null) {
synchronized(Test.class) {
if(test == null) {
test = new Test();
}
}
}
return test;
}
}
Bill Pugh singleton with holder pattern (preferably the best one)
public class Test {
private Test() {
}
private static class TestHolder {
private static final Test test = new Test();
}
public static Test getInstance() {
return TestHolder.test;
}
}
Enum singleton
public enum MySingleton {
INSTANCE;
private MySingleton() {
System.out.println("Here");
}
}
The answer shared by @mockinterface is correct. Although I would like to add my 2 cents to it.
If someone is using frameworks like scrapy
the you will have to use /html/body//a[contains(@href,'com')][2]/@href
along with get() like this:
response.xpath('//a[contains(@href,'com')][2]/@href').get()
Also you can use DownloadFileAsync
method in WebClient
class. It downloads to a local file the resource with the specified URI
. Also this method does not block the calling thread.
Sample:
webClient.DownloadFileAsync(new Uri("http://www.example.com/file/test.jpg"), "test.jpg");
For more information:
http://csharpexamples.com/download-files-synchronous-asynchronous-url-c/
If you need to re-type this several times, you can do like I did once. Get your columns` names into rows in excel sheet (write down at the end of each column name (=) which is easy in notepad++) on the right side make a column to copy and paste your value that will correspond to the new entries at each column. Then on the right of them in an independent column put the commas as designed
Then you will have to copy your values into the middle column each time then just paste then and run
I do not know an easier solution
Given the update to the original question, it seems like there is trouble with the context ("this") while passing event handlers. The basics are explained e.g. here http://www.w3schools.com/js/js_function_invocation.asp
A simple working version of your example could read
var doClick = function(event, additionalParameter){
// do stuff with event and this being the triggering event and caller
}
element.addEventListener('click', function(event)
{
var additionalParameter = ...;
doClick.call(this, event, additionalParameter );
}, false);
Does the screenshot contain only the icon? If so, the L2 distance of the two images might suffice. If the L2 distance doesn't work, the next step is to try something simple and well established, like: Lucas-Kanade. Which I'm sure is available in OpenCV.
You can't set a favicon from CSS - if you want to do this explicitly you have to do it in the markup as you described.
Most browsers will, however, look for a favicon.ico
file on the root of the web site - so if you access http://example.com most browsers will look for http://example.com/favicon.ico automatically.
As Blexy already answered, go to "Behavior > Site Content > All Pages".
Just pay attention that "Behavior" appears two times in the left sidebar and we need to click on the second option:
I know you have already satisfied with an answer but if you are interested to know the right approach, then this might be helpful for you. I would prefer not to mix http-response error code with the error code in the error object (confused? please continue reading a bit...).
The http response codes are standard error codes about a http response defining generic situations when response is received and varies from 1xx to 5xx ( e.g 200 OK, 408 Request timed out,504 Gateway timeout etc - http://www.restapitutorial.com/httpstatuscodes.html )
The error code in a NSError object provides very specific identification to the kind of error the object describes for a particular domain of application/product/software. For example your application may use 1000 for "Sorry, You can't update this record more than once in a day" or say 1001 for "You need manager role to access this resource"... which are specific to your domain/application logic.
For a very small application, sometimes these two concepts are merged. But they are completely different as you can see and very important & helpful to design and work with large software.
So, there can be two techniques to handle the code in better way:
completionHandler(data, httpResponse, responseError)
if nil == responseError {
successCallback(data)
} else {
failureCallback(data, responseError) // failure can have data also for standard REST request/response APIs
}
Happy coding :)
This helped me at the end:
Quick guide:
Download Google USB Driver
Connect your device with Android Debugging enabled to your PC
Open Device Manager of Windows from System Properties.
Your device should appear under Other devices
listed as something like
Android ADB Interface
or 'Android Phone' or similar. Right-click that and
click on Update Driver Software...
Select Browse my computer for driver software
Select Let me pick from a list of device drivers on my computer
Double-click Show all devices
Press the Have disk
button
Browse and navigate to [wherever your SDK has been installed]\google-usb_driver and select android_winusb.inf
Select Android ADB Interface
from the list of device types.
Press the Yes
button
Press the Install
button
Press the Close
button
Now you've got the ADB driver set up correctly. Reconnect your device if it doesn't recognize it already.
Yes, %d
means decimal, but it means decimal number system, not decimal point.
Further, as a complement to the former post, you can also control the number of decimal points to show. Try this,
System.out.printf("%.2f %.1f",d,f); // prints 1.20 1.2
For more please refer to the API docs.
you can use the css background-image
property and z-index
to ensure the image stays in front of the text.
For those stuck with legacy issues, find the line throwing the error and add {passive: true}
- eg:
this.element.addEventListener(t, e, !1)
becomes
this.element.addEventListener(t, e, { passive: true} )
I don't think it is possible to share a database link between more than one user but not all. They are either private (for one user only) or public (for all users).
A good way around this is to create a view in SCHEMA_B that exposes the table you want to access through the database link. This will also give you good control over who is allowed to select from the database link, as you can control the access to the view.
Do like this:
create database link db_link... as before;
create view mytable_view as select * from mytable@db_link;
grant select on mytable_view to myuser;
Try "android update adb" command. It helps me with samsung galaxy gear.
Thanks Friend, i got an answer. This is only possible because of your help. you all give me a ray of hope towards resolving this problem.
Here is the code:
package facebook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class Facebook {
public static void main(String args[]){
WebDriver driver = new FirefoxDriver();
driver.get("http://www.facebook.com");
WebElement email= driver.findElement(By.id("email"));
Actions builder = new Actions(driver);
Actions seriesOfActions = builder.moveToElement(email).click().sendKeys(email, "[email protected]");
seriesOfActions.perform();
WebElement pass = driver.findElement(By.id("pass"));
WebElement login =driver.findElement(By.id("u_0_b"));
Actions seriesOfAction = builder.moveToElement(pass).click().sendKeys(pass, "naveench").click(login);
seriesOfAction.perform();
driver.
}
}
Exactly what you need:) You can choose callback version or Promise version. Note that promises will work in IE only with Promise polyfill lib.You can put this code once on a page, and this function will appear in all your files.
The loadend event is fired when progress has stopped on the loading of a resource (e.g. after "error", "abort", or "load" have been dispatched)
Callback version
File.prototype.convertToBase64 = function(callback){
var reader = new FileReader();
reader.onloadend = function (e) {
callback(e.target.result, e.target.error);
};
reader.readAsDataURL(this);
};
$("#asd").on('change',function(){
var selectedFile = this.files[0];
selectedFile.convertToBase64(function(base64){
alert(base64);
})
});
Promise version
File.prototype.convertToBase64 = function(){
return new Promise(function(resolve, reject) {
var reader = new FileReader();
reader.onloadend = function (e) {
resolve({
fileName: this.name,
result: e.target.result,
error: e.target.error
});
};
reader.readAsDataURL(this);
}.bind(this));
};
FileList.prototype.convertAllToBase64 = function(regexp){
// empty regexp if not set
regexp = regexp || /.*/;
//making array from FileList
var filesArray = Array.prototype.slice.call(this);
var base64PromisesArray = filesArray.
filter(function(file){
return (regexp).test(file.name)
}).map(function(file){
return file.convertToBase64();
});
return Promise.all(base64PromisesArray);
};
$("#asd").on('change',function(){
//for one file
var selectedFile = this.files[0];
selectedFile.convertToBase64().
then(function(obj){
alert(obj.result);
});
});
//for all files that have file extention png, jpeg, jpg, gif
this.files.convertAllToBase64(/\.(png|jpeg|jpg|gif)$/i).then(function(objArray){
objArray.forEach(function(obj, i){
console.log("result[" + obj.fileName + "][" + i + "] = " + obj.result);
});
});
})
html
<input type="file" id="asd" multiple/>
It's impossible to say without seeing your actual code. Likely the reason is a code path through your function that doesn't execute a return
statement. When the code goes down that path, the function ends with no value returned, and so returns None
.
Updated: It sounds like your code looks like this:
def b(self, p, data):
current = p
if current.data == data:
return True
elif current.data == 1:
return False
else:
self.b(current.next, data)
That else clause is your None
path. You need to return the value that the recursive call returns:
else:
return self.b(current.next, data)
BTW: using recursion for iterative programs like this is not a good idea in Python. Use iteration instead. Also, you have no clear termination condition.
If you called setText
before and the new text didn't get layout phase call setSelection
in a separate runnable fired by View.post(Runnable)
(repost from this topic).
So, for me this code works:
editText.setText("text");
editText.post(new Runnable() {
@Override
public void run() {
editText.setSelection(editText.getText().length());
}
});
Edit 05/16/2019: Right now I'm using Kotlin extension for that:
fun EditText.placeCursorToEnd() {
this.setSelection(this.text.length)
}
and then - editText.placeCursorToEnd().
Instead of
CGContextDrawImage(context, CGRectMake(0, 0, 145, 15), image.CGImage);
Use
[image drawInRect:CGRectMake(0, 0, 145, 15)];
In the middle of your begin/end CGcontext
methods.
This will draw the image with the correct orientation into your current image context - I'm pretty sure this has something to do with the UIImage
holding onto knowledge of the orientation while the CGContextDrawImage
method gets the underlying raw image data with no understanding of orientation.
$("#myNode").parent(x).html();
Where 'x' is the node number, beginning with 0 as the first one, should get the right node you want, if you're trying to get a specific one. If you have child nodes, you should really be putting an ID on the one you want, though, to just zero in on that one. Using that methodology and no 'x' worked fine for me.
I suppose rgba()
would work here. After all, browser support for both box-shadow
and rgba()
is roughly the same.
/* 50% black box shadow */
box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5);
div {_x000D_
width: 200px;_x000D_
height: 50px;_x000D_
line-height: 50px;_x000D_
text-align: center;_x000D_
color: white;_x000D_
background-color: red;_x000D_
margin: 10px;_x000D_
}_x000D_
_x000D_
div.a {_x000D_
box-shadow: 10px 10px 10px #000;_x000D_
}_x000D_
_x000D_
div.b {_x000D_
box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5);_x000D_
}
_x000D_
<div class="a">100% black shadow</div>_x000D_
<div class="b">50% black shadow</div>
_x000D_
angualr uses the lighter version of jquery called as jqlite which means it doesnt have all the features of jQuery. here is a reference in angularjs docs about what you can use from jquery. Angular Element docs
In your case you need to find a div with ID or class name. for class name you can use
var elems =$element.find('div') //returns all the div's in the $elements
angular.forEach(elems,function(v,k)){
if(angular.element(v).hasClass('class-name')){
console.log(angular.element(v));
}}
or you can use much simpler way by query selector
angular.element(document.querySelector('#id'))
angular.element(elem.querySelector('.classname'))
it is not as flexible as jQuery but what
If you are creating modelform from POST values initial can be assigned this way:
form = SomeModelForm(request.POST, initial={"option": "10"})
https://docs.djangoproject.com/en/1.10/topics/forms/modelforms/#providing-initial-values
The checked answer does work but officially in MongooseJS latest, you should use pull.
doc.subdocs.push({ _id: 4815162342 }) // added
doc.subdocs.pull({ _id: 4815162342 }) // removed
https://mongoosejs.com/docs/api.html#mongoosearray_MongooseArray-pull
I was just looking that up too.
See Daniel's answer for the correct answer. Much better.
As far as i understand fr is the object of your FileReadExample class. So it is obvious it will not have any method like fr.readLine() if you dont create one yourself.
secondly, i think a correct constructor of the BufferedReader class will help you do your task.
String str;
BufferedReader buffread = new BufferedReader(new FileReader(new File("file.dat")));
str = buffread.readLine();
.
.
buffread.close();
this should help you.
According to the docs (http://ca3.php.net/language.oop5.cloning):
$a = clone $b;
To exec into a running container named test
, below is the following commands
If the container has bash
shell
docker exec -it test /bin/bash
If the container has bourne
shell and most of the cases it's present
docker run -it test /bin/sh
One option in Objective-C:
- (NSArray *)lettersForNumber:(NSNumber *)number {
switch ([number intValue]) {
case 2:
return @[@"A",@"B",@"C"];
case 3:
return @[@"D",@"E",@"F"];
case 4:
return @[@"G",@"H",@"I"];
case 5:
return @[@"J",@"K",@"L"];
case 6:
return @[@"M",@"N",@"O"];
case 7:
return @[@"P",@"Q",@"R",@"S"];
case 8:
return @[@"T",@"U",@"V"];
case 9:
return @[@"W",@"X",@"Y",@"Z"];
default:
return nil;
}
}
- (NSArray *)letterCombinationsForNumbers:(NSArray *)numbers {
NSMutableArray *combinations = [[NSMutableArray alloc] initWithObjects:@"", nil];
for (NSNumber *number in numbers) {
NSArray *lettersNumber = [self lettersForNumber:number];
//Ignore numbers that don't have associated letters
if (lettersNumber.count == 0) {
continue;
}
NSMutableArray *currentCombinations = [combinations mutableCopy];
combinations = [[NSMutableArray alloc] init];
for (NSString *letter in lettersNumber) {
for (NSString *letterInResult in currentCombinations) {
NSString *newString = [NSString stringWithFormat:@"%@%@", letterInResult, letter];
[combinations addObject:newString];
}
}
}
return combinations;
}
Since Java 8, we could use streams instead of for loops. Also, it might be apropriate to return an Optional if the enum does not have an instance with such a name.
I have come up with the following three alternatives on how to look up an enum:
private enum Test {
TEST1, TEST2;
public Test fromNameOrThrowException(String name) {
return Arrays.stream(values())
.filter(e -> e.name().equals(name))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("No enum with name " + name));
}
public Test fromNameOrNull(String name) {
return Arrays.stream(values()).filter(e -> e.name().equals(name)).findFirst().orElse(null);
}
public Optional<Test> fromName(String name) {
return Arrays.stream(values()).filter(e -> e.name().equals(name)).findFirst();
}
}
That should be possible using Socket.IO-client: https://github.com/LearnBoost/socket.io-client
You could also use:
var latLon = L.latLng(40.737, -73.923);
var bounds = latLon.toBounds(500); // 500 = metres
map.panTo(latLon).fitBounds(bounds);
This will set the view level to fit the bounds in the map leaflet.
I had this problem on my developent environment with Visual Studio.
What helped me was to Clean Solution
in Visual Studio and then do a rebuild.
use appcmd to export one or all the sites out then reimport into the new server. It could be iis7.0 or 7.5 When you export out using appcmd, the passwords are decrypted, then reimport and they will reencrypt.
I was also looking for this a while back. I ran into HTMLDOC http://www.easysw.com/htmldoc/ which is a free open source command line app that takes an HTML file as an argument and spits out a PDF from it. It's worked for me pretty well for my side project, but it all depends on what you actually need.
The company that makes it sells the compiled binaries, but you are free to download and compile from source and use it for free. I managed to compile a pretty recent revision (for version 1.9) and I intend on releasing a binary installer for it in a few days, so if you're interested I can provide a link to it as soon as I post it.
Edit (2/25/2014): Seems like the docs and site moved to http://www.msweet.org/projects.php?Z1
width: 100%;
overflow: hidden;
I believe that should do the trick.
You may be interested in the csv
module, which is designed for comma-separated files but can be easily modified to use a custom delimiter.
import csv
csv.register_dialect( "myDialect", delimiter = "__", <other-options> )
lines = [ "MATCHES__STRING" ]
for row in csv.reader( lines ):
...
All offer a key->value map and a way to iterate through the keys. The most important distinction between these classes are the time guarantees and the ordering of the keys.
Imagine you passed an empty TreeMap, HashMap, and LinkedHashMap into the following function:
void insertAndPrint(AbstractMap<Integer, String> map) {
int[] array= {1, -1, 0};
for (int x : array) {
map.put(x, Integer.toString(x));
}
for (int k: map.keySet()) {
System.out.print(k + ", ");
}
}
The output for each will look like the results below.
For HashMap, the output was, in my own tests, { 0, 1, -1}, but it could be any ordering. There is no guarantee on the
ordering.
Treemap,the output was,{ -1, 0, 1}
LinkedList,the output was,{ 1, -1, 0}
This is crazily stupid, but if you use the code:
fprintf("%x", variable)
and you use the -Wall flag while compiling, then gcc will kick out a warning of that it expects an argument of 'unsigned int' while the argument is of type '____'. (If this warning doesn't appear, then your variable is of type 'unsigned int'.)
Best of luck!
Edit: As was brought up below, this only applies to compile time. Very helpful when trying to figure out why your pointers aren't behaving, but not very useful if needed during run time.
Here is one command that displays the number of threads of a given process :
ps -L -o pid= -p <pid> | wc -l
Unlike the other ps
based answers, there is here no need to substract 1
from its output as there is no ps
header line thanks to the -o pid=
option.
write following statement in your app's build.gradle file.
com.android.support:appcompat-v7:18.0.+
That's it
The other methods here didn't work for me, so here's what does work in Ubuntu 12.04 'precise'.
On Ubuntu and other Debian-derived platforms, dpkg is the typical way to get software package versions. For more recent versions than the one that @Tio refers to, use
dpkg -l | grep libopencv
If you have the development packages installed, like libopencv-core-dev
, you'll probably have .pc
files and can use pkg-config
:
pkg-config --modversion opencv
I'd wrap the dictionary in another class:
public class MyListDictionary
{
private Dictionary<string, List<string>> internalDictionary = new Dictionary<string,List<string>>();
public void Add(string key, string value)
{
if (this.internalDictionary.ContainsKey(key))
{
List<string> list = this.internalDictionary[key];
if (list.Contains(value) == false)
{
list.Add(value);
}
}
else
{
List<string> list = new List<string>();
list.Add(value);
this.internalDictionary.Add(key, list);
}
}
}
For System.Timers.Timer:
See Brian Gideon's answer below
MSDN Documentation on Timers states:
The System.Threading.Timer class makes callbacks on a ThreadPool thread and does not use the event model at all.
So indeed the timer elapses on a different thread.
You need to use the border property as seen here: jsFiddle
HTML:
<table width="770">
<tr>
<td class="border-left-bottom">picture (border only to the left and bottom ) </td>
<td>text</td>
</tr>
<tr>
<td>text</td>
<td class="border-left-bottom">picture (border only to the left and bottom) </td>
</tr>
</table>`
CSS:
td.border-left-bottom{
border-left: solid 1px #000;
border-bottom: solid 1px #000;
}
I use a dot(.) to concate string and variable. like this-
echo "Hello ".$var;
Sometimes, I use curly braces to concate string and variable that looks like this-
echo "Hello {$var}";