For python flask server, you can use the flask-cors plugin to enable cross domain requests.
I got the same error and for the issue was that I was on VPN and I didn't realize that. After disconnecting the VPN and reconnecting the wifi resolved it.
With respect to binning functions, I didn't expect the result of the functions offered so far. Namely, if my binwidth is 0.001, these functions were centering the bins on 0.0005 points, whereas I feel it's more intuitive to have the bins centered on 0.001 boundaries.
In other words, I'd like to have
Bin 0.001 contain data from 0.0005 to 0.0014
Bin 0.002 contain data from 0.0015 to 0.0024
...
The binning function I came up with is
my_bin(x,width) = width*(floor(x/width+0.5))
Here's a script to compare some of the offered bin functions to this one:
rint(x) = (x-int(x)>0.9999)?int(x)+1:int(x)
bin(x,width) = width*rint(x/width) + width/2.0
binc(x,width) = width*(int(x/width)+0.5)
mitar_bin(x,width) = width*floor(x/width) + width/2.0
my_bin(x,width) = width*(floor(x/width+0.5))
binwidth = 0.001
data_list = "-0.1386 -0.1383 -0.1375 -0.0015 -0.0005 0.0005 0.0015 0.1375 0.1383 0.1386"
my_line = sprintf("%7s %7s %7s %7s %7s","data","bin()","binc()","mitar()","my_bin()")
print my_line
do for [i in data_list] {
iN = i + 0
my_line = sprintf("%+.4f %+.4f %+.4f %+.4f %+.4f",iN,bin(iN,binwidth),binc(iN,binwidth),mitar_bin(iN,binwidth),my_bin(iN,binwidth))
print my_line
}
and here's the output
data bin() binc() mitar() my_bin()
-0.1386 -0.1375 -0.1375 -0.1385 -0.1390
-0.1383 -0.1375 -0.1375 -0.1385 -0.1380
-0.1375 -0.1365 -0.1365 -0.1375 -0.1380
-0.0015 -0.0005 -0.0005 -0.0015 -0.0010
-0.0005 +0.0005 +0.0005 -0.0005 +0.0000
+0.0005 +0.0005 +0.0005 +0.0005 +0.0010
+0.0015 +0.0015 +0.0015 +0.0015 +0.0020
+0.1375 +0.1375 +0.1375 +0.1375 +0.1380
+0.1383 +0.1385 +0.1385 +0.1385 +0.1380
+0.1386 +0.1385 +0.1385 +0.1385 +0.1390
Try this:
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class currentTime {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
System.out.println( sdf.format(cal.getTime()) );
}
}
You can format SimpleDateFormat in the way you like. For any additional information you can look in java api:
On mac, press Command + R
or got to Database
-> Reverse Engineer
and keep selecting your requirements and continue
The draft CSS Selectors Level 4 proposes to add an of <other-selector>
grammar within the :nth-child
selector. This would allow you to pick out the nth child matching a given other selector:
:nth-child(1 of p.myclass)
Previous drafts used a new pseudo-class, :nth-match()
, so you may see that syntax in some discussions of the feature:
:nth-match(1 of p.myclass)
This has now been implemented in WebKit, and is thus available in Safari, but that appears to be the only browser that supports it. There are tickets filed for implementing it Blink (Chrome), Gecko (Firefox), and a request to implement it in Edge, but no apparent progress on any of these.
Call myTextInputLayout.setError()
instead of myEditText.setError()
.
These container and containment have double functionality on setting errors. Functionality you need is container's one. But you could require minimal version of 23 for that.
I'll talk about the HashMap and TreeMap implementation in Java:
HashMap -- implement basic map interface
Map m = Collections.synchronizedMap(new HashMap(...));
TreeMap -- implement navigable map interface
SortedMap m = Collections.synchronizedSortedMap(new TreeMap(...));
To sum, the biggest difference between HashMap and TreeMap is that TreeMap implements NavigableMap<K,V>
, which provide the feature of ordered iteration. Besides, both HashMap and TreeMap are members of Java Collection framework. You can investigate the source code of Java to know more about their implementations.
This should work:
$("#table-filters>ul>li.active").removeClass("active");
//Find all `li`s with class `active`, children of `ul`s, children of `table-filters`
Once you have a paid account on GitHub, it is not obvious how to create a private repository. To create a private repository for an organization with paid account, go to https://github.com/organizations/MYORGANIZATIONNAME.
The only way I've figured how to navigate there is:
Edited:
I think you are trying to do as done in this DEMO
There are three states of a button: normal, hover and active
You need to use CSS Image Sprites for the button states.
See The Mystery of CSS Sprites
/*CSS*/_x000D_
_x000D_
.imgClass { _x000D_
background-image: url(http://inspectelement.com/wp-content/themes/inspectelementv2/style/images/button.png);_x000D_
background-position: 0px 0px;_x000D_
background-repeat: no-repeat;_x000D_
width: 186px;_x000D_
height: 53px;_x000D_
border: 0px;_x000D_
background-color: none;_x000D_
cursor: pointer;_x000D_
outline: 0;_x000D_
}_x000D_
.imgClass:hover{ _x000D_
background-position: 0px -52px;_x000D_
}_x000D_
_x000D_
.imgClass:active{_x000D_
background-position: 0px -104px;_x000D_
}
_x000D_
<!-- HTML -->_x000D_
<input type="submit" value="" class="imgClass" />
_x000D_
In drawable I use this xml code to define the border and background:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="4dp" android:color="#D8FDFB" />
<padding android:left="7dp" android:top="7dp"
android:right="7dp" android:bottom="7dp" />
<corners android:radius="4dp" />
<solid android:color="#f0600000"/>
</shape>
Since you're not passing in POST data, I'll assume that what you are trying to do is set an initial value that will be displayed in the form. The way you do this is with the initial
keyword.
form = CustomForm(initial={'Email': GetEmailString()})
See the Django Form docs for more explanation.
If you are trying to change a value after the form was submitted, you can use something like:
if form.is_valid():
form.cleaned_data['Email'] = GetEmailString()
Check the referenced docs above for more on using cleaned_data
A map will not keep insertion order. Use *(myMap.begin())
to get the value of the first pair (the one with the smallest key when ordered).
You could also do myMap.begin()->first
to get the key and myMap.begin()->second
to get the value.
Also, see the Stack Overflow question How to detect what .NET Framework versions and service packs are installed? which also mentions:
There is an official Microsoft answer to this question at the knowledge base article [How to determine which versions and service pack levels of the Microsoft .NET Framework are installed][2]
Article ID: 318785 - Last Review: November 7, 2008 - Revision: 20.1 How to determine which versions of the .NET Framework are installed and whether service packs have been applied.
Unfortunately, it doesn't appear to work, because the mscorlib.dll
version in the 2.0 directory has a 2.0 version, and there is no mscorlib.dll
version in either the 3.0 or 3.5 directories even though 3.5 SP1 is installed ... Why would the official Microsoft answer be so misinformed?
Go to your python package directory and remove your .egg file, e.g.: In python 2.5(ubuntu): /usr/lib/python2.5/site-packages/
In python 2.6(ubuntu): /usr/local/lib/python2.6/dist-packages/
You can print Unicode objects as well, you don't need to do str() around it.
Assuming you really want a str:
When you do str(u'\u2013') you are trying to convert the Unicode string to a 8-bit string. To do this you need to use an encoding, a mapping between Unicode data to 8-bit data. What str() does is that is uses the system default encoding, which under Python 2 is ASCII. ASCII contains only the 127 first code points of Unicode, that is \u0000 to \u007F1. The result is that you get the above error, the ASCII codec just doesn't know what \u2013 is (it's a long dash, btw).
You therefore need to specify which encoding you want to use. Common ones are ISO-8859-1, most commonly known as Latin-1, which contains the 256 first code points; UTF-8, which can encode all code-points by using variable length encoding, CP1252 that is common on Windows, and various Chinese and Japanese encodings.
You use them like this:
u'\u2013'.encode('utf8')
The result is a str containing a sequence of bytes that is the uTF8 representation of the character in question:
'\xe2\x80\x93'
And you can print it:
>>> print '\xe2\x80\x93'
–
An example of where the console will return ReferenceError is putting a function inside a JQuery document ready function
//this will fail
$(document).ready(function () {
myFunction(alert('doing something!'));
//other stuff
}
To succeed move the function outside the document ready function
//this will work
myFunction(alert('doing something!'));
$(document).ready(function () {
//other stuff
}
Then in the console window, type the function name with the '()' to execute the function
myFunction()
Also of use is being able to print out the function body to remind yourself what the function does. Do this by leaving off the '()' from the function name
function myFunction(alert('doing something!'))
Of course if you need the function to be registered after the document is loaded then you couldn't do this. But you might be able to work around that.
I'm guessing that either the class name is wrong - be sure to use the fully-resolved class name, with all packages - or it's not in the CLASSPATH so javap can't find it.
I tried the chosen answer, but found when I ran a shell script having it, the whole thing was getting printed to screen (similar to how jupyter notebooks print out everything in '''xx'''
quotes) and there was an error message at end. It wasn't doing anything, but: scary. Then I realised while editing it that single-quotes can span multiple lines. So.. lets just assign the block to a variable.
x='
echo "these lines will all become comments."
echo "just make sure you don_t use single-quotes!"
ls -l
date
'
$_GET['start_date']
is not numeric is my bet, but an date format not supported by strtotime
. You will need to re-format the date to a workable format for strtotime or use combination of explode/mktime.
I could add you an example if you'd be kind enough to post the format you currently receive.
This is ugly MSSQL:
CASE WHEN LTRIM(RTRIM(ISNULL([Address1], ''))) <> '' THEN [Address2] ELSE '' END
Along with top ranked answer you may use a bit simpliest approach. Apache commons FieldUtils
class already has particular method that can do the stuff. Please, take a look at FieldUtils.removeFinalModifier
method. You should specify target field instance and accessibility forcing flag (if you play with non-public fields). More info you can find here.
TEXT
is used for large pieces of string data. If the length of the field exceeed a certain threshold, the text is stored out of row.
VARCHAR
is always stored in row and has a limit of 8000 characters. If you try to create a VARCHAR(x)
, where x > 8000, you get an error:
Server: Msg 131, Level 15, State 3, Line 1
The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000)
These length limitations do not concern VARCHAR(MAX)
in SQL Server 2005, which may be stored out of row, just like TEXT
.
Note that MAX
is not a kind of constant here, VARCHAR
and VARCHAR(MAX)
are very different types, the latter being very close to TEXT
.
In prior versions of SQL Server you could not access the TEXT
directly, you only could get a TEXTPTR
and use it in READTEXT
and WRITETEXT
functions.
In SQL Server 2005 you can directly access TEXT
columns (though you still need an explicit cast to VARCHAR
to assign a value for them).
TEXT
is good:
VARCHAR
is good:
By selecting here I mean issuing any queries that return the value of the column.
By searching here I mean issuing any queries whose result depends on the value of the TEXT
or VARCHAR
column. This includes using it in any JOIN
or WHERE
condition.
As the TEXT
is stored out of row, the queries not involving the TEXT
column are usually faster.
Some examples of what TEXT
is good for:
Some examples of what VARCHAR
is good for:
As a rule of thumb, if you ever need you text value to exceed 200 characters AND do not use join on this column, use TEXT
.
Otherwise use VARCHAR
.
P.S. The same applies to UNICODE
enabled NTEXT
and NVARCHAR
as well, which you should use for examples above.
P.P.S. The same applies to VARCHAR(MAX)
and NVARCHAR(MAX)
that SQL Server 2005+ uses instead of TEXT
and NTEXT
. You'll need to enable large value types out of row
for them with sp_tableoption
if you want them to be always stored out of row.
As mentioned above and here, TEXT
is going to be deprecated in future releases:
The
text in row
option will be removed in a future version of SQL Server. Avoid using this option in new development work, and plan to modify applications that currently usetext in row
. We recommend that you store large data by using thevarchar(max)
,nvarchar(max)
, orvarbinary(max)
data types. To control in-row and out-of-row behavior of these data types, use thelarge value types out of row
option.
Simple, [yourobject class] it will return the class name of yourobject.
Copy your XML schema here & get the JSON schema code to the online tools which are available to generate JSON schema from XML schema.
Using the accepted answer and knowing that Object.values() is proposed in ECMAScript 2017 Draft you can extend Object with method:
if(Object.values == null) {
Object.values = function(obj) {
var arr, o;
arr = new Array();
for(o in obj) { arr.push(obj[o]); }
return arr;
}
}
You could approach this method.
Instead of using th:field
use html id
& name
. Set value using th:value
<input class="form-control"
type="text"
th:value="${client.name}" id="clientName" name="clientName" />
Hope this will help you
It looks like get-pip.py
has been updated to use the environment variables http_proxy
and https_proxy
.
Windows:
set http_proxy=http://proxy.myproxy.com
set https_proxy=https://proxy.myproxy.com
python get-pip.py
Linux/OS X:
export http_proxy=http://proxy.myproxy.com
export https_proxy=https://proxy.myproxy.com
sudo -E python get-pip.py
However if this still doesn't work for you, you can always install pip through a proxy using setuptools' easy_install
by setting the same environment variables.
Windows:
set http_proxy=http://proxy.myproxy.com
set https_proxy=https://proxy.myproxy.com
easy_install pip
Linux/OS X:
export http_proxy=http://proxy.myproxy.com
export https_proxy=https://proxy.myproxy.com
sudo -E easy_install pip
Then once it's installed, use:
pip install --proxy="user:password@server:port" packagename
From the pip man page:
--proxy
Have pip use a proxy server to access sites. This can be specified using "user:[email protected]:port" notation. If the password is left out, pip will ask for it.
You can use html5 tag to download the image directly
<?php
$file = "Bang.png"; //Let say If I put the file name Bang.png
echo "<a href='download.php?nama=".$file."' download>donload</a> ";
?>
For more information, check this link http://www.w3schools.com/tags/att_a_download.asp
what about creating a stub node (document.createElement('div') - or using your library equivalent), filling it with the xml string (via innerHTML) and calling simple recursive function for the root element/or the stub element in case you don't have a root. The function would call itself for all the child nodes.
You could then syntax-highlight along the way, be certain the markup is well-formed (done automatically by browser when appending via innerHTML) etc. It wouldn't be that much code and probably fast enough.
Also you can try to formulate your answer in the form of a SELECT CASE
Statement. You can then later create simple if then's that use your results if needed as you have narrowed down the possibilities.
SELECT @Result =
CASE @inputParam
WHEN 1 THEN 1
WHEN 2 THEN 2
WHEN 3 THEN 1
ELSE 4
END
IF @Result = 1
BEGIN
...
END
IF @Result = 2
BEGIN
....
END
IF @Result = 4
BEGIN
//Error handling code
END
I just changed the encryption from "Use explicit FTP over TLS if available" to "Only use plain FTP" (insecure) at site manager and it works!
Dictionary<string, string> source
//
//functional programming - do not modify state - only create new state
Dictionary<string, string> result = source
.Where(kvp => string.Compare(kvp.Value, "two", true) != 0)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
//
// or you could modify state
List<string> keys = source
.Where(kvp => string.Compare(kvp.Value, "two", true) == 0)
.Select(kvp => kvp.Key)
.ToList();
foreach(string theKey in keys)
{
source.Remove(theKey);
}
You are mixing pointers and arrays. If what you want is an array, then use an array:
struct test {
static int data[10]; // array, not pointer!
};
int test::data[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
If on the other hand you want a pointer, the simplest solution is to write a helper function in the translation unit that defines the member:
struct test {
static int *data;
};
// cpp
static int* generate_data() { // static here is "internal linkage"
int * p = new int[10];
for ( int i = 0; i < 10; ++i ) p[i] = 10*i;
return p;
}
int *test::data = generate_data();
You can try with this code - based on Rows.Add method
DataTable table = new DataTable();
DataRow row = table.NewRow();
table.Rows.Add(row);
Link : https://msdn.microsoft.com/en-us/library/9yfsd47w.aspx
You're looking for Path.GetFileName
.
Note that this won't work if the path ends in a \
.
As already mentioned you can use Fine Code Coverage that visualize coverlet output. If you create a xunit test project
(dotnet new xunit
) you'll find coverlet reference already present in csproj
file because Coverlet
is the default coverage tool for every .NET Core and >= .NET 5 applications.
Microsoft has an example using ReportGenerator that converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
Example report:
While the article focuses on C# and xUnit as the test framework, both MSTest and NUnit would also work.
Guide:
If you want code coverage in .xml files you can run any of these commands:
dotnet test --collect:"XPlat Code Coverage"
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
I do not feel there is anything wrong with using JQuery with angular and bootstrap, since it is included when adding bootstrap.
import {.......
declare var $: any;
@component.....
<div id="errorModal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" ..............
showErrorModal() {
$("#errorModal").modal('show');
}
In case if you are using checkstyle from qulice
mvn plugin (https://github.com/teamed/qulice) you may use the following suppresion:
// @checkstyle <Rulename> (N lines)
... code with violation(s)
or
/**
* ...
* @checkstyle <Rulename> (N lines)
* ...
*/
... code with violation(s)
As a proof of concept, I did the following function. It takes a list of classes and composes them into a new class (the last prototype wins so there are no conflicts). When creating a composed function, the user can choose to use all original constructors [sic!] or pass their own. This was the biggest challenge of this experiment: to come up with a description of what constructor should do. Copying methods into a prototype is not an issue but what's the intended logic of newly composed object. Or maybe it should be constructorless? In Python, from what I know, it finds the matching constructor but functions in JS are more accepting, hence one can pass to a function just about everything and from signature it won't be clear.
I don't think it's optimised but the purpose was exploring possibilities. instanceof
will not behave as expected which, I guess, is a bummer, since class-oriented developers like to use this as a tool.
Maybe JavaScript just doesn't have it.
/*_x000D_
(c) Jon Krazov 2019_x000D_
_x000D_
Below is an experiment searching boundaries of JavaScript._x000D_
It allows to compute one class out of many classes._x000D_
_x000D_
Usage 1: Without own constructor_x000D_
_x000D_
If no constructor is passed then constructor of each class will be called_x000D_
with params passed in object. In case of missing params, constructor_x000D_
will be called without params._x000D_
_x000D_
Example:_x000D_
_x000D_
const MyClass1 = computeClass([Class1, Class2, Class3]);_x000D_
const myClass1Instance = new MyClass1({_x000D_
'Class1': [1, 2],_x000D_
'Class2': ['test'],_x000D_
'Class3': [(value) => value],_x000D_
});_x000D_
_x000D_
Usage 2: With own constructor_x000D_
_x000D_
If constructor is passed in options object (second param) then it will_x000D_
be called in place of constructors of all classes._x000D_
_x000D_
Example:_x000D_
_x000D_
const MyClass2 = computeClass([Class1, Class2, Class3], {_x000D_
ownConstructor(param1) {_x000D_
this.name = param1;_x000D_
}_x000D_
});_x000D_
const myClass2Instance = new MyClass2('Geoffrey');_x000D_
*/_x000D_
_x000D_
// actual function_x000D_
_x000D_
var computeClass = (classes = [], { ownConstructor = null } = {}) => {_x000D_
const noConstructor = (value) => value != 'constructor';_x000D_
_x000D_
const ComputedClass = ownConstructor === null_x000D_
? class ComputedClass {_x000D_
constructor(args) {_x000D_
classes.forEach((Current) => {_x000D_
const params = args[Current.name];_x000D_
_x000D_
if (params) {_x000D_
Object.assign(this, new Current(...params));_x000D_
} else {_x000D_
Object.assign(this, new Current());_x000D_
}_x000D_
})_x000D_
}_x000D_
}_x000D_
: class ComputedClass {_x000D_
constructor(...args) {_x000D_
if (typeof ownConstructor != 'function') {_x000D_
throw Error('ownConstructor has to be a function!');_x000D_
}_x000D_
ownConstructor.call(this, ...args);_x000D_
} _x000D_
};_x000D_
_x000D_
const prototype = classes.reduce(_x000D_
(composedPrototype, currentClass) => {_x000D_
const partialPrototype = Object.getOwnPropertyNames(currentClass.prototype)_x000D_
.reduce(_x000D_
(result, propName) =>_x000D_
noConstructor(propName)_x000D_
? Object.assign(_x000D_
result,_x000D_
{ [propName]: currentClass.prototype[propName] }_x000D_
)_x000D_
: result,_x000D_
{}_x000D_
);_x000D_
_x000D_
return Object.assign(composedPrototype, partialPrototype);_x000D_
},_x000D_
{}_x000D_
);_x000D_
_x000D_
Object.entries(prototype).forEach(([prop, value]) => {_x000D_
Object.defineProperty(ComputedClass.prototype, prop, { value });_x000D_
});_x000D_
_x000D_
return ComputedClass;_x000D_
}_x000D_
_x000D_
// demo part_x000D_
_x000D_
var A = class A {_x000D_
constructor(a) {_x000D_
this.a = a;_x000D_
}_x000D_
sayA() { console.log('I am saying A'); }_x000D_
}_x000D_
_x000D_
var B = class B {_x000D_
constructor(b) {_x000D_
this.b = b;_x000D_
}_x000D_
sayB() { console.log('I am saying B'); }_x000D_
}_x000D_
_x000D_
console.log('class A', A);_x000D_
console.log('class B', B);_x000D_
_x000D_
var C = computeClass([A, B]);_x000D_
_x000D_
console.log('Composed class');_x000D_
console.log('var C = computeClass([A, B]);', C);_x000D_
console.log('C.prototype', C.prototype);_x000D_
_x000D_
var c = new C({ A: [2], B: [32] });_x000D_
_x000D_
console.log('var c = new C({ A: [2], B: [32] })', c);_x000D_
console.log('c instanceof A', c instanceof A);_x000D_
console.log('c instanceof B', c instanceof B);_x000D_
_x000D_
console.log('Now c will say:')_x000D_
c.sayA();_x000D_
c.sayB();_x000D_
_x000D_
console.log('---');_x000D_
_x000D_
var D = computeClass([A, B], {_x000D_
ownConstructor(c) {_x000D_
this.c = c;_x000D_
}_x000D_
});_x000D_
_x000D_
console.log(`var D = computeClass([A, B], {_x000D_
ownConstructor(c) {_x000D_
this.c = c;_x000D_
}_x000D_
});`);_x000D_
_x000D_
var d = new D(42);_x000D_
_x000D_
console.log('var d = new D(42)', d);_x000D_
_x000D_
console.log('Now d will say:')_x000D_
d.sayA();_x000D_
d.sayB();_x000D_
_x000D_
console.log('---');_x000D_
_x000D_
var E = computeClass();_x000D_
_x000D_
console.log('var E = computeClass();', E);_x000D_
_x000D_
var e = new E();_x000D_
_x000D_
console.log('var e = new E()', e);
_x000D_
Originally posted here (gist.github.com).
A native debugger is being made available as an extension to JupyterLab. Released a few weeks ago, this can be installed by getting the relevant extension, as well as xeus-python kernel (which notably comes without the magics well-known to ipykernel users):
jupyter labextension install @jupyterlab/debugger
conda install xeus-python -c conda-forge
This enables a visual debugging experience well-known from other IDEs.
Source: A visual debugger for Jupyter
I ran across this while researching the proper loop to use for a situation I have. I believe this will fully satisfy a common situation where a do.. while loop is a better implementation than a while loop (C# language, since you stated that is your primary for work).
I am generating a list of strings based on the results of an SQL query. The returned object by my query is an SQLDataReader. This object has a function called Read() which advances the object to the next row of data, and returns true if there was another row. It will return false if there is not another row.
Using this information, I want to return each row to a list, then stop when there is no more data to return. A Do... While loop works best in this situation as it ensures that adding an item to the list will happen BEFORE checking if there is another row. The reason this must be done BEFORE checking the while(condition) is that when it checks, it also advances. Using a while loop in this situation would cause it to bypass the first row due to the nature of that particular function.
In short:
This won't work in my situation.
//This will skip the first row because Read() returns true after advancing.
while (_read.NextResult())
{
list.Add(_read.GetValue(0).ToString());
}
return list;
This will.
//This will make sure the currently read row is added before advancing.
do
{
list.Add(_read.GetValue(0).ToString());
}
while (_read.NextResult());
return list;
nohup
catches the hangup signal (see man 7 signal
) while the ampersand doesn't (except the shell is confgured that way or doesn't send SIGHUP
at all).
Normally, when running a command using &
and exiting the shell afterwards, the shell will terminate the sub-command with the hangup signal (kill -SIGHUP <pid>
). This can be prevented using nohup
, as it catches the signal and ignores it so that it never reaches the actual application.
In case you're using bash, you can use the command shopt | grep hupon
to find out whether
your shell sends SIGHUP to its child processes or not. If it is off, processes won't be
terminated, as it seems to be the case for you. More information on how bash terminates
applications can be found here.
There are cases where nohup
does not work, for example when the process you start reconnects
the SIGHUP
signal, as it is the case here.
Use file readers:
$(document).ready(function() {
$("#input-file").change(function() {
var length = this.files.length;
if (!length) {
return false;
}
useImage(this);
});
});
// Creating the function
function useImage(img) {
var file = img.files[0];
var imagefile = file.type;
var match = ["image/jpeg", "image/png", "image/jpg"];
if (!((imagefile == match[0]) || (imagefile == match[1]) || (imagefile == match[2]))) {
alert("Invalid File Extension");
} else {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(img.files[0]);
}
function imageIsLoaded(e) {
$('div.withBckImage').css({ 'background-image': "url(" + e.target.result + ")" });
}
}
Autocomplete need to set off from textbox
<asp:TextBox ID="TextBox1" runat="server" autocomplete="off"></asp:TextBox>
A few line of java code.
public static void main(String args[]) throws Exception{
String str="test string";
MessageDigest messageDigest=MessageDigest.getInstance("MD5");
messageDigest.update(str.getBytes(),0,str.length());
System.out.println("MD5: "+new BigInteger(1,messageDigest.digest()).toString(16));
}
getline(fin, buffer, '\n')
where fin
is opened file(ifstream object) and buffer
is of string/char
type where you want to copy line.
I believe the normal answer is that it should be passed by value if you need to make a copy of it in your function. Pass it by const reference otherwise.
Here is a good discussion: http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
Converting a JKS KeyStore to a single PEM file can easily be accomplished using the following command:
keytool -list -rfc -keystore "myKeystore.jks" | sed -e "/-*BEGIN [A-Z]*-*/,/-*END [A-Z]-*/!d" >> "myKeystore.pem"
Explanation:
keytool -list -rfc -keystore "myKeystore.jks"
lists everything in the 'myKeyStore.jks' KeyStore in PEM format. However, it also prints extra information.| sed -e "/-*BEGIN [A-Z]*-*/,/-*END [A-Z]-*/!d"
filters out everything we don't need. We are left with only the PEMs of everything in the KeyStore.>> "myKeystore.pem"
write the PEMs to the file 'myKeyStore.pem'.I like @CHR15TO's answer, unlike other answers I've seen on other similar questions, that answer actually shows how to properly escape a user provided search string (rather than saying it would be necessary without showing how).
However, it's still quite clunky, and possibly relatively slower. So why not have a specific solution to what is likely a common requirement for coders? (And why not include it in the ES6 API BTW?)
My answer [https://stackoverflow.com/a/38290557/887092] on a similar question enables the following:
var haystack = 'A. BAIL. Of. Hay.';
var needle = 'bail.';
var index = haystack.naturalIndexOf(needle);
On Ubuntu you can install it for the system Python with
sudo apt install python3-opencv
This method exists since Laravel 5.4, you can get it by:
$path = Storage::disk('public')->path($filename);
The notation that is used in
a[::-1]
means that for a given string/list/tuple, you can slice the said object using the format
<object_name>[<start_index>, <stop_index>, <step>]
This means that the object is going to slice every "step" index from the given start index, till the stop index (excluding the stop index) and return it to you.
In case the start index or stop index is missing, it takes up the default value as the start index and stop index of the given string/list/tuple. If the step is left blank, then it takes the default value of 1 i.e it goes through each index.
So,
a = '1234'
print a[::2]
would print
13
Now the indexing here and also the step count, support negative numbers. So, if you give a -1 index, it translates to len(a)-1 index. And if you give -x as the step count, then it would step every x'th value from the start index, till the stop index in the reverse direction. For example
a = '1234'
print a[3:0:-1]
This would return
432
Note, that it doesn't return 4321 because, the stop index is not included.
Now in your case,
str(int(a[::-1]))
would just reverse a given integer, that is stored in a string, and then convert it back to a string
i.e "1234" -> "4321" -> 4321 -> "4321"
If what you are trying to do is just reverse the given string, then simply a[::-1] would work .
Your "trigger" is doing something that a "trigger" is not suppose to be doing. You can simple have your Sql Server Agent run
DELETE FROM someTable
WHERE ISNUMERIC(someField) = 1
every 1 second or so. While you're at it, how about writing a nice little SP to stop the programming folk from inserting errors into your table. One good thing about SP's is that the parameters are type safe.
You can do it by using name attibute, class, id or just universal checkbox; If you want to count only checked number of checkbox.
By the class name :
var countChk = $('checkbox.myclassboxName:checked').length;
By name attribute :
var countByName= $('checkbox[name=myAllcheckBoxName]:checked').length;
$('checkbox.className').blur(function() {
//count only checked checkbox
$('checkbox[name=myAllcheckBoxName]:checked').length;
});
Maybe a clean install will fix the problem. This "command" removes all previous modules and re-installs them, perhaps while the webpack module is incompletely downloaded and installed.
npm clean-install
You can use the ID
field as the equality identifier. You can't use the adhoc object for this case because AngularJS checks references equality when comparing objects.
<select
ng-model="Choice.SelectedOption.ID"
ng-options="choice.ID as choice.Name for choice in Choice.Options">
</select>
Try this:
function explode(){
alert("Boom!");
}
setTimeout(explode, 2000);
Line ending format used in OS
CR
(Carriage Return \r
) and LF
(LineFeed \n
) pairLF
(LineFeed \n
)We can configure git to auto-correct line ending formats for each OS in two ways.
.gitattributes
filegit config --global core.autocrlf input
This will fix any CRLF
to LF
when you commit.
git config --global core.autocrlf true
This will make sure when you checkout in windows, all LF
will convert to CRLF
It is a good idea to keep a .gitattributes
file as we don't want to expect everyone in our team set their config. This file should keep in repo's root path and if exist one, git will respect it.
* text=auto
This will treat all files as text files and convert to OS's line ending on checkout and back to LF
on commit automatically. If wanted to tell explicitly, then use
* text eol=crlf
* text eol=lf
First one is for checkout and second one is for commit.
*.jpg binary
Treat all .jpg
images as binary files, regardless of path. So no conversion needed.
Or you can add path qualifiers:
my_path/**/*.jpg binary
To understand get and set, it's all related to how variables are passed between different classes.
The get method is used to obtain or retrieve a particular variable value from a class.
A set value is used to store the variables.
The whole point of the get and set is to retrieve and store the data values accordingly.
What I did in this old project was I had a User class with my get and set methods that I used in my Server class.
The User class's get set methods:
public int getuserID()
{
//getting the userID variable instance
return userID;
}
public String getfirstName()
{
//getting the firstName variable instance
return firstName;
}
public String getlastName()
{
//getting the lastName variable instance
return lastName;
}
public int getage()
{
//getting the age variable instance
return age;
}
public void setuserID(int userID)
{
//setting the userID variable value
this.userID = userID;
}
public void setfirstName(String firstName)
{
//setting the firstName variable text
this.firstName = firstName;
}
public void setlastName(String lastName)
{
//setting the lastName variable text
this.lastName = lastName;
}
public void setage(int age)
{
//setting the age variable value
this.age = age;
}
}
Then this was implemented in the run()
method in my Server class as follows:
//creates user object
User use = new User(userID, firstName, lastName, age);
//Mutator methods to set user objects
use.setuserID(userID);
use.setlastName(lastName);
use.setfirstName(firstName);
use.setage(age);
There is a tool called MySQL Pivot table generator, it can help you create web based pivot table that you can later export to excel(if you like). it can work if your data is in a single table or in several tables .
All you need to do is to specify the data source of the columns (it supports dynamic columns), rows , the values in the body of the table and table relationship (if there are any)
The home page of this tool is http://mysqlpivottable.net
Prefer <appSettings>
to <customUserSetting>
section. It is much easier to read AND write with (Web)ConfigurationManager. ConfigurationSection, ConfigurationElement and ConfigurationElementCollection require you to derive custom classes and implement custom ConfigurationProperty properties. Way too much for mere everyday mortals IMO.
Here is an example of reading and writing to web.config:
using System.Web.Configuration;
using System.Configuration;
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
string oldValue = config.AppSettings.Settings["SomeKey"].Value;
config.AppSettings.Settings["SomeKey"].Value = "NewValue";
config.Save(ConfigurationSaveMode.Modified);
Before:
<appSettings>
<add key="SomeKey" value="oldValue" />
</appSettings>
After:
<appSettings>
<add key="SomeKey" value="newValue" />
</appSettings>
for a lightweight list that does not copy the entries, you may use sth like this:
List<Object> mergedList = new ConcatList<>(list1, list2);
here the implementation:
public class ConcatList<E> extends AbstractList<E> {
private final List<E> list1;
private final List<E> list2;
public ConcatList(final List<E> list1, final List<E> list2) {
this.list1 = list1;
this.list2 = list2;
}
@Override
public E get(final int index) {
return getList(index).get(getListIndex(index));
}
@Override
public E set(final int index, final E element) {
return getList(index).set(getListIndex(index), element);
}
@Override
public void add(final int index, final E element) {
getList(index).add(getListIndex(index), element);
}
@Override
public E remove(final int index) {
return getList(index).remove(getListIndex(index));
}
@Override
public int size() {
return list1.size() + list2.size();
}
@Override
public void clear() {
list1.clear();
list2.clear();
}
private int getListIndex(final int index) {
final int size1 = list1.size();
return index >= size1 ? index - size1 : index;
}
private List<E> getList(final int index) {
return index >= list1.size() ? list2 : list1;
}
}
One way to test private methods is through reflection. This applies to NUnit and XUnit, too:
MyObject objUnderTest = new MyObject();
MethodInfo methodInfo = typeof(MyObject).GetMethod("SomePrivateMethod", BindingFlags.NonPublic | BindingFlags.Instance);
object[] parameters = {"parameters here"};
methodInfo.Invoke(objUnderTest, parameters);
As far I can understand the original problem, you added commits to local master by mistake and did not push that changes yet. Now you want to cancel your changes and hope to delete your local changes and to create a new master branch from the remote one.
You can just reset your changes and reload master from remote server:
git reset --hard origin/master
Generally when people are trying to animate display: none
what they really want is:
Most popular answers use visibility
, which can only achieve the first goal, but luckily it's just as easy to achieve both by using position
.
Since position: absolute
removes the element from typing document flow spacing, you can toggle between position: absolute
and position: static
(global default), combined with opacity
. See the below example.
.content-page {_x000D_
position:absolute;_x000D_
opacity: 0;_x000D_
}_x000D_
_x000D_
.content-page.active {_x000D_
position: static;_x000D_
opacity: 1;_x000D_
transition: opacity 1s linear;_x000D_
}
_x000D_
There is more than one way to do it.
1). A long statement:
>>> def print_something():
print 'This is a really long line,', \
'but we can make it across multiple lines.'
2). Using parenthesis:
>>> def print_something():
print ('Wow, this also works?',
'I never knew!')
3). Using \
again:
>>> x = 10
>>> if x == 10 or x > 0 or \
x < 100:
print 'True'
Quoting PEP8:
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. If necessary, you can add an extra pair of parentheses around an expression, but sometimes using a backslash looks better. Make sure to indent the continued line appropriately. The preferred place to break around a binary operator is after the operator, not before it.
You've already got it: A if test else B
is a valid Python expression. The only problem with your dict comprehension as shown is that the place for an expression in a dict comprehension must have two expressions, separated by a colon:
{ (some_key if condition else default_key):(something_if_true if condition
else something_if_false) for key, value in dict_.items() }
The final if
clause acts as a filter, which is different from having the conditional expression.
Try this:
create procedure dept_count(@dept_name varchar(20),@d_count int)
begin
set @d_count=(select count(*)
from instructor
where instructor.dept_name=dept_count.dept_name)
Select @d_count as count
end
Or
create procedure dept_count(@dept_name varchar(20))
begin
select count(*)
from instructor
where instructor.dept_name=dept_count.dept_name
end
If you use jQuery UI's datepicker and moment.js on the same project, you should piggyback off of moment.js's locale data:
// Finnish. you need to include separate locale file for each locale: https://github.com/moment/moment/tree/develop/locale
moment.locale('fi');
// fetch locale data internal structure, so we can shove it inside jQuery UI
var momentLocaleData = moment.localeData();
$.datepicker.regional['user'] = {
monthNames: momentLocaleData._months,
monthNamesShort: momentLocaleData._monthsShort,
dayNames: momentLocaleData._weekdays,
dayNamesShort: momentLocaleData._weekdaysMin,
dayNamesMin: momentLocaleData._weekdaysMin,
firstDay: momentLocaleData._week.dow,
dateFormat: 'yy-mm-dd' // "2016-11-22". date formatting tokens are not easily interchangeable between momentjs and jQuery UI (https://github.com/moment/moment/issues/890)
};
$.datepicker.setDefaults($.datepicker.regional['user']);
The console is not available because the code is running in the cloud, not in your browser. Instead, use the Logger class provided by GAS:
Logger.log(playerArray[3])
and then view the results in the IDE under View > Logs...
Here's some documentation on logging with GAS.
Edit: 2017-07-20 Apps script now also provides Stackdriver Logging. View these logs in the script editor under View - Console Logs.
you can create your own xml in drawable and use this as android:background="@drawable/your_xml"
in that you can give border corner everything
<item>
<shape>
<gradient
android:endColor="#fff"
android:startColor="#fff"/>
<corners
android:radius="2dp"/>
<stroke
android:width="15dp"
android:color="#0013669e"/>
</shape>
</item>
The return statements should place in one line. Or the other option is to remove the curly brackets that bound the HTML statement.
example:
return posts.map((post, index) =>
<div key={index}>
<h3>{post.title}</h3>
<p>{post.body}</p>
</div>
);
Query performance mainly depends on the number of records it needs to scan, indexes plays a high role in it and index data size is proportional to number of rows and number of indexes.
Queries with indexed field conditions along with full value would be returned in 1ms generally, but starts_with, IN, Between, obviously contains conditions might take more time with more records to scan.
Also you will face lot of maintenance issues with DDL, like ALTER, DROP will be slow and difficult with more live traffic even for adding a index or new columns.
Generally its advisable to cluster the Database into as many clusters as required (500GB would be a general benchmark, as said by others it depends on many factors and can vary based on use cases) that way it gives better isolation and gives independence to scale specific clusters (more suited in case of B2B)
Try to this way :
1) In Instance Run is Enable then desable it. 2) Save it and Rebuild the project. 3) Check devices is online or USB debugging On your device. 4) Then Run It App On your devices.
Note :
If you use mobile device is MI (Xiaomi) Then Check : => setting>Additional setting> Developer options> Install via USB (ON it) => setting>Additional setting> Developer options> USB debugging (ON it) => setting>Additional setting> Developer options> Verify apps over USB (ON/Off it)
In order to use API tokens, users will have to obtain their own tokens, each from https://<jenkins-server>/me/configure
or https://<jenkins-server>/user/<user-name>/configure
. It is up to you, as the author of the script, to determine how users supply the token to the script. For example, in a Bourne Shell script running interactively inside a Git repository, where .gitignore
contains /.jenkins_api_token
, you might do something like:
api_token_file="$(git rev-parse --show-cdup).jenkins_api_token"
api_token=$(cat "$api_token_file" || true)
if [ -z "$api_token" ]; then
echo
echo "Obtain your API token from $JENKINS_URL/user/$user/configure"
echo "After entering here, it will be saved in $api_token_file; keep it safe!"
read -p "Enter your Jenkins API token: " api_token
echo $api_token > "$api_token_file"
fi
curl -u $user:$api_token $JENKINS_URL/someCommand
<dependency>
<groupId>com.github.yingzhuo</groupId>
<artifactId>spring-boot-stater-env</artifactId>
<version>0.0.3</version>
</dependency>
Welcome to use my library. Now yaml, toml, hocon is supported.
Source: github.com
It basically occours when you return from a loop you can only return from function
or you can use this, the '-1' means you don't have to specify the number of the elements.
In [3]: a.view(1,-1)
Out[3]:
1 2 3 4 5
[torch.FloatTensor of size 1x5]
var pom = document.createElement('a');
pom.setAttribute('href', 'data:application/octet-stream,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
pom.style.display = 'none';
document.body.appendChild(pom);
pom.click();
document.body.removeChild(pom);
you can use this method just pass your date to it
-(NSString *)getDateFromString:(NSString *)string
{
NSString * dateString = [NSString stringWithFormat: @"%@",string];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"your current date format"];
NSDate* myDate = [dateFormatter dateFromString:dateString];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"your desired format"];
NSString *stringFromDate = [formatter stringFromDate:myDate];
NSLog(@"%@", stringFromDate);
return stringFromDate;
}
HTML5 says <input type="file" accept="image/*">
. Of course, never trust client-side validation: Always check again on the server-side...
Integer
refers to the reference, that is, when comparing references you're comparing if they point to the same object, not value. Hence, the issue you're seeing. The reason it works so well with plain int
types is that it unboxes the value contained by the Integer
.
May I add that if you're doing what you're doing, why have the if
statement to begin with?
mismatch = ( cdiCt != null && cdsCt != null && !cdiCt.equals( cdsCt ) );
Your cases does not have a return value.
getButtons().get(i).setText("§");
In-line-if is Ternary operation all ternary operations must have return value. That variable is likely void and does not return anything and it is not returning to a variable. Example:
int i = 40;
String value = (i < 20) ? "it is too low" : "that is larger than 20";
for your case you just need an if statement.
if (compareChar(curChar, toChar("0"))) { getButtons().get(i).setText("§"); }
Also side note you should use curly braces it makes the code more readable and declares scope.
Have encountered the same issue in my asp.net project, in the end i found the issue is with the target function not static, the issue fixed after I put the keyword static.
[WebMethod]
public static List<string> getRawData()
JXcore will allow you to turn any nodejs application into a single executable, including all dependencies, in either Windows, Linux, or Mac OS X.
Here is a link to the installer: https://github.com/jxcore/jxcore-release
And here is a link to how to set it up: http://jxcore.com/turn-node-applications-into-executables/
It is very easy to use and I have tested it in both Windows 8.1 and Ubuntu 14.04.
FYI: JXcore is a fork of NodeJS so it is 100% NodeJS compatible, with some extra features.
jQuery(".morepost").live("click", function() {
var loadID = jQuery(this).attr('id'); //get the id
alert(loadID);
});
you can also get the value of id using .attr()
SELECT
cast(xmlField as xml).value('(/person//firstName/node())[1]', 'nvarchar(max)') as FirstName,
cast(xmlField as xml).value('(/person//lastName/node())[1]', 'nvarchar(max)') as LastName
FROM [myTable]
You should have a default server for catch-all, you can return 404
or better to not respond at all (will save some bandwidth) by returning 444
which is nginx specific HTTP response that simply close the connection and return nothing
server {
listen 80 default_server;
server_name _; # some invalid name that won't match anything
return 444;
}
Use the FileSystemObject
object, namely, its CreateFolder
and CopyFile
methods. Basically, this is what your script will look like:
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Create a new folder
oFSO.CreateFolder "C:\MyFolder"
' Copy a file into the new folder
' Note that the destination folder path must end with a path separator (\)
oFSO.CopyFile "\\server\folder\file.ext", "C:\MyFolder\"
You may also want to add additional logic, like checking whether the folder you want to create already exists (because CreateFolder
raises an error in this case) or specifying whether or not to overwrite the file being copied. So, you can end up with this:
Const strFolder = "C:\MyFolder\", strFile = "\\server\folder\file.ext"
Const Overwrite = True
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not oFSO.FolderExists(strFolder) Then
oFSO.CreateFolder strFolder
End If
oFSO.CopyFile strFile, strFolder, Overwrite
Ok, so here was my process:
keytool -list -v -keystore permanent.jks
- got me the alias.
keytool -export -alias alias_name -file certificate_name -keystore permanent.jks
- got me the certificate to import.
Then I could import it with the keytool:
keytool -import -alias alias_name -file certificate_name -keystore keystore location
As @Christian Bongiorno says the alias can't already exist in your keystore.
I was facing the same problem! I've added the code below in wp-config.php file (in any line) and it's working now!
define('FS_METHOD', 'direct');
I've created that effect on my blog Landman Code.
What I did was
#Header {
position: relative;
}
#Header H1 {
font-size: 3em;
color: #00FF00;
margin:0;
padding:0;
}
#Header H2 {
font-size: 1.5em;
color: #FFFF00;
margin:0;
padding:0;
}
#Header .Background {
background: #557700;
filter: alpha(opacity=30);
filter: progid: DXImageTransform.Microsoft.Alpha(opacity=30);
-moz-opacity: 0.30;
opacity: 0.3;
zoom: 1;
}
#Header .Background * {
visibility: hidden; // hide the faded text
}
#Header .Foreground {
position: absolute; // position on top of the background div
left: 0;
top: 0;
}
_x000D_
<div id="Header">
<div class="Background">
<h1>Title</h1>
<h2>Subtitle</h2>
</div>
<div class="Foreground">
<h1>Title</h1>
<h2>Subtitle</h2>
</div>
</div>
_x000D_
The important thing that every padding/margin and content must be the same in both the .Background as .Foreground.
It could be any one of the parameter, not just the file name or alias - for me it was the Key Password.
I had the same need and was looking for recommendation or standard references and came across this thread. My current blacklist of characters that should be avoided in file and directory names are:
$CharactersInvalidForFileName = {
"pound" -> "#",
"left angle bracket" -> "<",
"dollar sign" -> "$",
"plus sign" -> "+",
"percent" -> "%",
"right angle bracket" -> ">",
"exclamation point" -> "!",
"backtick" -> "`",
"ampersand" -> "&",
"asterisk" -> "*",
"single quotes" -> "“",
"pipe" -> "|",
"left bracket" -> "{",
"question mark" -> "?",
"double quotes" -> "”",
"equal sign" -> "=",
"right bracket" -> "}",
"forward slash" -> "/",
"colon" -> ":",
"back slash" -> "\\",
"lank spaces" -> "b",
"at sign" -> "@"
};
The following works in MVC5:
document.getElementById('theID').value = 'new value';
Easiest way to do this with Chartjs. Just add below line in options:
pieceLabel: {
fontColor: '#000'
}
Best of luck
print_r() can print out value but also if second flag parameter is passed and is TRUE - it will return printed result as string and nothing send to standard output. About var_dump. If XDebug debugger is installed so output results will be formatted in much more readable and understandable way.
I tried everything else and found helpless but this indeed worked for me "To update your credentials, go to Control Panel -> Credential Manager -> Generic Credentials. Find the credentials related to your git account and edit them to use the updated passwords".
Above Solution found in this link: https://cmatskas.com/how-to-update-your-git-credentials-on-windows/
gem bootstrap-sass
bootstrap-sass is easy to drop into Rails with the asset pipeline.
In your Gemfile you need to add the bootstrap-sass gem, and ensure that the sass-rails gem is present - it is added to new Rails applications by default.
gem 'sass-rails', '>= 3.2' # sass-rails needs to be higher than 3.2
gem 'bootstrap-sass', '~> 3.0.3.0'
bundle install
and restart your server to make the files available through the pipeline.
Source: http://rubydoc.info/gems/bootstrap-sass/3.0.3.0/frames
It's look like you are using an old version of slim(2.x). You can just add following lines to .htaccess and don't need to do anything in PHP scripts.
# Enable cross domain access control
SetEnvIf Origin "^http(s)?://(.+\.)?(domain_one\.com|domain_two\.net)$" REQUEST_ORIGIN=$0
Header always set Access-Control-Allow-Origin %{REQUEST_ORIGIN}e env=REQUEST_ORIGIN
Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE"
Header always set Access-Control-Allow-Headers: Authorization
# Force to request 200 for options
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule .* / [R=200,L]
We can assign a variable for curl using single quote '
and wrap some other variables in double-single-double quote "'"
for substitution inside curl-variable. Then easily we can use that curl-variable which here is MERGE
.
Example:
# other variables ...
REF_NAME="new-branch";
# variable for curl using single quote => ' not double "
MERGE='{
"repository": "tmp",
"command": "git",
"args": [
"pull",
"origin",
"'"$REF_NAME"'"
],
"options": {
"cwd": "/home/git/tmp"
}
}';
notice this line:
"'"$REF_NAME"'"
and then calling curl as usual:
curl -s -X POST localhost:1365/M -H 'Content-Type: application/json' --data "$MERGE"
It just came up to me that maybe T attribute is a valid choice. Transpose, can get away from the somewhat misleading df.loc[-1] = [2, 3, 4]
as @flow2k mentioned, and it is suitable for more universal situation such as you want to insert [2, 3, 4]
before arbitrary row, which is hard for concat()
,append()
to achieve. And there's no need to bare the trouble defining and debugging a function.
a = df.T
a.insert(0,'anyName',value=[2,3,4])
# just give insert() any column name you want, we'll rename it.
a.rename(columns=dict(zip(a.columns,[i for i in range(a.shape[1])])),inplace=True)
# set inplace to a Boolean as you need.
df=a.T
df
A B C
0 2 3 4
1 5 6 7
2 7 8 9
I guess this can partly explain @MattCochrane 's complaint about why pandas doesn't have a method to insert a row like insert() does.
There are already good answers posted here for this question. But, this is the way I've tried myself (and might be the easiest logic based ? modulo/divide/add):
int decimalOrBinary = 345;
StringBuilder builder = new StringBuilder();
do {
builder.append(decimalOrBinary % 2);
decimalOrBinary = decimalOrBinary / 2;
} while (decimalOrBinary > 0);
System.out.println(builder.reverse().toString()); //prints 101011001
If you're using Bootstrap Sass, here's another way that avoids having to add extra classes to your element markup:
@import "bootstrap/mixins/_border-radius";
@import "bootstrap/_variables";
.your-class {
$r: $border-radius-base; // or $border-radius-large, $border-radius-small, ...
@include border-top-radius($r);
@include border-bottom-radius($r);
}
Try to do following:
Go to your Server
cd rep.git
chmod -R g+ws *
chgrp -R git *
git config core.sharedRepository true
Then go to your working copy(local repository) and repack it by git repack master
Works perfectly to me.
Make sure that...
=
sign before the formula=
sign=A1
, instead of "=A1"
)First of all, note you are not using the variable correctly:
if [ "pass_tc11" != "" ]; then
# ^
# missing $
Anyway, to check if a variable is empty or not you can use -z
--> the string is empty:
if [ ! -z "$pass_tc11" ]; then
echo "hi, I am not empty"
fi
or -n
--> the length is non-zero:
if [ -n "$pass_tc11" ]; then
echo "hi, I am not empty"
fi
From man test
:
-z STRING
the length of STRING is zero
-n STRING
the length of STRING is nonzero
$ [ ! -z "$var" ] && echo "yes"
$
$ var=""
$ [ ! -z "$var" ] && echo "yes"
$
$ var="a"
$ [ ! -z "$var" ] && echo "yes"
yes
$ var="a"
$ [ -n "$var" ] && echo "yes"
yes
jQuery Ajax loader is not working well when you call two APIs simultaneously. To resolve this problem you have to call the APIs one by one using the isAsync
property in Ajax setting. You also need to make sure that there should not be any error in the setting. Otherwise, the loader will not work. E.g undefined content-type, data-type for POST/PUT/DELETE/GET call.
Try this
<TextBlock x:Name="txtblock" FontSize="24" >Hai Welcom to this page
</TextBlock>
Code Behind
var txtblock = sender as Textblock;
txtblock.Foreground = "Red"
If you have an object and wish to become JObject you can use:
JObject o = (JObject)JToken.FromObject(miObjetoEspecial);
like this :
Pocion pocionDeVida = new Pocion{
tipo = "vida",
duracion = 32,
};
JObject o = (JObject)JToken.FromObject(pocionDeVida);
Console.WriteLine(o.ToString());
// {"tipo": "vida", "duracion": 32,}
An alternative to the answer of asselin for use with ES2015 classes
class InvalidArgumentException extends Error {
constructor(message) {
super();
Error.captureStackTrace(this, this.constructor);
this.name = "InvalidArgumentException";
this.message = message;
}
}
How about this? (not my real IP Address!)
PS C:\> $ipV4 = Test-Connection -ComputerName (hostname) -Count 1 | Select IPV4Address
PS C:\> $ipV4
IPV4Address
-----------
192.0.2.0
Note that using localhost would just return and IP of 127.0.0.1
PS C:\> $ipV4 = Test-Connection -ComputerName localhost -Count 1 | Select IPV4Address
PS C:\> $ipV4
IPV4Address
-----------
127.0.0.1
The IP Address object has to be expanded out to get the address string
PS C:\> $ipV4 = Test-Connection -ComputerName (hostname) -Count 1 | Select -ExpandProperty IPV4Address
PS C:\> $ipV4
Address : 556228818
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
IsIPv6Teredo : False
IsIPv4MappedToIPv6 : False
IPAddressToString : 192.0.2.0
PS C:\> $ipV4.IPAddressToString
192.0.2.0
Not sure, if that's what you want, but you could make the inner div an inline-element. This way the border should be wrapped only around the text. Even better than that is to use an inline-element for your title.
Solution 1
<div id="page" style="width: 600px;">
<div id="title" style="display: inline; border...">Title</div>
</div>
Solution 2
<div id="page" style="width: 600px;">
<span id="title" style="border...">Title</span>
</div>
Edit: Strange, SO doesn't interpret my code-examples correctly as block, so I had to use inline-code-method.
You have to be specific about the columns you are selecting. If your user
table had four columns id, name, username, opted_in
you must select exactly those four columns from the query. The syntax looks like:
INSERT INTO user (id, name, username, opted_in)
SELECT id, name, username, opted_in
FROM user LEFT JOIN user_permission AS userPerm ON user.id = userPerm.user_id
However, there does not appear to be any reason to join against user_permission
here, since none of the columns from that table would be inserted into user
. In fact, this INSERT
seems bound to fail with primary key uniqueness violations.
MySQL does not support inserts into multiple tables at the same time. You either need to perform two INSERT
statements in your code, using the last insert id from the first query, or create an AFTER INSERT
trigger on the primary table.
INSERT INTO user (name, username, email, opted_in) VALUES ('a','b','c',0);
/* Gets the id of the new row and inserts into the other table */
INSERT INTO user_permission (user_id, permission_id) VALUES (LAST_INSERT_ID(), 4)
Or using a trigger:
CREATE TRIGGER creat_perms AFTER INSERT ON `user`
FOR EACH ROW
BEGIN
INSERT INTO user_permission (user_id, permission_id) VALUES (NEW.id, 4)
END
I believe he is asking to write the new json to a directory. You will need some Javascript and PHP. So, to piggy back off the other answers:
script.js
var yourObject = {
test:'test 1',
testData: [
{testName: 'do',testId:''}
],
testRcd:'value'
};
var myString = 'newData='+JSON.stringify(yourObject); //converts json to string and prepends the POST variable name
$.ajax({
type: "POST",
url: "buildJson.php", //the name and location of your php file
data: myString, //add the converted json string to a document.
success: function() {alert('sucess');} //just to make sure it got to this point.
});
return false; //prevents the page from reloading. this helps if you want to bind this whole process to a click event.
buildJson.php
<?php
$file = "data.json"; //name and location of json file. if the file doesn't exist, it will be created with this name
$fh = fopen($file, 'a'); //'a' will append the data to the end of the file. there are other arguemnts for fopen that might help you a little more. google 'fopen php'.
$new_data = $_POST["newData"]; //put POST data from ajax request in a variable
fwrite($fh, $new_data); //write the data with fwrite
fclose($fh); //close the dile
?>
You get this error if you have constrained T
to being a class
Swift 3, with extension:
extension UIView{
var globalPoint :CGPoint? {
return self.superview?.convert(self.frame.origin, to: nil)
}
var globalFrame :CGRect? {
return self.superview?.convert(self.frame, to: nil)
}
}
I would use null
to show that there is no value for that particular key. For example, use null
to represent that "number of devices in your household connects to internet" is unknown.
On the other hand, use {}
if that particular key is not applicable. For example, you should not show a count, even if null
, to the question "number of cars that has active internet connection" is asked to someone who does not own any cars.
I would avoid defaulting any value unless that default makes sense. While you may decide to use null
to represent no value, certainly never use "null"
to do so.
Use the sorted()
function:
return sorted(dict.iteritems())
If you want an actual iterator over the sorted results, since sorted()
returns a list, use:
return iter(sorted(dict.iteritems()))
<pre>
<input type="text" #titleInput>
<button type="submit" (click) = 'addTodo(titleInput.value)'>Add</button>
</pre>
{
addTodo(title:string) {
console.log(title);
}
}
yes, you can swap these 2 queries
select * from table limit 5, 5
select * from table limit 0, 5
I think you should be able to develop applications using the visual studio development web server: Start a new FaceBook application on: http://www.facebook.com/developers/. Then set the settings for the site Url and the canvas url to the running instance of your website for example:http://localhost:1062/
Here are a couple of links that should help you out on starting with FaceBook:
Hope this helps.
Try with below command, and it will ask all values to INT
select case when isnumeric(YourColumn + '.0e0') = 1 then cast(YourColumn as int) else NULL end /* case */ from YourTable
I would use XMLHTTP request to retrieve page content as much faster. Then it is easy enough to use querySelectorAll to apply a CSS class selector to grab by class name. Then you access the child elements by tag name and index.
Option Explicit
Public Sub GetInfo()
Dim sResponse As String, html As HTMLDocument, elements As Object, i As Long
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "https://www.hsbc.com/about-hsbc/leadership", False
.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
.send
sResponse = StrConv(.responseBody, vbUnicode)
End With
Set html = New HTMLDocument
With html
.body.innerHTML = sResponse
Set elements = .querySelectorAll(".profile-col1")
For i = 0 To elements.Length - 1
Debug.Print String(20, Chr$(61))
Debug.Print elements.item(i).getElementsByTagName("a")(0).innerText
Debug.Print elements.item(i).getElementsByTagName("p")(0).innerText
Debug.Print elements.item(i).getElementsByTagName("p")(1).innerText
Next
End With
End Sub
References:
VBE > Tools > References > Microsoft HTML Object Library
this code if u make a register form with textBox and use insert and ur textBox is empty and u click on submit button .
CREATE UNIQUE NONCLUSTERED INDEX [IX_tableName_Column]
ON [dbo].[tableName]([columnName] ASC) WHERE [columnName] !=`''`;
I found this thread looking to create an ajax page refresh button with jQuery Mobile.
@sgissinger had the closest answer to what I was looking for, but it was outdated.
I updated for jQuery Mobile 1.4
function refreshPage() {
jQuery.mobile.pageContainer.pagecontainer('change', window.location.href, {
allowSamePageTransition: true,
transition: 'none',
reloadPage: true
// 'reload' parameter not working yet: //github.com/jquery/jquery-mobile/issues/7406
});
}
// Run it with .on
$(document).on( "click", '#refresh', function() {
refreshPage();
});
If you want to have the result for all values of NUM
:
SELECT `NUM`, COUNT(*) AS `count`
FROM yourTable
GROUP BY `NUM`
Or just for one specific:
SELECT `NUM`, COUNT(*) AS `count`
FROM yourTable
WHERE `NUM`=1
You can also use org.apache.commons.lang.ArrayUtils.isEquals()
We are using the cordova-custom-config
plugin to manage our Android configuration. In this case the solution was to add a new custom-preference
to our config.xml
:
<platform name="android">
<preference name="orientation" value="portrait" />
<!-- ... other settings ... -->
<!-- Allow http connections (by default Android only allows https) -->
<!-- See: https://stackoverflow.com/questions/54752716/ -->
<custom-preference
name="android-manifest/application/@android:usesCleartextTraffic"
value="true" />
</platform>
Does anybody know how to do this only for development builds? I would be happy for release builds to leave this setting false
.
(I see the iOS configuration offers buildType="debug"
for that, but I'm not sure if this applies to Android configuration.)
Just wanted to point out that the accepted answer has a couple of limitations (which I discovered when I tried to use it)
It is thus not suitable (without adaptation) for use in a repeated-call setting (eg a ComponentResizedListener
, or a custom/modified LayoutManager
).
The listed code effectively assumes a starting size of 10 pt but refers to the current font size and is thus suitable for calling once (to set the size of the font when the label is created). It would work better in a multi-call environment if it did int newFontSize = (int) (widthRatio * 10);
rather than int newFontSize = (int)(labelFont.getSize() * widthRatio);
Because it uses new Font(labelFont.getName(), Font.PLAIN, fontSizeToUse))
to generate the new font, there is no support for Bolding, Italic or Color etc from the original font in the updated font. It would be more flexible if it made use of labelFont.deriveFont
instead.
The solution does not provide support for HTML label Text. (I know that was probably not ever an intended outcome of the answer code offered, but as I had an HTML-text JLabel
on my JPanel
I formally discovered the limitation. The FontMetrics.stringWidth()
calculates the text length as inclusive of the width of the html tags - ie as simply more text)
I recommend looking at the answer to this SO question where trashgod's answer points to a number of different answers (including this one) to an almost identical question. On that page I will provide an additional answer that speeds up one of the other answers by a factor of 30-100.
For me was a problem with Lombok, because it requires Annotation Processing to be enabled. You can find this checkbox on Settings > Build > Compiler > Annotation Processors
In addition to the existing answer it is possible to set a default option as follows:
echo off
ECHO A current build of Test Harness exists.
set delBuild=n
set /p delBuild=Delete preexisting build [y/n] (default - %delBuild%)?:
This allows users to simply hit "Enter" if they want to enter the default.
There's another very simple answer which can work for some simple graphs.
Just add a call to guide_legend() into your graph.
ggplot(...) + ... + guide_legend(title="my awesome title")
As shown in the very nice ggplot docs.
If that doesn't work, you can more precisely set your guide parameters with a call to guides:
ggplot(...) + ... + guides(fill=guide_legend("my awesome title"))
You can also vary the shape/color/size by specifying these parameters for your call to guides
as well.
A lot of people are going to say this is a bad answer because it is not best practice but you can also convert it to a List before your where.
result = result.ToList().Where(p => date >= p.DOB);
Slauma's answer is better, but this would work as well. This cost more because ToList() will execute the Query against the database and move the results into memory.
On Mac OS 10.14.5, Idea Intellij 2019.1.3 - Press command + 1 to navigate to project files then press control + n
You can comma-separate shadows:
box-shadow: inset 0 2px 0px #dcffa6, 0 2px 5px #000;
The easiest is to use the queryout
option and use union all
to link a column list with the actual table content
bcp "select 'col1', 'col2',... union all select * from myschema.dbo.myTableout" queryout myTable.csv /SmyServer01 /c /t, -T
An example:
create table Question1355876
(id int, name varchar(10), someinfo numeric)
insert into Question1355876
values (1, 'a', 123.12)
, (2, 'b', 456.78)
, (3, 'c', 901.12)
, (4, 'd', 353.76)
This query will return the information with the headers as first row (note the casts of the numeric values):
select 'col1', 'col2', 'col3'
union all
select cast(id as varchar(10)), name, cast(someinfo as varchar(28))
from Question1355876
The bcp command will be:
bcp "select 'col1', 'col2', 'col3' union all select cast(id as varchar(10)), name, cast(someinfo as varchar(28)) from Question1355876" queryout myTable.csv /SmyServer01 /c /t, -T
Uninstalling the app on device and then reinstalling fixed it for me.
Tried all the other options, nothing. Finally found this post. This is after adding permission (below) and cleaning build.
<uses-permission android:name="android.permission.INTERNET"/>
You can use the :last-of-type
pseudo-class:
tr > td:last-of-type {
/* styling here */
}
See the MDN for more info and compatibility with the different browsers.
Check out the W3C CSS guidelines for more info.
Take a look at Numeral.js. It can format numbers, currency, percentages and has support for localization.
Based on this answer, one-liner for simple cases (Python 3 code):
from urllib.parse import urlparse, urlencode
url = "https://stackoverflow.com/search?q=question"
params = {'lang':'en','tag':'python'}
url += ('&' if urlparse(url).query else '?') + urlencode(params)
or:
url += ('&', '?')[urlparse(url).query == ''] + urlencode(params)
Unfortunately SQL Developer doesn't fully honour the set echo off
command that would (appear to) solve this in SQL*Plus.
The only workaround I've found for this is to save what you're doing as a script, e.g. test.sql
with:
set echo off
spool c:\test.csv
select /*csv*/ username, user_id, created from all_users;
spool off;
And then from SQL Developer, only have a call to that script:
@test.sql
And run that as a script (F5).
Saving as a script file shouldn't be much of a hardship anyway for anything other than an ad hoc query; and running that with @
instead of opening the script and running it directly is only a bit of a pain.
A bit of searching found the same solution on the SQL Developer forum, and the development team suggest it's intentional behaviour to mimic what SQL*Plus does; you need to run a script with @
there too in order to hide the query text.
If you're using the anaconda distribution of Python, then simply do:
$? conda install -c conda-forge tensorboard
or
$? conda install -c anaconda tensorboard
Also, you can have a look at various builds by search the packages repo by:
$? anaconda search -t conda tensorboard
which would list the channels and the corresponding builds, the supported OS, Python versions etc.,
Use
$(document).ready(function() {
$('#createFormId').on('show.bs.modal', function(event) {
$("#cafeId").val($(event.relatedTarget).data('id'));
});
});
public String getIMEI(Context context){
TelephonyManager mngr = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
String imei = mngr.getDeviceId();
return imei;
}
An alternative to Martin's
select LEFT(name, CHARINDEX(' ', name + ' ') -1),
STUFF(name, 1, Len(Name) +1- CHARINDEX(' ',Reverse(name)), '')
from somenames
Sample table
create table somenames (Name varchar(100))
insert somenames select 'abcd efgh'
insert somenames select 'ijk lmn opq'
insert somenames select 'asd j. asdjja'
insert somenames select 'asb (asdfas) asd'
insert somenames select 'asd'
insert somenames select ''
insert somenames select null
This is the favicon and is explained in the link.
e.g. from W3C
<link rel="icon"
type="image/png"
href="http://example.com/myicon.png">
Plus, of course the image file in the appropriate place.
I use varargs frequently for constructors that can take some sort of filter object. For example, a large part of our system based on Hadoop is based on a Mapper that handles serialization and deserialization of items to JSON, and applies a number of processors that each take an item of content and either modify and return it, or return null to reject.
RHEL: /etc/pki/tls/openssl.cnf
You can't do it directly, you should provide your own way to check this. Eg.
class MyClass {
Object attr1, attr2, attr3;
public boolean isValid() {
return attr1 != null && attr2 != null && attr3 != null;
}
}
Or make all fields final and initialize them in constructors so that you can be sure that everything is initialized.
Here's some code taken from Kirk Evans Blog that demonstrates how to encode an image in C#;
//Load the picture from a file
Image picture = Image.FromFile(@"c:\temp\test.gif");
//Create an in-memory stream to hold the picture's bytes
System.IO.MemoryStream pictureAsStream = new System.IO.MemoryStream();
picture.Save(pictureAsStream, System.Drawing.Imaging.ImageFormat.Gif);
//Rewind the stream back to the beginning
pictureAsStream.Position = 0;
//Get the stream as an array of bytes
byte[] pictureAsBytes = pictureAsStream.ToArray();
//Create an XmlTextWriter to write the XML somewhere... here, I just chose
//to stream out to the Console output stream
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Console.Out);
//Write the root element of the XML document and the base64 encoded data
writer.WriteStartElement("w", "binData",
"http://schemas.microsoft.com/office/word/2003/wordml");
writer.WriteBase64(pictureAsBytes, 0, pictureAsBytes.Length);
writer.WriteEndElement();
writer.Flush();
I have had the same problem, and I had to set the "Target Framework" of all the projects to be the same. Then it built fine. On the Project menu, click ProjectName Properties. Click the compile tab. Click Advanced Compile Options. In the Target Framework, choose your desired framework.
In my case, during a merge, it seems the solution file was missing some project references. Manually re-adding the project to the solution fixed it. You can also manually edit the solution file but you need to be careful and know what you are doing.
So the Enum
has a __members__
dict.
The solution that @ozgur proposed is really the best, but you can do this, which does the same thing, with more work
[color.value for color_name, color in Color.__members__.items()]
The __members__
dictionary could come in handy if you wanted to insert stuff dynamically in it... in some crazy situation.
[EDIT]
Apparently __members__
is not a dictionary, but a map proxy. Which means you can't easily add items to it.
You can however do weird stuff like MyEnum.__dict__['_member_map_']['new_key'] = 'new_value'
, and then you can use the new key like MyEnum.new_key
.... but this is just an implementation detail, and should not be played with. Black magic is payed for with huge maintenance costs.
In 2020 I use the MoreLinq
Pipe
method. https://morelinq.github.io/2.3/ref/api/html/M_MoreLinq_MoreEnumerable_Pipe__1.htm
for /f "usebackq tokens=*" %%a in (`echo %StringWithLeadingSpaces%`) do set StringWithout=%%a
This is very simple. for
without any parameters considers spaces to be delimiters; setting "*" as the tokens
parameter causes the program to gather up all the parts of the string that are not spaces and place them into a new string into which it inserts gaps of its own.
If you style as list
I guess putting the second line in would also work, but requires human thinking for the content to flow properly, and, of course, hard line breaks (which don't bother me, per se).
This might be what you are after, although depending on how many style_id's there are, it would be tricky to implement (not sure if those style_id's are static or not). If this is the case, then it is not really possible what you are wanting as the WHERE clause works on a row to row basis.
WITH cte as (
SELECT
image_id,
max(decode(style_id,24,style_value)) AS style_colour,
max(decode(style_id,25,style_value)) AS style_size,
max(decode(style_id,27,style_value)) AS style_shape
FROM
list
GROUP BY
image_id
)
SELECT
image_id
FROM
cte
WHERE
style_colour = 'red'
and style_size = 'big'
and style_shape = 'round'
Your stored procedures work as coded. The problem is with the last line, it is unable to invoke either of your stored procedures.
Three choices in SQL*Plus are: call
, exec
, and an anoymous PL/SQL block.
call
appears to be a SQL keyword, and is documented in the SQL Reference. http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4008.htm#BABDEHHG The syntax diagram indicates that parentesis are required, even when no arguments are passed to the call routine.
CALL test_sp_1();
An anonymous PL/SQL block is PL/SQL that is not inside a named procedure, function, trigger, etc. It can be used to call your procedure.
BEGIN
test_sp_1;
END;
/
Exec
is a SQL*Plus command that is a shortcut for the above anonymous block. EXEC <procedure_name>
will be passed to the DB server as BEGIN <procedure_name>; END;
Full example:
SQL> SET SERVEROUTPUT ON
SQL> CREATE OR REPLACE PROCEDURE test_sp
2 AS
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('Test works');
5 END;
6 /
Procedure created.
SQL> CREATE OR REPLACE PROCEDURE test_sp_1
2 AS
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('Testing');
5 test_sp;
6 END;
7 /
Procedure created.
SQL> CALL test_sp_1();
Testing
Test works
Call completed.
SQL> exec test_sp_1
Testing
Test works
PL/SQL procedure successfully completed.
SQL> begin
2 test_sp_1;
3 end;
4 /
Testing
Test works
PL/SQL procedure successfully completed.
SQL>
If anyone is getting this error from a function, try using a reference to the abstract class in the parameters instead.
void something(Abstract bruh){
}
to
void something(Abstract& bruh){
}
There is an example in the launcher app of Android (that I've made a library out of it, here), inside the class that handles wallpapers-picking ("WallpaperPickerActivity") .
The example shows that you need to set a customized theme for this to work. Sadly, this worked for me only using the normal framework, and not the one of the support library.
Here're the themes:
styles.xml
<style name="Theme.WallpaperPicker" parent="Theme.WallpaperCropper">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="Theme.WallpaperCropper" parent="@android:style/Theme.DeviceDefault">
<item name="android:actionBarStyle">@style/WallpaperCropperActionBar</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
<style name="WallpaperCropperActionBar" parent="@android:style/Widget.DeviceDefault.ActionBar">
<item name="android:displayOptions">showCustom</item>
<item name="android:background">#88000000</item>
</style>
value-v19/styles.xml
<style name="Theme.WallpaperCropper" parent="@android:style/Theme.DeviceDefault">
<item name="android:actionBarStyle">@style/WallpaperCropperActionBar</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Theme" parent="@android:style/Theme.DeviceDefault.Wallpaper.NoTitleBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
EDIT: there is a better way to do it, which works on the support library too. Just add this line of code instead of what I've written above:
getSupportActionBar().setDisplayShowCustomEnabled(true);
You have to change the extends Activity to extends AppCompactActivity then try set and getSupportActionBar()
Try javax.net.ssl.keyStorePassword
instead of javax.net.ssl.keyPassword
: the latter isn't mentioned in the JSSE ref guide.
The algorithms you mention should be there by default using the default security providers. NoSuchAlgorithmException
s are often cause by other underlying exceptions (file not found, wrong password, wrong keystore type, ...). It's useful to look at the full stack trace.
You could also use -Djavax.net.debug=ssl
, or at least -Djavax.net.debug=ssl,keymanager
, to get more debugging information, if the information in the stack trace isn't sufficient.
I've tried a some of the solutions in this thread, and unfortunately, I found some of them to be cumbersome (i.e. requiring excessive effort when doing something non-trivial) and inelegant. Consequently, I thought I'd throw my preferred solution, web2py HTML helper objects, into the mix.
First, install the the standalone web2py module:
pip install web2py
Unfortunately, the above installs an extremely antiquated version of web2py, but it'll be good enough for this example. The updated source is here.
Import web2py HTML helper objects documented here.
from gluon.html import *
Now, you can use web2py helpers to generate XML/HTML.
words = ['this', 'is', 'my', 'item', 'list']
# helper function
create_item = lambda idx, word: LI(word, _id = 'item_%s' % idx, _class = 'item')
# create the HTML
items = [create_item(idx, word) for idx,word in enumerate(words)]
ul = UL(items, _id = 'my_item_list', _class = 'item_list')
my_div = DIV(ul, _class = 'container')
>>> my_div
<gluon.html.DIV object at 0x00000000039DEAC8>
>>> my_div.xml()
# I added the line breaks for clarity
<div class="container">
<ul class="item_list" id="my_item_list">
<li class="item" id="item_0">this</li>
<li class="item" id="item_1">is</li>
<li class="item" id="item_2">my</li>
<li class="item" id="item_3">item</li>
<li class="item" id="item_4">list</li>
</ul>
</div>
As of June 2016, click the settings cog in the top right corner and click edit project at the bottom of the list. Then, scroll to the bottom of the page to the Remove project section.
I dont have prettier
extension installed, but after reading the possible duplicate answer I've added from scratch in my User Setting (UserSetting.json
, Ctrl+, shortcut):
"prettier.singleQuote": true
A part a green warning (Unknown configuration setting
) the single quotes are no more replaced.
I suspect that the prettier extension is not visible but is embedded inside the Vetur extension.
From MSDN:
To maximize productivity, the Windows Forms Designer shadows the
AutoSize
property for theForm
class. At design time, the form behaves as though theAutoSize
property is set to false, regardless of its actual setting. At runtime, no special accommodation is made, and theAutoSize
property is applied as specified by the property setting.
For every PostScript printer, one part of its driver is an ASCII file called PostScript Printer Description (PPD). PPDs are used in the CUPS printing system on Linux and Mac OS X as well even for non-PostScript printers.
Every PPD MUST, according to the PPD specification written by Adobe, contain definitions of a *ImageableArea (that's a PPD keyword) for each and every media sizes it can handle. That value is given for example as *ImageableArea Folio/8,25x13: "12 12 583 923"
for one printer in this office here, and *ImageableArea Folio/8,25x13: "0 0 595 935"
for the one sitting in the next room.
These figures mean "Lower left corner is at (12|12), upper right corner is at (583|923)" (where these figures are measured in points; 72pt == 1inch). Can you see that the first printer does print with a margin of 1/6 inch? -- Can you also see that the next one can even print borderless?
What you need to know is this: Even if the printer can do very small margins physically, if the PPD *ImageableArea
is set to a wider margin, the print data generated by the driver and sent to the printer will be clipped according to the PPD setting -- not by the printer itself.
These days more and more models appear on the market which can indeed print edge-to-edge. This is especially true for office laser printers. (Don't know about devices for the home use market.) Sometimes you have to enable that borderless mode with a separate switch in the driver settings, sometimes also on the device itself (front panel, or web interface).
Older models, for example HP's, define in their PPDs their margines quite generously, just to be on the supposedly "safe side". Very often HP used 1/3, 1/2 inch or more (like "24 24 588 768"
for Letter format). I remember having hacked HP PPDs and tuned them down to "6 6 606 786"
(1/12 inch) before the physical boundaries of the device kicked in and enforced a real clipping of the page image.
Now, PCL and other language printers are not that much different in their margin capabilities from PostScript models.
But of course, when it comes to printing of PDF docs, here you can nearly always choose "print to fit" or similarly named options. Even for a file that itself does not use any margins. That "fit" is what the PDF viewer reads from the driver, and the viewer then scales down the page to the *ImageableArea
.
Environment variable (can access anywhere/ dynamic object) is a type of variable. They are of 2 types system environment variables and user environment variables.
System variables having a predefined type and structure. That are used for system function. Values that produced by the system are stored in the system variable. They generally indicated by using capital letters Example: HOME,PATH,USER
User environment variables are the variables that determined by the user,and are represented by using small letters.
To avoid hyphenation in already hyphenated word I used non-breaking space ~
in combination with backward space \!
. For example, command
3~\!\!\!\!-~\!\!\!D
used in the text, suppress hyphenation in word 3-D. Probably not the best solution, but it worked for me!
Update Sept 2017: fs-promise
has been deprecated in favour of fs-extra
.
I haven't used it, but you could look into fs-promise. It's a node module that:
Proxies all async fs methods exposing them as Promises/A+ compatible promises (when, Q, etc). Passes all sync methods through as values.
To avoid adding extra div
s when clicking on the link multiple times, and avoid problems when using the script to display forms, you could try a variation of @jek's code.
$('a.ajax').live('click', function() {
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $('<div id="dialog" style="display:hidden"></div>').appendTo('body');
}
// load remote content
dialog.load(
url,
{},
function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog();
}
);
//prevent the browser to follow the link
return false;
});`
Duplicate question which basically says use ExecuteScalar()
instead.
If this helps you,
<input type="checkbox" (ngModelChange)="mychange($event)" [ngModel]="mymodel">
mychange(val)
{
console.log(val); // updated value
}
Newer versions of the DOMTokenList spec allow for multiple arguments to add()
and remove()
, as well as a second argument to toggle()
to force state.
At the time of writing, Chrome supports multiple arguments to add()
and remove()
, but none of the other browsers do. IE 10 and lower, Firefox 23 and lower, Chrome 23 and lower and other browsers do not support the second argument to toggle()
.
I wrote the following small polyfill to tide me over until support expands:
(function () {
/*global DOMTokenList */
var dummy = document.createElement('div'),
dtp = DOMTokenList.prototype,
toggle = dtp.toggle,
add = dtp.add,
rem = dtp.remove;
dummy.classList.add('class1', 'class2');
// Older versions of the HTMLElement.classList spec didn't allow multiple
// arguments, easy to test for
if (!dummy.classList.contains('class2')) {
dtp.add = function () {
Array.prototype.forEach.call(arguments, add.bind(this));
};
dtp.remove = function () {
Array.prototype.forEach.call(arguments, rem.bind(this));
};
}
// Older versions of the spec didn't have a forcedState argument for
// `toggle` either, test by checking the return value after forcing
if (!dummy.classList.toggle('class1', true)) {
dtp.toggle = function (cls, forcedState) {
if (forcedState === undefined)
return toggle.call(this, cls);
(forcedState ? add : rem).call(this, cls);
return !!forcedState;
};
}
})();
A modern browser with ES5 compliance and DOMTokenList
are expected, but I'm using this polyfill in several specifically targeted environments, so it works great for me, but it might need tweaking for scripts that will run in legacy browser environments such as IE 8 and lower.
In [92]: (myseries==7).argmax()
Out[92]: 3
This works if you know 7 is there in advance. You can check this with (myseries==7).any()
Another approach (very similar to the first answer) that also accounts for multiple 7's (or none) is
In [122]: myseries = pd.Series([1,7,0,7,5], index=['a','b','c','d','e'])
In [123]: list(myseries[myseries==7].index)
Out[123]: ['b', 'd']
Bit
is also an option if tinyint
isn't to your liking. A few links:
Not surprisingly, more info about numeric types is available in the manual.
One more link: http://blog.mclaughlinsoftware.com/2010/02/26/mysql-boolean-data-type/
And a quote from the comment section of the article above:
- TINYINT(1) isn’t a synonym for bit(1).
- TINYINT(1) can store -9 to 9.
- TINYINT(1) UNSIGNED: 0-9
- BIT(1): 0, 1. (Bit, literally).
Edit: This edit (and answer) is only remotely related to the original question...
Additional quotes by Justin Rovang and the author maclochlainn (comment section of the linked article).
Excuse me, seems I’ve fallen victim to substr-ism: TINYINT(1): -128-+127 TINYINT(1) UNSIGNED: 0-255 (Justin Rovang 25 Aug 11 at 4:32 pm)
True enough, but the post was about what PHPMyAdmin listed as a Boolean, and there it only uses 0 or 1 from the entire wide range of 256 possibilities. (maclochlainn 25 Aug 11 at 11:35 pm)
The answer with most vote partially worked for me. The browser url stayed the same but my routerLinkActive
was not longer working after navigation.
My solution was to use lotation.go:
import { Component } from "@angular/core";
import { Location } from "@angular/common";
import { HttpParams } from "@angular/common/http";
export class whateverComponent {
constructor(private readonly location: Location, private readonly router: Router) {}
addQueryString() {
const params = new HttpParams();
params.append("param1", "value1");
params.append("param2", "value2");
this.location.go(this.router.url.split("?")[0], params.toString());
}
}
I used HttpParams to build the query string since I was already using it to send information with httpClient. but you can just build it yourself.
and the this._router.url.split("?")[0]
, is to remove all previous query string from current url.
The geocoder has quota and rate limits. From experience, you can geocode ~10 locations without hitting the query limit (the actual number probably depends on server loading). The best solution is to delay when you get OVER_QUERY_LIMIT errors, then retry. See these similar posts:
If it is exactly null
(as opposed to not set):
db.states.find({"cities.name": null})
(but as javierfp points out, it also matches documents that have no cities array at all, I'm assuming that they do).
If it's the case that the property is not set:
db.states.find({"cities.name": {"$exists": false}})
I've tested the above with a collection created with these two inserts:
db.states.insert({"cities": [{name: "New York"}, {name: null}]})
db.states.insert({"cities": [{name: "Austin"}, {color: "blue"}]})
The first query finds the first state, the second query finds the second. If you want to find them both with one query you can make an $or
query:
db.states.find({"$or": [
{"cities.name": null},
{"cities.name": {"$exists": false}}
]})
As far as I'm aware, you've got three options to install zsh on Mac OS X:
./configure
, make
, make install
). Please add the following dependency http://mvnrepository.com/artifact/org.json/json/20080701
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20080701</version>
</dependency>
You need to add Portrait (top home button) on the supported interface orientation field of info.plist file in xcode
.live()
has been deprecated as of jQuery 1.7
Use .on()
instead and specify a descendant selector
$("table").on({
mouseenter: function(){
$(this).addClass("inside");
},
mouseleave: function(){
$(this).removeClass("inside");
}
}, "tr"); // descendant selector
You could use loc
to get series which satisfying your condition and then iloc
to get first element:
In [2]: df
Out[2]:
A B
0 p1 1
1 p1 2
2 p3 3
3 p2 4
In [3]: df.loc[df['B'] == 3, 'A']
Out[3]:
2 p3
Name: A, dtype: object
In [4]: df.loc[df['B'] == 3, 'A'].iloc[0]
Out[4]: 'p3'
One way:
SELECT DISTINCT sc.StoreId
FROM StoreClients sc
WHERE NOT EXISTS(
SELECT * FROM StoreClients sc2
WHERE sc2.StoreId = sc.StoreId AND sc2.ClientId = 5)
If you are using Hibernate version prior to Hibernate5 @GeneratedValue(strategy = GenerationType.IDENTITY)
works like a charm. But post Hibernate5 the following fix is necessary.
@Id
@GeneratedValue(strategy= GenerationType.AUTO,generator="native")
@GenericGenerator(name = "native",strategy = "native")
private Long id;
DDL
`id` BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
REASON
Excerpt from hibernate-issue
Currently, if the hibernate.id.new_generator_mappings is set to false, @GeneratedValue(strategy = GenerationType.AUTO) is mapped to native. If this property is true (which is the defult value in 5.x), the @GeneratedValue(strategy = GenerationType.AUTO) is always mapped to SequenceStyleGenerator.
For this reason, on any database that does not support sequences natively (e.g. MySQL) we are going to use the TABLE generator instead of IDENTITY.
However, TABLE generator, although more portable, uses a separate transaction every time a value is being fetched from the database. In fact, even if the IDENTITY disables JDBC batch updates and the TABLE generator uses the pooled optimizer, the IDENTITY still scales better.
\begin{tikzpicture}
\tikzstyle{every node}=[font=\small]
\end{tikzpicture}
will give you font size control on every node.
Try this:
$('#parent').on('click', '#child', function() {
// Code
});
From the $.on()
documentation:
Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to
.on()
.
Your #child
element doesn't exist when you call $.on()
on it, so the event isn't bound (unlike $.live()
). #parent
, however, does exist, so binding the event to that is fine.
The second argument in my code above acts as a 'filter' to only trigger if the event bubbled up to #parent
from #child
.
NW.js allows you to create desktop applications using Javascript without all the security restrictions usually placed on the browser. So you can run executables with a function, or create/edit/read/write/delete files. You can access the hardware, such as current CPU usage or total ram in use, etc.
You can create a windows, linux, or mac desktop application with it that doesn't require any installation.
Step 1:
npm uninstall -g angular-cli
Step 2:
npm cache clean
Step 3:
npm cache verify
Step 4:
npm cache verify --force
Note: You can also delete by the following the paths
C:\Users"System_name"\AppData\Roaming\npm and
C:\Users"System_name"\AppData\Roaming\npm-cache
Then
Step 5:
npm install -g @angular/cli@latest
In PostgreSQL, while adding a field it would be added at the end of the table. If we need to insert into particular position then
alter table tablename rename to oldtable;
create table tablename (column defs go here);
insert into tablename (col1, col2, col3) select col1, col2, col3 from oldtable;
I had the same problem. For me, just writing
sqlplus myusername/mypassword@localhost
did the trick, doing so makes it connect to the default service name, I guess.
string myFilePath = @"C:\MyFile.txt";
string ext = Path.GetExtension(myFilePath);
// ext would be ".txt"
The already mentioned solutions above will work if all you want to do is resize the window and window only. However, if you want to have the resize propagated to child elements, you will need to propagate the event yourself. Here's some example code to do it:
window.addEventListener("resize", function () {
var recResizeElement = function (root) {
Array.prototype.forEach.call(root.childNodes, function (el) {
var resizeEvent = document.createEvent("HTMLEvents");
resizeEvent.initEvent("resize", false, true);
var propagate = el.dispatchEvent(resizeEvent);
if (propagate)
recResizeElement(el);
});
};
recResizeElement(document.body);
});
Note that a child element can call
event.preventDefault();
on the event object that is passed in as the first Arg of the resize event. For example:
var child1 = document.getElementById("child1");
child1.addEventListener("resize", function (event) {
...
event.preventDefault();
});