qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
1,829,160 | I am coding a terminal like Linux terminal with C under Linux OS and I need to quit program when the user presses ctrl+D keywords. But I don't know how to understand that the user pressed these keywords. Thanks for your helping.
I'm getting inputs with fgets() | 2009/12/01 | [
"https://Stackoverflow.com/questions/1829160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/200543/"
] | Ctrl+D is end-of-file. In that case, `fgets()` will return a null pointer.
So, your program's main loop can probably look something like this:
```
char buffer[2000];
const char* input = fgets(buffer, sizeof(buffer), stdin);
while (input) {
do_something_with(input);
input = fgets(buffer, sizeof(buffer), stdin)... | Here is a small example, how to read individual keypresses from a terminal keyboard:
```
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
int main(void){
struct termios save,raw;
tcgetattr(0,&save);
cfmakeraw(&raw); tcsetattr(0,TCSANOW,&raw);
unsigned char ch;
do{
read(0,&ch,1);
if( ch<... |
15,519,695 | I would like to find the index for when an array exceeds a certain value, and this value is value is exceeded for a duration, n. For examples:
```
n = 5;
dat = [1,2,2,1.5,2,4,2,1,1,3,4,6,8,4,9];
```
Here, I would like to find when 'dat' exceeds 2 for a duration greater than n for the first time. So, the solution her... | 2013/03/20 | [
"https://Stackoverflow.com/questions/15519695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1480106/"
] | ```
n = 5;
m = 2;
dat = [1,2,2,1.5,2,4,2,1,1,3,4,6,8,4,9];
c = conv(double(dat >= m), ones(1, n))
%I think you can also do
% c = conv((dat >= m)*1, ones(1, n))
min(find(c == n)) - n + 1
``` | ```
n=5
x=2;
dat = [1,2,2,1.5,2,4,2,1,1,3,4,6,8,4,9];
vec= cumsum(dat>=x);
ind=find(vec>=n);
ind=dat(ind(1));
```
`ind` will contain the answer 10 |
27,243,745 | I have 10 files with some data varying in length.I would like to store corresponding data in same file and with same filename, but flume is splitting up the data and saving as FlumeData.timestamp. I am using the configuration as below:
```
a1.sources = r1
a1.sinks = k2
a1.channels = c1
a1.channels.c1.type = file
a1... | 2014/12/02 | [
"https://Stackoverflow.com/questions/27243745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3840344/"
] | ok, you need a few more props fro hdfs sink:
```
a1.sinks.k2.hdfs.filePrefix = [your prefix]
a1.sinks.k2.hdfs.fileSuffix = .[your suffix]
```
suffix would be .tsv or .csv for instance, while prefix can be anything - you can also use variables for date and time - this requires that you use the timestamp interceptor. ... | Thanks much for your help Erik it helped to go close to the problem i found that flume was creating a file in the data source directory .flumespool which i had to delete along with /mnt/flume/\* and also rename the data file to the same name as it was if it was changed to .COMPLETED |
31,457 | I'm a self-taught hobby pianist with small hands, which means that often I need to substitute notes to be able to play something comfortably (or at all).
E.g. in Traumerei, there is a 10-note reach for both hands in the 3rd-to-last bar. At this point in the score it seems (to me at least) that the composer aims for a ... | 2015/04/06 | [
"https://music.stackexchange.com/questions/31457",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/17020/"
] | The first one's OK, you've redistributed the original notes. But in the second one you've invented a new harmony, and that ISN'T OK! I suggest you simply leave out the low E in the RH. Or even play the B octave a bit early, catch it with the pedal and take the E with your LH. | As a supplement to @LaurencePayne's answer:
For the first chord, have you tried playing both lower notes, the F and G, with your thumb? If not, give it a try; perhaps it will allow you to play as written.
Regarding the second chord, dropping the low E is the best option, because that pitch is doubled by the more impo... |
24,835,302 | How do I determine programmatically if my Sitecore renderings field inherits from standard value?
I can get my standard values for the rendering field with this...
```
var ss = StandardValuesManager.GetStandardValue(rootrenderingfield);
```
I can also parse the id of the rendering from this but really need to know ... | 2014/07/18 | [
"https://Stackoverflow.com/questions/24835302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638423/"
] | You can use the code below to check if it came from Standard Value or not.
```
Sitecore.Data.Fields.Field title = item.Fields["title"];
title.ContainsStandardValue(); //boolean
```
Or if you want to check the the value from the standardValue of the title field
```
title.GetStandardValue(); //string
``` | If your looking to find ALL ITEMS where the "Renderings" field does NOT inherit from standard values, try this...
```
protected void CheckStdValues(Sitecore.Data.Items.Item root)
{
foreach (Sitecore.Data.Items.Item itm in root.Children)
{
Sitecore.Collections.FieldCollection fields = itm.Fields;
... |
24,835,302 | How do I determine programmatically if my Sitecore renderings field inherits from standard value?
I can get my standard values for the rendering field with this...
```
var ss = StandardValuesManager.GetStandardValue(rootrenderingfield);
```
I can also parse the id of the rendering from this but really need to know ... | 2014/07/18 | [
"https://Stackoverflow.com/questions/24835302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638423/"
] | You can use the code below to check if it came from Standard Value or not.
```
Sitecore.Data.Fields.Field title = item.Fields["title"];
title.ContainsStandardValue(); //boolean
```
Or if you want to check the the value from the standardValue of the title field
```
title.GetStandardValue(); //string
``` | I'm not sure exactly what you're looking for to do, but a layouts is typically set on standard values and then a layout delta is applied when changing the layout on a content item. Therefore this is a bit different compared to other field where the value is simply overwritten.
I guess you're looking for somethink like... |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | try
```
variableName in window
```
or
```
typeof window[variableName] != 'undefined'
```
or
```
window[variableName] !== undefined
```
or
```
window.hasOwnProperty(variableName)
``` | If you are not sure whether a global variable is defined, you can always try accessing it and see what happens.
```
function node_env(name) {
try {
return process.env[name];
} catch (ignore) {}
}
``` |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | ```
/**
* @param {string} nameOfVariable
*/
function globalExists(nameOfVariable) {
return nameOfVariable in window
}
```
It doesn't matter whether you created a global variable with var foo or window.foo — variables created with var in global context are written into window. | If you are not sure whether a global variable is defined, you can always try accessing it and see what happens.
```
function node_env(name) {
try {
return process.env[name];
} catch (ignore) {}
}
``` |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | ```
/**
* @param {string} nameOfVariable
*/
function globalExists(nameOfVariable) {
return nameOfVariable in window
}
```
It doesn't matter whether you created a global variable with var foo or window.foo — variables created with var in global context are written into window. | As of ES6 most of other answers, including the accepted answer, are incorrect, because global variables defined by `let` or `const`, or resulting from a `class` declaration, do not have corresponding properties on the global object (`window` in a browser, or `global` in node.js). Several of them—mainly the ones which u... |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | As of ES6 most of other answers, including the accepted answer, are incorrect, because global variables defined by `let` or `const`, or resulting from a `class` declaration, do not have corresponding properties on the global object (`window` in a browser, or `global` in node.js). Several of them—mainly the ones which u... | bfavaretto is incorrect.
Setting the global undefined to a value will not alter tests of objects against undefined. Try this in your favorite browsers JavaScript console:
```
var udef; var idef = 42;
alert(udef === undefined); // Alerts "true".
alert(idef === undefined); // Alerts "false".
window.undefined = 'defined... |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | ```
/*global window */
if (window.someVar === undefined) {
window.someVar = 123456;
}
if (!window.hasOwnProperty('someVar')) {
window.someVar = 123456;
}
``` | As of ES6 most of other answers, including the accepted answer, are incorrect, because global variables defined by `let` or `const`, or resulting from a `class` declaration, do not have corresponding properties on the global object (`window` in a browser, or `global` in node.js). Several of them—mainly the ones which u... |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | If you are wanting to assign a global variable only if it doesn't already exist, try:
```
window.someVar = window.someVar || 'hi';
```
or
```
window['someVar'] = window['someVar'] || 'hi';
``` | As of ES6 most of other answers, including the accepted answer, are incorrect, because global variables defined by `let` or `const`, or resulting from a `class` declaration, do not have corresponding properties on the global object (`window` in a browser, or `global` in node.js). Several of them—mainly the ones which u... |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | ```
/*global window */
if (window.someVar === undefined) {
window.someVar = 123456;
}
if (!window.hasOwnProperty('someVar')) {
window.someVar = 123456;
}
``` | bfavaretto is incorrect.
Setting the global undefined to a value will not alter tests of objects against undefined. Try this in your favorite browsers JavaScript console:
```
var udef; var idef = 42;
alert(udef === undefined); // Alerts "true".
alert(idef === undefined); // Alerts "false".
window.undefined = 'defined... |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | I think this is actually a problem with JSLint. It will issue the following error:
>
> Unexpected 'typeof'. Compare directly with 'undefined'.
>
>
>
I believe this is bad advice. In JavaScript, `undefined` is a global variable that is, usually, undefined. But some browsers allow scripts to modify it, like this: `... | This would be a simple way to perform the check .
But this check would fail if `variableName` is declared and is assigned with the `boolean value: false`
```
if(window.variableName){
}
``` |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | As of ES6 most of other answers, including the accepted answer, are incorrect, because global variables defined by `let` or `const`, or resulting from a `class` declaration, do not have corresponding properties on the global object (`window` in a browser, or `global` in node.js). Several of them—mainly the ones which u... | If you are not sure whether a global variable is defined, you can always try accessing it and see what happens.
```
function node_env(name) {
try {
return process.env[name];
} catch (ignore) {}
}
``` |
11,596,315 | JSLint is not passing this as a valid code:
```
/* global someVar: false */
if (typeof someVar === "undefined") {
var someVar = "hi!";
}
```
What is the correct way? | 2012/07/21 | [
"https://Stackoverflow.com/questions/11596315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414809/"
] | If you are wanting to assign a global variable only if it doesn't already exist, try:
```
window.someVar = window.someVar || 'hi';
```
or
```
window['someVar'] = window['someVar'] || 'hi';
``` | >
>
> ```
> if (typeof someVar === "undefined") {
> var someVar = "hi!";
> }
>
> ```
>
>
will check if `someVar` (local or global) is undefined.
If you want to check for a global variable you can use
```
if(window['someVar'] === undefined) {
...
}
```
assuming this is in a browser :) |
38,584 | As I am going deep into my meditations of Vipassana and Zazen I am also going deep in my subconscious mind. Some long-forgotten painful memories of insult surface up. As I look now with a different vantage point I understand that my own Karma, my own Ego, and my own behavior was also responsible for me getting insulted... | 2020/04/02 | [
"https://buddhism.stackexchange.com/questions/38584",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/16806/"
] | **How to deal with insults?**
There's a canonical answer here -- [Akkosa Sutta: Insult (SN 7.2)](https://www.accesstoinsight.org/tipitaka/sn/sn07/sn07.002.than.html)
>
> In the same way, brahman, that with which you have insulted me, who is not insulting; that with which you have taunted me, who is not taunting; tha... | Here we have a prime example of how attachment can lead to dukha (suffering).
In this instance, you are attached to a certain self-image, and insulting behavior by in others is attacking that image.
If you can bear in mind that we live in an a world of delusion, of impermanence, and if you are able to be more flexibl... |
38,584 | As I am going deep into my meditations of Vipassana and Zazen I am also going deep in my subconscious mind. Some long-forgotten painful memories of insult surface up. As I look now with a different vantage point I understand that my own Karma, my own Ego, and my own behavior was also responsible for me getting insulted... | 2020/04/02 | [
"https://buddhism.stackexchange.com/questions/38584",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/16806/"
] | **How to deal with insults?**
There's a canonical answer here -- [Akkosa Sutta: Insult (SN 7.2)](https://www.accesstoinsight.org/tipitaka/sn/sn07/sn07.002.than.html)
>
> In the same way, brahman, that with which you have insulted me, who is not insulting; that with which you have taunted me, who is not taunting; tha... | Well it's a good thing to be insulted. Why? Because it basically wears off the bad Karma that you accumulated in the past by insulting others. When those thoughts of insults appear in you, imagine that the same insults you recieved; were earlier done by you towards someone else in a previous birth. The person who is in... |
15,358,531 | Is there a free tool to open and recompile a swf file that contains action script 3 code? | 2013/03/12 | [
"https://Stackoverflow.com/questions/15358531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187730/"
] | This will help you to save image in png type
```
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage : (UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
NSError *error;
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithF... | You could use something similar to this in your method to save the captured object as a PNG:
```
// Create paths to output images
NSString *thePngPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Example.png"];
NSString *theJpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Ex... |
15,358,531 | Is there a free tool to open and recompile a swf file that contains action script 3 code? | 2013/03/12 | [
"https://Stackoverflow.com/questions/15358531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187730/"
] | ```
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
// png image data
NSData *pngData = UIImagePNGRepresentation(image);
// jpeg image data
NSData *jpegData = UIImageJPEGRepresentation(image, compressionQuality); // compressionQuality = 0.0 to 1.0 --> 0 means maximum compression and 1 me... | You could use something similar to this in your method to save the captured object as a PNG:
```
// Create paths to output images
NSString *thePngPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Example.png"];
NSString *theJpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Ex... |
15,358,531 | Is there a free tool to open and recompile a swf file that contains action script 3 code? | 2013/03/12 | [
"https://Stackoverflow.com/questions/15358531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187730/"
] | This will help you to save image in png type
```
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage : (UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
NSError *error;
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithF... | Use this code,
```
NSData* pngdata = UIImagePNGRepresentation (image); //PNG wrap
UIImage* img = [UIImage imageWithData:pngdata];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
``` |
15,358,531 | Is there a free tool to open and recompile a swf file that contains action script 3 code? | 2013/03/12 | [
"https://Stackoverflow.com/questions/15358531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187730/"
] | ```
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
// png image data
NSData *pngData = UIImagePNGRepresentation(image);
// jpeg image data
NSData *jpegData = UIImageJPEGRepresentation(image, compressionQuality); // compressionQuality = 0.0 to 1.0 --> 0 means maximum compression and 1 me... | Use this code,
```
NSData* pngdata = UIImagePNGRepresentation (image); //PNG wrap
UIImage* img = [UIImage imageWithData:pngdata];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
``` |
15,358,531 | Is there a free tool to open and recompile a swf file that contains action script 3 code? | 2013/03/12 | [
"https://Stackoverflow.com/questions/15358531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187730/"
] | This will help you to save image in png type
```
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage : (UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
NSError *error;
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithF... | ```
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
// png image data
NSData *pngData = UIImagePNGRepresentation(image);
// jpeg image data
NSData *jpegData = UIImageJPEGRepresentation(image, compressionQuality); // compressionQuality = 0.0 to 1.0 --> 0 means maximum compression and 1 me... |
53,482,032 | I'm having a JSON deserialized from Java as follow:
**Java**
```
jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(graphDTO);
```
**JSON**
```
"accounts" : [ {
"name" : "1009427721",
"value" : 16850.79,
"children" : [ {
"name" : "BITCOIN EARNINGS",
"value" : 10734... | 2018/11/26 | [
"https://Stackoverflow.com/questions/53482032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4230093/"
] | I don't think it's possible to avoid the `accounts`, but you can do this:
```
jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(graphDTO.getAccounts());
```
We're waiting your way to parse JSON in javascript... | Got it work as follow:
1. Applying the answer of Mohicane:
`mapper.writerWithDefaultPrettyPrinter().writeValueAsString(graphDTO.getAccounts())`
2. Injecting the JSON from Java to JavaScript (in a JSP) with:
`var data = ${graphDTOJSON};`
Many thanks! |
170,327 | Is there a mode, some switch or a programmatic way that I can ask MSBuild to display or output it's calculated dependencies for a given build file?
**Some background** -
I have a large project that requires splitting up to speed up the build time and want to remove the slow changing infrastructure code into it's own ... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7093/"
] | The [MSBuild Profiler](http://www.codeplex.com/msbuildprofiler) project should be able to help you in seeing where time is being taken on the build. It doesn't directly show dependencies. With or without build dependencies, just profiling the builds can probably give some insight and help speed up the process.
I did j... | Whilst I asked the original question quite a long time ago, I have moved on in jobs and surprisingly encountered the same need. In this case I was more successful in my pursuit of a tool and discovered [Microsoft Build Sidekick](http://www.attrice.info/msbuild/index.htm) which offers:
* view
* edit
* build
* debug
of... |
7,078,884 | Looking to do something that I think is fairly basic, but having never written a CRON job before, I'm not really sure how to go about it. Basically, I have a simple DB query that I've written:
```
SELECT SUM(total) as totalDownloads FROM wp_podpress_statcounts
```
As you'd expect, this displays a number. What I'd li... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7078884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/622278/"
] | No need for PHP if you use a few built-in UNIX tools:
To execute from commandline, using the [MySQL commandline](http://dev.mysql.com/doc/refman/5.5/en/mysql.html):
```
mysql -e 'SELECT SUM(total) as totalDownloads FROM wp_podpress_statcounts';
```
Either put a `-u -p` for the username and password, or put a [`~/.m... | Just an FYI - there is one other option you could also look at - mysql events. Similar to what you would have in MS SQL Server for example. There are some limitations on what you can do so you would definitely want to check those out first.
Check out: <http://dev.mysql.com/doc/refman/5.1/en/events.html> for more info.... |
14,048,704 | Please assist me for complete this query
```
select *
from table1 a
join table2_n n
on a.PHONE_NO like '%'|| (select substr(mobile_no,2,9) as mobile_no from table2)
```
table 2 records exists in table1. so i need to get them all from this query | 2012/12/27 | [
"https://Stackoverflow.com/questions/14048704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1762112/"
] | Why do you need to use like and subquery, any how you have joined 2 tables with phone\_no column, then it'll return all the matching records. | Use rownum=1 or where condition to return only one row from the inner sub query otherwise it would not work for multiple recods in table2. |
14,048,704 | Please assist me for complete this query
```
select *
from table1 a
join table2_n n
on a.PHONE_NO like '%'|| (select substr(mobile_no,2,9) as mobile_no from table2)
```
table 2 records exists in table1. so i need to get them all from this query | 2012/12/27 | [
"https://Stackoverflow.com/questions/14048704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1762112/"
] | You don't need to have a subquery, you can just join the data directly:
```
select a.*
from table1 a
join table2 n
on a.PHONE_NO like '%'|| substr(mobile_no,2,9);
```
Alternatively, you could write this using an `exists` subquery:
```
select *
from table1 a
where exists (select null
from ... | Why do you need to use like and subquery, any how you have joined 2 tables with phone\_no column, then it'll return all the matching records. |
14,048,704 | Please assist me for complete this query
```
select *
from table1 a
join table2_n n
on a.PHONE_NO like '%'|| (select substr(mobile_no,2,9) as mobile_no from table2)
```
table 2 records exists in table1. so i need to get them all from this query | 2012/12/27 | [
"https://Stackoverflow.com/questions/14048704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1762112/"
] | You don't need to have a subquery, you can just join the data directly:
```
select a.*
from table1 a
join table2 n
on a.PHONE_NO like '%'|| substr(mobile_no,2,9);
```
Alternatively, you could write this using an `exists` subquery:
```
select *
from table1 a
where exists (select null
from ... | Use rownum=1 or where condition to return only one row from the inner sub query otherwise it would not work for multiple recods in table2. |
35,787,999 | It seems that 'waitForEnabled' does not work the same as Webdriver's elementToBeClickable. Could someone help with an API of it? | 2016/03/04 | [
"https://Stackoverflow.com/questions/35787999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
public static WebElement ElementToBeClickable(WebElement element)
{
try
{
if (element != null && element.isDisplayed() && element.isEnabled())
{
return element;
}
else
{
return null;
}
}
ca... | WebDriverWait wait = new WebDriverWait(driver, timeout);
element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); |
35,745,371 | I want to generate a random UUID in a Camel route. (Camel version 2.15.3)
I expect the UUID to be different for each run of the route, even if the route runs twice without restarting the Camel context. I am using java.util.UUID (Java 1.8.0) to generate a random UUID.
But the route generates the same UUID for each run... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35745371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199651/"
] | The configure method of the RouteBuilder that is overridden is only run once. The solution is to call a bean instead.
Bean code:
```
import java.util.UUID;
public class UuidGenerator {
public String getUuid(){
return UUID.randomUUID().toString();
}
}
```
Code in route:
```
import org.apache.camel.... | I think a more simple solution is to generate the UUID in a process like :
```
.process(exchange -> {
exchange.getIn().setHeader("uid", UidUtils.getUid());
})
``` |
35,745,371 | I want to generate a random UUID in a Camel route. (Camel version 2.15.3)
I expect the UUID to be different for each run of the route, even if the route runs twice without restarting the Camel context. I am using java.util.UUID (Java 1.8.0) to generate a random UUID.
But the route generates the same UUID for each run... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35745371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199651/"
] | The configure method of the RouteBuilder that is overridden is only run once. The solution is to call a bean instead.
Bean code:
```
import java.util.UUID;
public class UuidGenerator {
public String getUuid(){
return UUID.randomUUID().toString();
}
}
```
Code in route:
```
import org.apache.camel.... | If you are using log4j and apache camel together then this is a good solution too.
<http://www.boxjar.com/logging-a-unique-id-for-every-request-using-log4j/>
use below MDC class.
```
import org.apache.log4j.MDC;
``` |
35,745,371 | I want to generate a random UUID in a Camel route. (Camel version 2.15.3)
I expect the UUID to be different for each run of the route, even if the route runs twice without restarting the Camel context. I am using java.util.UUID (Java 1.8.0) to generate a random UUID.
But the route generates the same UUID for each run... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35745371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199651/"
] | I think a more simple solution is to generate the UUID in a process like :
```
.process(exchange -> {
exchange.getIn().setHeader("uid", UidUtils.getUid());
})
``` | If you are using log4j and apache camel together then this is a good solution too.
<http://www.boxjar.com/logging-a-unique-id-for-every-request-using-log4j/>
use below MDC class.
```
import org.apache.log4j.MDC;
``` |
628,551 | I have a file with the full path to an image on each line, all are jpg. I want to resize every image/line in the file to 1024px in width, while keeping the aspect ratio for the height. I simply want to overwrite the original file.
The main thing I'm having issue with is, I want to SHRINK only. I do not want to enlarge... | 2015/05/26 | [
"https://askubuntu.com/questions/628551",
"https://askubuntu.com",
"https://askubuntu.com/users/55007/"
] | This should do it:
```
#!/bin/bash
while IFS= read -r jpg
do
convert "$jpg""[1024x>]" "$jpg"
done < "$1"
```
Save the script above as `~/bin/shrink.sh`, make it executable (`chmod a+x ~/bin/shrink.sh`) and run it, giving the list of files as an argument:
```
shrink.sh /path/to/list
```
This is basically the ... | Try something like this:
```
#!/bin/bash
for p in "$@"
do
w=`identify "$p" | cut -f 3 -d ' ' | sed 's/x.*//'`
if [ $w -gt 1024 ]
then
convert -scale 1024x1024 "$p" "$p"
fi
done
```
Explanation:
* The "identify" command produces all sorts of info about the image. The third field is the size,... |
17,914,512 | I'm setting up a PHP script that connects to the 4D Database on my local system.
However, I keep getting:
```
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'tester'' in /Applications/MAMP/htdocs/4d/index.php:8 Stack trace: #0 /App... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17914512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806070/"
] | Subclassing `list`
------------------
If you insist, you can subclass `list`:
```
class ListContainer(list):
def play(self, *args, **kwargs):
for item in self:
item.play(*args, **kwargs)
def close(self, *args, **kwargs):
for item in self:
item.close(*args, **kwargs)
``... | [`map()`](http://docs.python.org/2/library/functions.html#map) should do the trick
Try this:
```
map(MyListClass.play,my_list)
```
`map()` takes two arguments, a function and an iterable, as shown above. |
17,914,512 | I'm setting up a PHP script that connects to the 4D Database on my local system.
However, I keep getting:
```
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'tester'' in /Applications/MAMP/htdocs/4d/index.php:8 Stack trace: #0 /App... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17914512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806070/"
] | [`map()`](http://docs.python.org/2/library/functions.html#map) should do the trick
Try this:
```
map(MyListClass.play,my_list)
```
`map()` takes two arguments, a function and an iterable, as shown above. | another variant:
```
playme = lambda x: x.play()
map(playme, list_goes_here)
``` |
17,914,512 | I'm setting up a PHP script that connects to the 4D Database on my local system.
However, I keep getting:
```
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'tester'' in /Applications/MAMP/htdocs/4d/index.php:8 Stack trace: #0 /App... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17914512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806070/"
] | Subclassing `list`
------------------
If you insist, you can subclass `list`:
```
class ListContainer(list):
def play(self, *args, **kwargs):
for item in self:
item.play(*args, **kwargs)
def close(self, *args, **kwargs):
for item in self:
item.close(*args, **kwargs)
``... | I am afraid you can not do this on list because they do not have the attributes. If you do want to, you have to subclass it.
```
>>> class MyList(list):
... def play(self):
... for each in self:
... each.play()
... def close(self):
... for each in self:
... ... |
17,914,512 | I'm setting up a PHP script that connects to the 4D Database on my local system.
However, I keep getting:
```
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'tester'' in /Applications/MAMP/htdocs/4d/index.php:8 Stack trace: #0 /App... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17914512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806070/"
] | I am afraid you can not do this on list because they do not have the attributes. If you do want to, you have to subclass it.
```
>>> class MyList(list):
... def play(self):
... for each in self:
... each.play()
... def close(self):
... for each in self:
... ... | another variant:
```
playme = lambda x: x.play()
map(playme, list_goes_here)
``` |
17,914,512 | I'm setting up a PHP script that connects to the 4D Database on my local system.
However, I keep getting:
```
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'tester'' in /Applications/MAMP/htdocs/4d/index.php:8 Stack trace: #0 /App... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17914512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/806070/"
] | Subclassing `list`
------------------
If you insist, you can subclass `list`:
```
class ListContainer(list):
def play(self, *args, **kwargs):
for item in self:
item.play(*args, **kwargs)
def close(self, *args, **kwargs):
for item in self:
item.close(*args, **kwargs)
``... | another variant:
```
playme = lambda x: x.play()
map(playme, list_goes_here)
``` |
35,754,699 | I've been studying angular for three days now, and I came across a little challenge but I'm still clueless how to do solve it with Angular.js, I've searched for it, but it's really hard to explain what I'm trying to accomplish.
I want to detect which checkboxes were checked and then show the number input into the inpu... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35754699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4579351/"
] | If I understand you correctly, you want to hide those numbers in the `<div id="data">` that don't have a checked checkbox. For this, your checkboxes need an ng-model as well:
```html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<tit... | The below code is just to give you an idea of how it works. You can extend this idea. It's the `ng-if` that you have to use. `ng-if` documentation [here](https://docs.angularjs.org/api/ng/directive/ngIf).
```
<div id="form">
<input type="checkbox" ng-model="check1" />
<label>Data:</label>
<input type="number" ng-model... |
35,754,699 | I've been studying angular for three days now, and I came across a little challenge but I'm still clueless how to do solve it with Angular.js, I've searched for it, but it's really hard to explain what I'm trying to accomplish.
I want to detect which checkboxes were checked and then show the number input into the inpu... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35754699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4579351/"
] | The below code is just to give you an idea of how it works. You can extend this idea. It's the `ng-if` that you have to use. `ng-if` documentation [here](https://docs.angularjs.org/api/ng/directive/ngIf).
```
<div id="form">
<input type="checkbox" ng-model="check1" />
<label>Data:</label>
<input type="number" ng-model... | There are multiple ways to deal with this. The basic idea is you have to provide the link between check box and the input field. It needs a way to show/hide input field based on checked item.
[Check this plunk here](https://plnkr.co/edit/9qGRvDZePeGCTXXMTPX9?p=preview)
```
<body ng-app="checkboxExample">
<script>... |
35,754,699 | I've been studying angular for three days now, and I came across a little challenge but I'm still clueless how to do solve it with Angular.js, I've searched for it, but it's really hard to explain what I'm trying to accomplish.
I want to detect which checkboxes were checked and then show the number input into the inpu... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35754699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4579351/"
] | If I understand you correctly, you want to hide those numbers in the `<div id="data">` that don't have a checked checkbox. For this, your checkboxes need an ng-model as well:
```html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<tit... | There are multiple ways to deal with this. The basic idea is you have to provide the link between check box and the input field. It needs a way to show/hide input field based on checked item.
[Check this plunk here](https://plnkr.co/edit/9qGRvDZePeGCTXXMTPX9?p=preview)
```
<body ng-app="checkboxExample">
<script>... |
1,224,833 | I'm writing a basic GUI application that essentially invokes other processes given some parameters, while the output of those applications is displayed to the user via a richtext box in real-time. So basically I have a seperate process thread running the child processes.
Most of the processes work fine on that thread,... | 2009/08/03 | [
"https://Stackoverflow.com/questions/1224833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13115/"
] | I believe the actual issue doesn't have to do with threads, but rather XDiscBld wants to write to a console window that doesn't exist. This is because I'm starting the process like this.
```
process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.RedirectStandardOutput = true;
process.Star... | What's happening here is that the handle you are using from that process is invalid. There are a couple of reasons this could occur, most common is that the process has already exited thus invalidating the handle. |
1,224,833 | I'm writing a basic GUI application that essentially invokes other processes given some parameters, while the output of those applications is displayed to the user via a richtext box in real-time. So basically I have a seperate process thread running the child processes.
Most of the processes work fine on that thread,... | 2009/08/03 | [
"https://Stackoverflow.com/questions/1224833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13115/"
] | You must set process.StartInfo.UseShellExecute to **false** if you redirect input/output; | What's happening here is that the handle you are using from that process is invalid. There are a couple of reasons this could occur, most common is that the process has already exited thus invalidating the handle. |
1,224,833 | I'm writing a basic GUI application that essentially invokes other processes given some parameters, while the output of those applications is displayed to the user via a richtext box in real-time. So basically I have a seperate process thread running the child processes.
Most of the processes work fine on that thread,... | 2009/08/03 | [
"https://Stackoverflow.com/questions/1224833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13115/"
] | I believe the actual issue doesn't have to do with threads, but rather XDiscBld wants to write to a console window that doesn't exist. This is because I'm starting the process like this.
```
process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.RedirectStandardOutput = true;
process.Star... | You must set process.StartInfo.UseShellExecute to **false** if you redirect input/output; |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | Try
```
android:capitalize="characters"
android:inputType="textCapCharacters"
```
This working fine in my case. | Take a look at <http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputMethod>
You'll probably want
```
android:inputMethod="textCapCharacters"
``` |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | Try
```
android:capitalize="characters"
android:inputType="textCapCharacters"
```
This working fine in my case. | Try this -
```
android:inputType="textCapCharacters"
```
You can even do this in your java code
```
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
``` |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | Try
```
android:capitalize="characters"
android:inputType="textCapCharacters"
```
This working fine in my case. | ```
android:inputType="textCapCharacters"
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
```
These two might be useful |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | Try
```
android:capitalize="characters"
android:inputType="textCapCharacters"
```
This working fine in my case. | You can also set it programmatically and it is for api level 14 and above only. below it you have to manually implement it.
```
editText.setInputType(android.text.InputType.TYPE_CLASS_TEXT
+ android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
```
I found your problem. `android:textAllCaps`is f... |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | Try
```
android:capitalize="characters"
android:inputType="textCapCharacters"
```
This working fine in my case. | You can wite this in java file.
```
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
```
or you can use this is xml
```
android:inputType="textCapCharacters"
``` |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | Take a look at <http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputMethod>
You'll probably want
```
android:inputMethod="textCapCharacters"
``` | You can also set it programmatically and it is for api level 14 and above only. below it you have to manually implement it.
```
editText.setInputType(android.text.InputType.TYPE_CLASS_TEXT
+ android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
```
I found your problem. `android:textAllCaps`is f... |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | Try this -
```
android:inputType="textCapCharacters"
```
You can even do this in your java code
```
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
``` | You can also set it programmatically and it is for api level 14 and above only. below it you have to manually implement it.
```
editText.setInputType(android.text.InputType.TYPE_CLASS_TEXT
+ android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
```
I found your problem. `android:textAllCaps`is f... |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | ```
android:inputType="textCapCharacters"
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
```
These two might be useful | You can also set it programmatically and it is for api level 14 and above only. below it you have to manually implement it.
```
editText.setInputType(android.text.InputType.TYPE_CLASS_TEXT
+ android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
```
I found your problem. `android:textAllCaps`is f... |
30,296,370 | In my application i have an edittext in which a user can Alphanumeric string. Now the point is i want that whatever the aplhanumeric or alphabetic string he types that should be converted into the capital case.
For ex: if the edittext input is like:
>
> sdhq8273dyp3
>
>
>
In editext when user types it should be c... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775139/"
] | You can wite this in java file.
```
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
```
or you can use this is xml
```
android:inputType="textCapCharacters"
``` | You can also set it programmatically and it is for api level 14 and above only. below it you have to manually implement it.
```
editText.setInputType(android.text.InputType.TYPE_CLASS_TEXT
+ android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
```
I found your problem. `android:textAllCaps`is f... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | This is a typical application of DFS (Depth First Search) algorithm performed on graphs. Try read this [dfs](http://en.wikipedia.org/wiki/Depth-first_search)
Complexity of this algorithm is O(|V|+|E|), where V - number of vertices and E - number of edges | Here's my stab at an answer. Python.
```
groups = []
infile = open("so2.txt")
for line in infile.readlines():
newset = set(line.split())
matchgroups = []
excludegroups = []
for group in groups:
if len(newset & group):
newset |= group
else:
excludegroups.append(group)
groups = excludegr... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | Here is a sample Perl solution that works on the original data set:
```
1 2
3 4
5 9
2 6
3 7
Group 1: 1 2 6
Group 2: 3 4 7
Group 3: 5 9
```
On the big data set, it produces the output:
```
Group 1: 1 27 134 137 161 171 275 309 413 464 627 684 744
Group 2: 2 135 398 437 548 594 717 738 783 798 912
Group 3: 5 74 223
... | This actually is a very classic [Union-find](http://en.wikipedia.org/wiki/Union-Find).
If M is the number of edges, N the number of nodes, the time complexity is **O(M \* α(M))** which is a **O(M)** for all practical M and the space complexity if **O(N)** with N the number of nodes.
The algorithm is online and does n... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | Here's a slightly different version in Python, which builds a graph containing the edges specified, then converts that to a list of connected subgraphs.
I might want to use this later so I wrote it as a general-purpose version that doesn't do input from a file or output with print statements, just converting data str... | Here's my stab at an answer. Python.
```
groups = []
infile = open("so2.txt")
for line in infile.readlines():
newset = set(line.split())
matchgroups = []
excludegroups = []
for group in groups:
if len(newset & group):
newset |= group
else:
excludegroups.append(group)
groups = excludegr... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | Here's a slightly different version in Python, which builds a graph containing the edges specified, then converts that to a list of connected subgraphs.
I might want to use this later so I wrote it as a general-purpose version that doesn't do input from a file or output with print statements, just converting data str... | My version in PHP actually is only a refactoring of your code. It fixes one issue in your code (you have one group too much) and is implemented slightly more efficient (Exec time drops from 0.0035 to 0.0020 on slow machine):
```
$group = 0;
$map = array();
do {
list($a, $b) = explode(' ', fgets($file));
$a = ... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | This is a typical application of DFS (Depth First Search) algorithm performed on graphs. Try read this [dfs](http://en.wikipedia.org/wiki/Depth-first_search)
Complexity of this algorithm is O(|V|+|E|), where V - number of vertices and E - number of edges | After not being completely satisfied with my first 2 attempts at this, and some research, I came across [this recipe](http://code.activestate.com/recipes/387776-grouping-objects-into-disjoint-sets/) for disjoint sets in Python, with Raymond Hettinger's blessing and input. (Raymond Hettinger is a long-time very active P... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | Here is a sample Perl solution that works on the original data set:
```
1 2
3 4
5 9
2 6
3 7
Group 1: 1 2 6
Group 2: 3 4 7
Group 3: 5 9
```
On the big data set, it produces the output:
```
Group 1: 1 27 134 137 161 171 275 309 413 464 627 684 744
Group 2: 2 135 398 437 548 594 717 738 783 798 912
Group 3: 5 74 223
... | After not being completely satisfied with my first 2 attempts at this, and some research, I came across [this recipe](http://code.activestate.com/recipes/387776-grouping-objects-into-disjoint-sets/) for disjoint sets in Python, with Raymond Hettinger's blessing and input. (Raymond Hettinger is a long-time very active P... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | Here's a slightly different version in Python, which builds a graph containing the edges specified, then converts that to a list of connected subgraphs.
I might want to use this later so I wrote it as a general-purpose version that doesn't do input from a file or output with print statements, just converting data str... | This actually is a very classic [Union-find](http://en.wikipedia.org/wiki/Union-Find).
If M is the number of edges, N the number of nodes, the time complexity is **O(M \* α(M))** which is a **O(M)** for all practical M and the space complexity if **O(N)** with N the number of nodes.
The algorithm is online and does n... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | I've managed O(n log n).
Here is a (somewhat intense) C++ implementation:
```
#include <boost/pending/disjoint_sets.hpp>
#include <boost/property_map/property_map.hpp>
#include <map>
#include <set>
#include <iostream>
typedef std::map<int, int> rank_t;
typedef std::map<int, int> parent_t;
typedef boost::associativ... | If the input is sorted, like your huge test set, you can do it in Θ(input) time and Ο(input) space. If the input is unsorted, you could modify this fairly easily and get Ο(input log input) time and Θ(input) space.
This is very quick because :
* it stores a hash map from a node to its "ultimate owner" (which is the no... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | Ok so I got something working in parallel to the other solution posted by @Jonathan (first of all, many thanks for your time). My solution looks deceptively simple but would love some suggestions on whether this is correct (maybe I'm missing a corner case somewhere?) because it seems to produce the output I wanted but ... | After not being completely satisfied with my first 2 attempts at this, and some research, I came across [this recipe](http://code.activestate.com/recipes/387776-grouping-objects-into-disjoint-sets/) for disjoint sets in Python, with Raymond Hettinger's blessing and input. (Raymond Hettinger is a long-time very active P... |
3,848,239 | I have some data like this:
```
1 2
3 4
5 9
2 6
3 7
```
and am looking for an output like this (group-id and the members of that group):
```
1: 1 2 6
2: 3 4 7
3: 5 9
```
First row because 1 is "connected" to 2 and 2 is connected to 6.
Second row because 3 is connected to 4 and 3 is connected to 7
This looked to ... | 2010/10/03 | [
"https://Stackoverflow.com/questions/3848239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184046/"
] | I've managed O(n log n).
Here is a (somewhat intense) C++ implementation:
```
#include <boost/pending/disjoint_sets.hpp>
#include <boost/property_map/property_map.hpp>
#include <map>
#include <set>
#include <iostream>
typedef std::map<int, int> rank_t;
typedef std::map<int, int> parent_t;
typedef boost::associativ... | Here's a slightly different version in Python, which builds a graph containing the edges specified, then converts that to a list of connected subgraphs.
I might want to use this later so I wrote it as a general-purpose version that doesn't do input from a file or output with print statements, just converting data str... |
62,428,084 | I have a very simple question, I've been looking around but I can't find the solution.
Take that code :
```js
class Foo {
bar = () => {
return 'string'
}
baz = async() => {
return 'promise'
}
}
```
I want to know if a specific method of a class is async or not.
```js
isAsync(Foo, 'bar') // fal... | 2020/06/17 | [
"https://Stackoverflow.com/questions/62428084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13013414/"
] | Instead of all the headaches, I added the same install command in `docker` file also. It now works fine.
```
from alpine/git as clone
workdir /app
run git clone --single-branch -b master https://@github.com/xxxx
from maven:3.5-jdk-8-alpine
workdir /app
copy --from=0 /app/idot/idot-backend /app
run mvn install:instal... | I used same approach, Its works for me. You can see here..
```
<dependencies>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.4.2-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven-rep... |
3,188,358 | I have a suspicion that there might be a race condition in a certain C++ multithreading situation involving virtual method calls in a vtable dynamic dispatching implementation (for which a vtable pointer is stored as a hidden member in the object with virtual methods). I would like to confirm whether or not this is act... | 2010/07/06 | [
"https://Stackoverflow.com/questions/3188358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383246/"
] | `StrictHostKeyChecking` is an option for the `ssh` program.
You can use the [Net::SSH::Expect](http://search.cpan.org/perldoc/Net::SSH::Expect) option `ssh_option` in the constructor:
```
my $ssh = Net::SSH::Expect->new(
# ...
ssh_option => '-o StrictHostKeyChecking=no',
# ...
);
```
Hat tip [salva](ht... | >
> StrictHostKeyChecking is an option for
> the ssh program. AFAIK, it cannot be
> set on the command line for ssh
>
>
>
yes, it can!
Use...
```
$ ssh -o StrictHostKeyChecking=no ...
``` |
3,188,358 | I have a suspicion that there might be a race condition in a certain C++ multithreading situation involving virtual method calls in a vtable dynamic dispatching implementation (for which a vtable pointer is stored as a hidden member in the object with virtual methods). I would like to confirm whether or not this is act... | 2010/07/06 | [
"https://Stackoverflow.com/questions/3188358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383246/"
] | `StrictHostKeyChecking` is an option for the `ssh` program.
You can use the [Net::SSH::Expect](http://search.cpan.org/perldoc/Net::SSH::Expect) option `ssh_option` in the constructor:
```
my $ssh = Net::SSH::Expect->new(
# ...
ssh_option => '-o StrictHostKeyChecking=no',
# ...
);
```
Hat tip [salva](ht... | ssh -o "StrictHostKeyChecking=no" -o ConnectTimeout=1 |
3,188,358 | I have a suspicion that there might be a race condition in a certain C++ multithreading situation involving virtual method calls in a vtable dynamic dispatching implementation (for which a vtable pointer is stored as a hidden member in the object with virtual methods). I would like to confirm whether or not this is act... | 2010/07/06 | [
"https://Stackoverflow.com/questions/3188358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383246/"
] | >
> StrictHostKeyChecking is an option for
> the ssh program. AFAIK, it cannot be
> set on the command line for ssh
>
>
>
yes, it can!
Use...
```
$ ssh -o StrictHostKeyChecking=no ...
``` | ssh -o "StrictHostKeyChecking=no" -o ConnectTimeout=1 |
2,446,203 | I have a Window handle Picker and it says my handle is 0094167C.
When I declare the variable in c# the letter in this code gives an error.
How to declare?
public const IntPtr WinHandle = 0094167C; | 2010/03/15 | [
"https://Stackoverflow.com/questions/2446203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133584/"
] | You know that the handle will typically change with each application and/or system start? This means your constant is subject to failure anyway.
If, however, you really want to assign a constant other than zero to an `IntPtr` (which would be `IntPtr.Zero`), the documentation states that there are constructors that tak... | As OregonGhost points out you probably don't want to do that for a windows handle. However, for a IntPtr in general, what you can do is this static readonly fields:
```
static readonly IntPtr TenK = new IntPtr(1024 * 10000);
``` |
2,446,203 | I have a Window handle Picker and it says my handle is 0094167C.
When I declare the variable in c# the letter in this code gives an error.
How to declare?
public const IntPtr WinHandle = 0094167C; | 2010/03/15 | [
"https://Stackoverflow.com/questions/2446203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133584/"
] | You know that the handle will typically change with each application and/or system start? This means your constant is subject to failure anyway.
If, however, you really want to assign a constant other than zero to an `IntPtr` (which would be `IntPtr.Zero`), the documentation states that there are constructors that tak... | I'd like to add to AgnosticOracle's answer.
In addition to constant-like static-readonly IntPtr/UIntPtr variables, you can use `nint` and `nuint` which are backed by IntPtr and UIntPtr, respectively.
These types can have integer and unsigned integer values assigned to them and can also be defined as constants.
<http... |
53,223,574 | My set capabilities are
```
DesiredCapabilities d= new DesiredCapabilities();
d.setCapability(MobileCapabilityType.DEVICE_NAME,"iPhone 8 Plus");
d.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS 12.1");
d.setCapability(MobileCapabilityType.AUTOMATION_NAME,AutomationName.IOS_XCUI_TEST);
d.setCapability(MobileCap... | 2018/11/09 | [
"https://Stackoverflow.com/questions/53223574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9144470/"
] | Always check the path using command line:
Navigate to the specific folder your .app file is in and run command as
```
ls
```
This should come up listing your .app file , no run command
```
pwd
```
It will return the correct path where you are at present.copy the same and put it in the DesiredCapability
```
Fil... | I Used a Driver wait Function and it Resolved the Issue
```
URL url = new URL ("http://127.0.0.1:4723/wd/hub");
Driver = new AppiumDriver<MobileElement>(url,DC);
wait = new WebDriverWait(Driver, 10);
System.out.println("Calculator Started::");
```
and Yes, You can WebDriver wait in AppiumDriver Test... |
2,298,112 | Is working fine?, i found instruction in Adobe site confusing and i am not confident at all since it says that only works with eclipse 3.3 (actual version should be 3.5 or close)
There is any special instructions to do it well.
Thanks! | 2010/02/19 | [
"https://Stackoverflow.com/questions/2298112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/275156/"
] | You can create your own custom Authorize attribute, something like "AuthorizeAllExceptAdmin." Within that class you would simply need to check whether or not the current user was an admin, and if they were reject it, otherwise accept it.
Here's a good [tutorial](http://davidhayden.com/blog/dave/archive/2009/04/09/Cust... | Besides creating a custom AuthorizeAttribute, suggested by manu, you could use PrincipalPermission, with a Deny-SecurityAction:
```
[PrincipalPermission(SecurityAction.Deny, Role="Administrator")]
``` |
2,298,112 | Is working fine?, i found instruction in Adobe site confusing and i am not confident at all since it says that only works with eclipse 3.3 (actual version should be 3.5 or close)
There is any special instructions to do it well.
Thanks! | 2010/02/19 | [
"https://Stackoverflow.com/questions/2298112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/275156/"
] | You can create your own custom Authorize attribute, something like "AuthorizeAllExceptAdmin." Within that class you would simply need to check whether or not the current user was an admin, and if they were reject it, otherwise accept it.
Here's a good [tutorial](http://davidhayden.com/blog/dave/archive/2009/04/09/Cust... | In my app I don't use roles so I have to query the database to determine whether the user has access or not. The benefits of the code below is that you can redirect the user to a certain action very easily. I explained the code in my blog post at <http://blog.athe.la/2009/12/implementing-permission-via-windows-authenti... |
2,298,112 | Is working fine?, i found instruction in Adobe site confusing and i am not confident at all since it says that only works with eclipse 3.3 (actual version should be 3.5 or close)
There is any special instructions to do it well.
Thanks! | 2010/02/19 | [
"https://Stackoverflow.com/questions/2298112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/275156/"
] | Besides creating a custom AuthorizeAttribute, suggested by manu, you could use PrincipalPermission, with a Deny-SecurityAction:
```
[PrincipalPermission(SecurityAction.Deny, Role="Administrator")]
``` | In my app I don't use roles so I have to query the database to determine whether the user has access or not. The benefits of the code below is that you can redirect the user to a certain action very easily. I explained the code in my blog post at <http://blog.athe.la/2009/12/implementing-permission-via-windows-authenti... |
29,475,047 | I need to run some code when an App is launched and when it completely exits (is destroyed). I am using onCreate and onDestroy but unfortunately screen orientation changes destroys and recreates the activity. | 2015/04/06 | [
"https://Stackoverflow.com/questions/29475047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1054563/"
] | Take a look at Android Application <http://developer.android.com/reference/android/app/Application.html>
You can know when Application created (Application.onCreated)
BUT you can't know when Application destroyed. Application.onTerminate() is only for use in emulated process environments. | Every time the app launched the `onCreate` method of your **launcher activity** is called. So you have to put the desired code in `onCreate` method of the Launcher activity.
And to detect whether your app is destroyed or not you can `override` `onDestroy` method ( just like adding the `onCreate` ) from **Override unim... |
29,475,047 | I need to run some code when an App is launched and when it completely exits (is destroyed). I am using onCreate and onDestroy but unfortunately screen orientation changes destroys and recreates the activity. | 2015/04/06 | [
"https://Stackoverflow.com/questions/29475047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1054563/"
] | Take a look at Android Application <http://developer.android.com/reference/android/app/Application.html>
You can know when Application created (Application.onCreated)
BUT you can't know when Application destroyed. Application.onTerminate() is only for use in emulated process environments. | You could try this, if your code can happen in the background (won't work if you need something to happen on the UI Thread):
Have your activity hold a reference to a thread you extended, let's call it MyThread operator.
In onCreate, do that:
```
if(operator==null){
operator = new MyThread();
operator.start()... |
34,005,254 | How to set up a variable on the root directory for the url link in ColdFusion?
I set up the variable on the root directory for the url link, appweb\instance.cfm:
```
<CFSCRIPT>
...
...
Application.MainLink = "http://www.ucdavis.edu/index.html";
</CFSCRIPT>
```
I have a file under appweb/costsharing/footer... | 2015/11/30 | [
"https://Stackoverflow.com/questions/34005254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792790/"
] | This is it, the query logic is as simple as it gets, the performance better than inner joins:
```
select date, sum(sales) - coalesce(lag(sum(sales), 1) over (order by date), 0)
from my_sales
group by date
order by date
```
Use window function `lag`. Play with it: <http://sqlfiddle.com/#!6/bebab/8> and read about it:... | I don't really see much of a way around a self join. Here is how it would work:
```
select a.date
, a.item
, sum(a.sales) - sum(b.sales) as DailyDelta
from table a
join table b on a.product = b.product
and b.date = dateadd(day, -1, a.date)
group by a.date
, a.item
```
Not great performance wise but it wi... |
34,005,254 | How to set up a variable on the root directory for the url link in ColdFusion?
I set up the variable on the root directory for the url link, appweb\instance.cfm:
```
<CFSCRIPT>
...
...
Application.MainLink = "http://www.ucdavis.edu/index.html";
</CFSCRIPT>
```
I have a file under appweb/costsharing/footer... | 2015/11/30 | [
"https://Stackoverflow.com/questions/34005254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792790/"
] | I don't really see much of a way around a self join. Here is how it would work:
```
select a.date
, a.item
, sum(a.sales) - sum(b.sales) as DailyDelta
from table a
join table b on a.product = b.product
and b.date = dateadd(day, -1, a.date)
group by a.date
, a.item
```
Not great performance wise but it wi... | Try this..
SELECT date,
```
( sum(sales) - LAG(sum(sales),1,0) over (order by sales) ) as dailyDelta
```
FROM Table
group by date
order by date; |
34,005,254 | How to set up a variable on the root directory for the url link in ColdFusion?
I set up the variable on the root directory for the url link, appweb\instance.cfm:
```
<CFSCRIPT>
...
...
Application.MainLink = "http://www.ucdavis.edu/index.html";
</CFSCRIPT>
```
I have a file under appweb/costsharing/footer... | 2015/11/30 | [
"https://Stackoverflow.com/questions/34005254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792790/"
] | This is it, the query logic is as simple as it gets, the performance better than inner joins:
```
select date, sum(sales) - coalesce(lag(sum(sales), 1) over (order by date), 0)
from my_sales
group by date
order by date
```
Use window function `lag`. Play with it: <http://sqlfiddle.com/#!6/bebab/8> and read about it:... | The following query is based on MySQL, but you can tweak it to make it work for SQL server. I hope SQL Server will also support the same
```
select o.date, t.tsales - sum(sales) delta from test o, (select date, sum(sales) tsales from test group by date) t
where o.date = t.date -1 group by o.date
```
For the above q... |
34,005,254 | How to set up a variable on the root directory for the url link in ColdFusion?
I set up the variable on the root directory for the url link, appweb\instance.cfm:
```
<CFSCRIPT>
...
...
Application.MainLink = "http://www.ucdavis.edu/index.html";
</CFSCRIPT>
```
I have a file under appweb/costsharing/footer... | 2015/11/30 | [
"https://Stackoverflow.com/questions/34005254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792790/"
] | This is it, the query logic is as simple as it gets, the performance better than inner joins:
```
select date, sum(sales) - coalesce(lag(sum(sales), 1) over (order by date), 0)
from my_sales
group by date
order by date
```
Use window function `lag`. Play with it: <http://sqlfiddle.com/#!6/bebab/8> and read about it:... | use a self join
```
declare @t table (item varchar(10), [date] date,country char(2), sales int)
insert into @t (item, [date],country, sales) values
('motorola','2015-01-01','US',10),
('motorola','2015-01-01','UK',20),
('motorola','2015-01-02','US',40),
('motorola','2015-01-02','UK',80),
('motorola','2015-01-03','US... |
34,005,254 | How to set up a variable on the root directory for the url link in ColdFusion?
I set up the variable on the root directory for the url link, appweb\instance.cfm:
```
<CFSCRIPT>
...
...
Application.MainLink = "http://www.ucdavis.edu/index.html";
</CFSCRIPT>
```
I have a file under appweb/costsharing/footer... | 2015/11/30 | [
"https://Stackoverflow.com/questions/34005254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792790/"
] | This is it, the query logic is as simple as it gets, the performance better than inner joins:
```
select date, sum(sales) - coalesce(lag(sum(sales), 1) over (order by date), 0)
from my_sales
group by date
order by date
```
Use window function `lag`. Play with it: <http://sqlfiddle.com/#!6/bebab/8> and read about it:... | Try this..
SELECT date,
```
( sum(sales) - LAG(sum(sales),1,0) over (order by sales) ) as dailyDelta
```
FROM Table
group by date
order by date; |
34,005,254 | How to set up a variable on the root directory for the url link in ColdFusion?
I set up the variable on the root directory for the url link, appweb\instance.cfm:
```
<CFSCRIPT>
...
...
Application.MainLink = "http://www.ucdavis.edu/index.html";
</CFSCRIPT>
```
I have a file under appweb/costsharing/footer... | 2015/11/30 | [
"https://Stackoverflow.com/questions/34005254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792790/"
] | The following query is based on MySQL, but you can tweak it to make it work for SQL server. I hope SQL Server will also support the same
```
select o.date, t.tsales - sum(sales) delta from test o, (select date, sum(sales) tsales from test group by date) t
where o.date = t.date -1 group by o.date
```
For the above q... | Try this..
SELECT date,
```
( sum(sales) - LAG(sum(sales),1,0) over (order by sales) ) as dailyDelta
```
FROM Table
group by date
order by date; |
34,005,254 | How to set up a variable on the root directory for the url link in ColdFusion?
I set up the variable on the root directory for the url link, appweb\instance.cfm:
```
<CFSCRIPT>
...
...
Application.MainLink = "http://www.ucdavis.edu/index.html";
</CFSCRIPT>
```
I have a file under appweb/costsharing/footer... | 2015/11/30 | [
"https://Stackoverflow.com/questions/34005254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792790/"
] | use a self join
```
declare @t table (item varchar(10), [date] date,country char(2), sales int)
insert into @t (item, [date],country, sales) values
('motorola','2015-01-01','US',10),
('motorola','2015-01-01','UK',20),
('motorola','2015-01-02','US',40),
('motorola','2015-01-02','UK',80),
('motorola','2015-01-03','US... | Try this..
SELECT date,
```
( sum(sales) - LAG(sum(sales),1,0) over (order by sales) ) as dailyDelta
```
FROM Table
group by date
order by date; |
14,872,400 | ```
<li><a href="home.html"> Home </a> </li>
<li> <a href="contact.html">Contact </a></li>
$('li').mouseenter( function() {
$(this).attr('a').css("color", "red");
});
```
fails. I am trying to understand how to reach that a within that 'li'. (not any 'li a') | 2013/02/14 | [
"https://Stackoverflow.com/questions/14872400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1164501/"
] | Use [**find()**](http://api.jquery.com/find/) instead of [attr()](http://api.jquery.com/attr/) as `a` is element not the attribute of current element.
```
$('li').mouseenter( function() {
$(this).find('a').css("color", "red");
});
``` | You can use `children` or `find` for this
```
$('li').mouseenter( function() {
$(this).children('a').css("color", "red");
});
```
**Note:** `Children` only looks at the immediate children of the node, while `find` traverses the entire DOM below the node, so children should be faster given equivalent implemen... |
14,872,400 | ```
<li><a href="home.html"> Home </a> </li>
<li> <a href="contact.html">Contact </a></li>
$('li').mouseenter( function() {
$(this).attr('a').css("color", "red");
});
```
fails. I am trying to understand how to reach that a within that 'li'. (not any 'li a') | 2013/02/14 | [
"https://Stackoverflow.com/questions/14872400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1164501/"
] | Use [**find()**](http://api.jquery.com/find/) instead of [attr()](http://api.jquery.com/attr/) as `a` is element not the attribute of current element.
```
$('li').mouseenter( function() {
$(this).find('a').css("color", "red");
});
``` | You can do this way too:
```
$('li').mouseenter( function() {
$('a', this).css("color", "red");
});
``` |
14,872,400 | ```
<li><a href="home.html"> Home </a> </li>
<li> <a href="contact.html">Contact </a></li>
$('li').mouseenter( function() {
$(this).attr('a').css("color", "red");
});
```
fails. I am trying to understand how to reach that a within that 'li'. (not any 'li a') | 2013/02/14 | [
"https://Stackoverflow.com/questions/14872400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1164501/"
] | `a` is an element not an attribute, you can use `find` method:
```
$('li').mouseenter(function() {
$(this).find('a').css("color", "red");
// or using $(selector, context):
// $('a', this).css("color", "red");
});
```
However JavaScript doesn't work like CSS, you should change the color on `mouseleave`... | You can use `children` or `find` for this
```
$('li').mouseenter( function() {
$(this).children('a').css("color", "red");
});
```
**Note:** `Children` only looks at the immediate children of the node, while `find` traverses the entire DOM below the node, so children should be faster given equivalent implemen... |
14,872,400 | ```
<li><a href="home.html"> Home </a> </li>
<li> <a href="contact.html">Contact </a></li>
$('li').mouseenter( function() {
$(this).attr('a').css("color", "red");
});
```
fails. I am trying to understand how to reach that a within that 'li'. (not any 'li a') | 2013/02/14 | [
"https://Stackoverflow.com/questions/14872400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1164501/"
] | `a` is an element not an attribute, you can use `find` method:
```
$('li').mouseenter(function() {
$(this).find('a').css("color", "red");
// or using $(selector, context):
// $('a', this).css("color", "red");
});
```
However JavaScript doesn't work like CSS, you should change the color on `mouseleave`... | You can do this way too:
```
$('li').mouseenter( function() {
$('a', this).css("color", "red");
});
``` |
14,872,400 | ```
<li><a href="home.html"> Home </a> </li>
<li> <a href="contact.html">Contact </a></li>
$('li').mouseenter( function() {
$(this).attr('a').css("color", "red");
});
```
fails. I am trying to understand how to reach that a within that 'li'. (not any 'li a') | 2013/02/14 | [
"https://Stackoverflow.com/questions/14872400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1164501/"
] | You can use `children` or `find` for this
```
$('li').mouseenter( function() {
$(this).children('a').css("color", "red");
});
```
**Note:** `Children` only looks at the immediate children of the node, while `find` traverses the entire DOM below the node, so children should be faster given equivalent implemen... | You can do this way too:
```
$('li').mouseenter( function() {
$('a', this).css("color", "red");
});
``` |
93,576 | I'm a newbie when it comes to electronics, so please forgive any glaring mistakes!
I am trying to create a simple circuit that sends an audible frequency/tone to a line-in/mic input when the mercury switch is active. Could anyone help me to identify what component I would need in the circuit to generate and send the f... | 2013/12/13 | [
"https://electronics.stackexchange.com/questions/93576",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34087/"
] | You can use a [555](http://en.wikipedia.org/wiki/555_timer_IC) timer IC to create a tone generator
Here is a page that shows such a [circuit](http://circuit-diagram.hqew.net/Basic-Oscillator-%28Tone-Generator%29-At-1$2e8-KHz-$2dalarm-circuits_14287.html) but you can find many more from google.
![enter image descripti... | Having the Audible Source, connected to the switch , and then to the mic input should do it.
Depending on number of wires in the Audio source(Say 2),you might need 2 switches to do this. |
35,620,124 | I need to create a multi select form field in October Cms backend form (fields.yaml). I applied the following method
select\_field:
label: Sample
type: dropdown
attributes: {multiple:'multiple'}
Options to this field will be invoked from the model
Everything is working good but when i submit ... | 2016/02/25 | [
"https://Stackoverflow.com/questions/35620124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5652672/"
] | you can't use a dropdown field with mutiple value because it was made to handle single value. as the checkbox and radio this is why there are checkboxList(i guess).
But i found a solution.
Use a partial as field type in fields.yaml instead of dropdown
<https://octobercms.com/docs/backend/forms#field-partial>
Create... | Also daftspunk has propose a workaround: <https://github.com/octobercms/october/issues/1829#issuecomment-193018469> |
35,620,124 | I need to create a multi select form field in October Cms backend form (fields.yaml). I applied the following method
select\_field:
label: Sample
type: dropdown
attributes: {multiple:'multiple'}
Options to this field will be invoked from the model
Everything is working good but when i submit ... | 2016/02/25 | [
"https://Stackoverflow.com/questions/35620124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5652672/"
] | you can't use a dropdown field with mutiple value because it was made to handle single value. as the checkbox and radio this is why there are checkboxList(i guess).
But i found a solution.
Use a partial as field type in fields.yaml instead of dropdown
<https://octobercms.com/docs/backend/forms#field-partial>
Create... | You can use "taglist" widget to do this ;-) |
35,620,124 | I need to create a multi select form field in October Cms backend form (fields.yaml). I applied the following method
select\_field:
label: Sample
type: dropdown
attributes: {multiple:'multiple'}
Options to this field will be invoked from the model
Everything is working good but when i submit ... | 2016/02/25 | [
"https://Stackoverflow.com/questions/35620124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5652672/"
] | you can't use a dropdown field with mutiple value because it was made to handle single value. as the checkbox and radio this is why there are checkboxList(i guess).
But i found a solution.
Use a partial as field type in fields.yaml instead of dropdown
<https://octobercms.com/docs/backend/forms#field-partial>
Create... | you could use select2 jquery plugin
\_widget.htm
```
<!-- for booking table -->
<select class="form-control" id="sle1" name="Booking[business_car_id]" >
<?php foreach($businesscars as $key => $value): ?>
<option class="form-control" value="<?php echo $key; ?>" >
<?php
echo $va... |
35,620,124 | I need to create a multi select form field in October Cms backend form (fields.yaml). I applied the following method
select\_field:
label: Sample
type: dropdown
attributes: {multiple:'multiple'}
Options to this field will be invoked from the model
Everything is working good but when i submit ... | 2016/02/25 | [
"https://Stackoverflow.com/questions/35620124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5652672/"
] | you can't use a dropdown field with mutiple value because it was made to handle single value. as the checkbox and radio this is why there are checkboxList(i guess).
But i found a solution.
Use a partial as field type in fields.yaml instead of dropdown
<https://octobercms.com/docs/backend/forms#field-partial>
Create... | To handle Many to Many relation through form, you can use multi select input or checkboxes.
In october cms, there are couple [relational form widget](https://octobercms.com/docs/backend/forms#widget-relation) and [taglist form widget](https://octobercms.com/docs/backend/forms#widget-taglist) to handle this kind of situ... |
3,331,098 | What has me going is the degree of web application development we are talking about.
There are different levels of web application development. For example, if I was asked to develop a web application to deal with housing customer information for a small mom and pop bakery (definitely not a enterprise situation), is t... | 2010/07/25 | [
"https://Stackoverflow.com/questions/3331098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388941/"
] | There seems to be some confusion over the usage of Java EE and Java SE terminologies. Just because EE expands to Enterprise Edition, it does not mean that it is used only by enterprises.
Java EE happens to be a set of specifications that are bundled together to form a platform. The moment you need to write a web appli... | Don't take Java EE literally. Java EE is not just *enterprise* development, per-se.
Java EE gives you the entire stack for building web apps on Java. You just can't do web development on Java otherwise.
Bottom line - you need the Java EE stack, even if you are a small/medium business. Don't let the name fool you. |
3,331,098 | What has me going is the degree of web application development we are talking about.
There are different levels of web application development. For example, if I was asked to develop a web application to deal with housing customer information for a small mom and pop bakery (definitely not a enterprise situation), is t... | 2010/07/25 | [
"https://Stackoverflow.com/questions/3331098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388941/"
] | Don't take Java EE literally. Java EE is not just *enterprise* development, per-se.
Java EE gives you the entire stack for building web apps on Java. You just can't do web development on Java otherwise.
Bottom line - you need the Java EE stack, even if you are a small/medium business. Don't let the name fool you. | Theres nothing wrong with using a full Java EE container. However this usually comes at the cost of complexity.
The minimum you need is a servlet container which is a subset of the Java EE specifications.
Full Java EE containers tend to have more to configure in them than simple servlet containers which may add overh... |
3,331,098 | What has me going is the degree of web application development we are talking about.
There are different levels of web application development. For example, if I was asked to develop a web application to deal with housing customer information for a small mom and pop bakery (definitely not a enterprise situation), is t... | 2010/07/25 | [
"https://Stackoverflow.com/questions/3331098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388941/"
] | There seems to be some confusion over the usage of Java EE and Java SE terminologies. Just because EE expands to Enterprise Edition, it does not mean that it is used only by enterprises.
Java EE happens to be a set of specifications that are bundled together to form a platform. The moment you need to write a web appli... | Theres nothing wrong with using a full Java EE container. However this usually comes at the cost of complexity.
The minimum you need is a servlet container which is a subset of the Java EE specifications.
Full Java EE containers tend to have more to configure in them than simple servlet containers which may add overh... |
29,673,604 | Hello this is my current code:
```
<select id="link_course">
<option value="">Select Course</option>
<option value="ALL">ALL</option>
<option value="BSIT" selected>BSIT</option>
<option value="BSA">BSA</option>
<option value="BSBA">BSBA</option>
<option value="BSHRTM">BSHRTM</option>
</select>
<script>
$("#link_c... | 2015/04/16 | [
"https://Stackoverflow.com/questions/29673604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4698790/"
] | You can do selection via JavaScript :
```
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
... | After loading the new page, you need to run JavaScript code to set the value on the correct item from the list. |
29,673,604 | Hello this is my current code:
```
<select id="link_course">
<option value="">Select Course</option>
<option value="ALL">ALL</option>
<option value="BSIT" selected>BSIT</option>
<option value="BSA">BSA</option>
<option value="BSBA">BSBA</option>
<option value="BSHRTM">BSHRTM</option>
</select>
<script>
$("#link_c... | 2015/04/16 | [
"https://Stackoverflow.com/questions/29673604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4698790/"
] | You can do selection via JavaScript :
```
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
... | Use `window.location.href`to get current URL. Then check on which page is user currently on and finally select corresponding option.
```
if(window.location.href.indexOf('home.php?course=BSHRTM)') != -1) {
$('select#link_course option[value=BSHRTM]').attr("selected","selected");
}
```
To avoid code duplication see... |
29,673,604 | Hello this is my current code:
```
<select id="link_course">
<option value="">Select Course</option>
<option value="ALL">ALL</option>
<option value="BSIT" selected>BSIT</option>
<option value="BSA">BSA</option>
<option value="BSBA">BSBA</option>
<option value="BSHRTM">BSHRTM</option>
</select>
<script>
$("#link_c... | 2015/04/16 | [
"https://Stackoverflow.com/questions/29673604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4698790/"
] | You can do selection via JavaScript :
```
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
... | You should do it in PHP:
```
<option value="BSHRTM" <?php if($course == 'BSHRTM') echo 'selected';?>>
```
*Supposing that you previsously set `$course = $_GET['course'];`* |
3,648,657 | This is what I'm doing
```
a = "%span.rockets#diamonds.ribbons.forever"
a = a.match(/(^\%\w+)([\.|\#]\w+)+/)
puts a.inspect
```
This is what I get
```
#<MatchData "%span.rockets#diamonds.ribbons.forever" 1:"%span" 2:".forever">
```
This is what I want
```
#<MatchData "%span.rockets#diamonds.ribbons.forever" 1:"%... | 2010/09/06 | [
"https://Stackoverflow.com/questions/3648657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/440305/"
] | Generally, you can't get an arbitrary number of capturing groups, but if you use `scan` you can get a *match* for every token you want to capture:
```
a = "%span.rockets#diamonds.ribbons.forever"
a = a.scan(/^%\w+|\G[.|#]\w+/)
puts a.inspect
["%span", ".rockets", "#diamonds", ".ribbons", ".forever"]
```
This isn't ... | That's just how capturing groups work. If you want to save all of those substrings, put the quantifier *inside* the capturing group:
```
a = a.match(/(^%\w+)((?:[.#]\w+)+)/)
```
Then your second capture will be:
```
2:".rockets#diamonds.ribbons.forever"
```
...and you can break it down the rest of the way yoursel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.