qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
58,395,576 | Given an application converting csv to parquet (from and to S3) with little transformation:
```
for table in tables:
df_table = spark.read.format('csv') \
.option("header", "true") \
.option("escape", "\"") \
.load(path)
df_one_seven_thirty_days = df_table \
.fi... | 2019/10/15 | [
"https://Stackoverflow.com/questions/58395576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599698/"
] | I would recommend:
```
select r1.*
from R1
where exists (select 1 from r2 where r1.a = r2.val) or
exists (select 1 from r2 where r1.b = r2.val);
```
Then, you want an index on `r2(val)`.
If `r2` is *really* small and `r1` is *really* big and there are separate indexes on `r1(a)` and `r1(b)`, then this might b... | Use a [`CTE`](https://www.postgresql.org/docs/current/queries-with.html) that returns all the `VAL`s from `R2` (so you scan `R2` only once).
But maybe this is not needed if the optimizer does it already for `select VAL from R2`.
Then use `CASE` to check the 2 separate cases, so the 2nd case (`WHEN b IN (SELECT VA... |
58,395,576 | Given an application converting csv to parquet (from and to S3) with little transformation:
```
for table in tables:
df_table = spark.read.format('csv') \
.option("header", "true") \
.option("escape", "\"") \
.load(path)
df_one_seven_thirty_days = df_table \
.fi... | 2019/10/15 | [
"https://Stackoverflow.com/questions/58395576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599698/"
] | It seems like in this specific case the first query I suggested in my main comment provides the best performance :
```
select * from R1 where R1.a in (select VAL from R2) or R1.b in (select VAL from R2);
```
@klin prepared a dbfiddle with all the execution plans if someone want to have a look :
<https://dbfiddle.u... | Use a [`CTE`](https://www.postgresql.org/docs/current/queries-with.html) that returns all the `VAL`s from `R2` (so you scan `R2` only once).
But maybe this is not needed if the optimizer does it already for `select VAL from R2`.
Then use `CASE` to check the 2 separate cases, so the 2nd case (`WHEN b IN (SELECT VA... |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | >
> This function is working properly in devices before Android N
>
>
>
It works for very few `Uri` values, may not have a result (e.g., for things that are indexed by `MediaStore` that are not local files), and may not have a usable result (e.g., for files on removable storage).
>
> So please help.
>
>
>
Us... | @Redturbo
I can't write a comment, I write here
```
IOUtils.copyStream(inputStream, outputStream);
```
TEMP\_DIR\_PATH - any your directory path, something like this
```
File rootDataDir = context.getFilesDir();
File copyFile = new File( rootDataDir + File.separator + fileName + ".jpg");
``` |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | >
> This function is working properly in devices before Android N
>
>
>
It works for very few `Uri` values, may not have a result (e.g., for things that are indexed by `MediaStore` that are not local files), and may not have a usable result (e.g., for files on removable storage).
>
> So please help.
>
>
>
Us... | //The following code is working in Android N:
```
private static String getFilePathForN(Uri uri, Context context) {
Uri returnUri = uri;
Cursor returnCursor = context.getContentResolver().query(returnUri, null, null, null, null);
/*
* Get the column indexes of the data in the Cursor,
* * move... |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | >
> This function is working properly in devices before Android N
>
>
>
It works for very few `Uri` values, may not have a result (e.g., for things that are indexed by `MediaStore` that are not local files), and may not have a usable result (e.g., for files on removable storage).
>
> So please help.
>
>
>
Us... | Further adding to Vidha's answer as per Android R storage framework guide and if you do not want to permanently save the copied file to storage:
```
public static String getFilePathFromURI(Context context, Uri contentUri) {
File folder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
folder =... |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | As per given answer by CommonsWare, the solution code is :
```
public static String getFilePathFromURI(Context context, Uri contentUri) {
//copy file and send new file path
String fileName = getFileName(contentUri);
if (!TextUtils.isEmpty(fileName)) {
File copyFile = new File(TEMP_DIR_PATH + File.... | @Redturbo
I can't write a comment, I write here
```
IOUtils.copyStream(inputStream, outputStream);
```
TEMP\_DIR\_PATH - any your directory path, something like this
```
File rootDataDir = context.getFilesDir();
File copyFile = new File( rootDataDir + File.separator + fileName + ".jpg");
``` |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | As per given answer by CommonsWare, the solution code is :
```
public static String getFilePathFromURI(Context context, Uri contentUri) {
//copy file and send new file path
String fileName = getFileName(contentUri);
if (!TextUtils.isEmpty(fileName)) {
File copyFile = new File(TEMP_DIR_PATH + File.... | //The following code is working in Android N:
```
private static String getFilePathForN(Uri uri, Context context) {
Uri returnUri = uri;
Cursor returnCursor = context.getContentResolver().query(returnUri, null, null, null, null);
/*
* Get the column indexes of the data in the Cursor,
* * move... |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | As per given answer by CommonsWare, the solution code is :
```
public static String getFilePathFromURI(Context context, Uri contentUri) {
//copy file and send new file path
String fileName = getFileName(contentUri);
if (!TextUtils.isEmpty(fileName)) {
File copyFile = new File(TEMP_DIR_PATH + File.... | Further adding to Vidha's answer as per Android R storage framework guide and if you do not want to permanently save the copied file to storage:
```
public static String getFilePathFromURI(Context context, Uri contentUri) {
File folder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
folder =... |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | //The following code is working in Android N:
```
private static String getFilePathForN(Uri uri, Context context) {
Uri returnUri = uri;
Cursor returnCursor = context.getContentResolver().query(returnUri, null, null, null, null);
/*
* Get the column indexes of the data in the Cursor,
* * move... | @Redturbo
I can't write a comment, I write here
```
IOUtils.copyStream(inputStream, outputStream);
```
TEMP\_DIR\_PATH - any your directory path, something like this
```
File rootDataDir = context.getFilesDir();
File copyFile = new File( rootDataDir + File.separator + fileName + ".jpg");
``` |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | @Redturbo
I can't write a comment, I write here
```
IOUtils.copyStream(inputStream, outputStream);
```
TEMP\_DIR\_PATH - any your directory path, something like this
```
File rootDataDir = context.getFilesDir();
File copyFile = new File( rootDataDir + File.separator + fileName + ".jpg");
``` | Further adding to Vidha's answer as per Android R storage framework guide and if you do not want to permanently save the copied file to storage:
```
public static String getFilePathFromURI(Context context, Uri contentUri) {
File folder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
folder =... |
42,508,383 | In Nougat, this function is not working.
```
String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
```
```
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {MediaStore.Images.Media.DATA};
cur... | 2017/02/28 | [
"https://Stackoverflow.com/questions/42508383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4150706/"
] | //The following code is working in Android N:
```
private static String getFilePathForN(Uri uri, Context context) {
Uri returnUri = uri;
Cursor returnCursor = context.getContentResolver().query(returnUri, null, null, null, null);
/*
* Get the column indexes of the data in the Cursor,
* * move... | Further adding to Vidha's answer as per Android R storage framework guide and if you do not want to permanently save the copied file to storage:
```
public static String getFilePathFromURI(Context context, Uri contentUri) {
File folder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
folder =... |
7,326,572 | So I'm building an application in Rails 3 using Devise as my authentication mechanism. I have all my controllers and views working. Our web site is humming along. Now we'd like to export our routes to 3rd party developers. The problem is how.
Here's the list of things I think I need to figure out.
1. Third party auth... | 2011/09/06 | [
"https://Stackoverflow.com/questions/7326572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195351/"
] | I'm biased about Swagger (I work on it at Wordnik) and will point out that we'll add ruby server support to automatically generate the description layer like we do with Scala. | I would definitely recommend OAuth if there is a security element for your users. That is, you want someone to be able to edit multiple users details via their service then used 3-legged OAuth (Provider, User, Client). Otherwise go for the 2-legged OAuth (Provider, Client.)
If you want to implement a 3-legged OAuth AP... |
40,713,757 | I need to add string in between of filename where a pattern is matched.
Sample filenames:
```
file_1_my001
file_11_my0012
file_65_my_012
```
I would like to rename them as:
```
file_1_my_copied_001
file_11_my_copied_0012
file_65_my_copied_012
```
Pattern is `<any string>0<any string>`
My logic was to first fetc... | 2016/11/21 | [
"https://Stackoverflow.com/questions/40713757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7173763/"
] | with `perl` based `rename` command:
```
$ touch file_1_my001 file_11_my0012 file_65_my_012
$ rename -n 's/_?(?=0)/_copied_/' file_*
rename(file_11_my0012, file_11_my_copied_0012)
rename(file_1_my001, file_1_my_copied_001)
rename(file_65_my_012, file_65_my_copied_012)
```
* `_?(?=0)` zero or one instance of `_` follo... | ```
ls | sed -e 's/\([_]*0\)/_copied_0/'
``` |
40,713,757 | I need to add string in between of filename where a pattern is matched.
Sample filenames:
```
file_1_my001
file_11_my0012
file_65_my_012
```
I would like to rename them as:
```
file_1_my_copied_001
file_11_my_copied_0012
file_65_my_copied_012
```
Pattern is `<any string>0<any string>`
My logic was to first fetc... | 2016/11/21 | [
"https://Stackoverflow.com/questions/40713757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7173763/"
] | with `perl` based `rename` command:
```
$ touch file_1_my001 file_11_my0012 file_65_my_012
$ rename -n 's/_?(?=0)/_copied_/' file_*
rename(file_11_my0012, file_11_my_copied_0012)
rename(file_1_my001, file_1_my_copied_001)
rename(file_65_my_012, file_65_my_copied_012)
```
* `_?(?=0)` zero or one instance of `_` follo... | Something like,
```
$ sed -E "s/(.*[^0-9]+)(0[0-9]*)/\1_copied_\2/"
``` |
825,944 | I have connected to nic adapters a standard vSwitch, and have enable 'Route based on an IP hash' on the vSwitch. For the physical switch we are using a cisco switch and have enabled LACP with nic teaming on two ports.
Now when we connect, the host stops responding. To bring it back I need to change the port on the phy... | 2017/01/12 | [
"https://serverfault.com/questions/825944",
"https://serverfault.com",
"https://serverfault.com/users/75464/"
] | Using LACP on the ESXi end requires that the uplinks be attached to a Distributed switch, as Standard switches don't have those options.
You can still get teaming with standard switches, but need to enable a static team on the switch end, then use 'Route based on an IP hash' on your vSwitch. | The management interface overrides the settings of the vswitch.
Set the settings of the management interface of the ESXi accordingly, especially the hashing algorithm. |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | I don't know whether you can use any random integer function library or not. However, I am giving you a simple pseudo code based on that:
```
1) Generate a Random Number I from 1 to 10.
2) For J = 0 to I
byte array[j] = (byte) Generate a Random Number from 0 to 128.
3) For J = 0 to I
String st = st + (char) byte arra... | **Nudge served:**
Yes, it is possible. You run single for-loop and then convert every counter value to base 26. Then every digit in your new number will code one letter. Please see [here](http://rachel5nj.tripod.com/NOTC/convertingbases.html) on how to convert numbers to arbitrary base. (Sorry for ads overrun page) |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | If you are looking for creating a single random word, then follow the next steps:
1. Populate an array of chars: `char[] arr = { 'a', 'b', ... , 'z'}`
2. get a random integer that denotes the size of the string.
3. initialize an empty string `s`
4. iterate from 0 to the drawed length, draw a number in range `[0,arr.le... | Lets suppose that you know the length of the list and the 'words' are again of random length and of totally random. You can then do something like the following (it prints the words, you can write them on a file instead):
```
import java.util.Random;
...
String alphabet = "qwertyuioplkjhgfdsazxcvbnm";
Random r = new R... |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | Create a function that maps integers to character sequences. ie:
```
0 -> a
1 -> b
...
26 -> aa
```
etc. You can use that to create a specific word or a list of words iteratively.
Inside your algorithm you will be using modulus `%26` a lot… | Lets suppose that you know the length of the list and the 'words' are again of random length and of totally random. You can then do something like the following (it prints the words, you can write them on a file instead):
```
import java.util.Random;
...
String alphabet = "qwertyuioplkjhgfdsazxcvbnm";
Random r = new R... |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | If you are looking for creating a single random word, then follow the next steps:
1. Populate an array of chars: `char[] arr = { 'a', 'b', ... , 'z'}`
2. get a random integer that denotes the size of the string.
3. initialize an empty string `s`
4. iterate from 0 to the drawed length, draw a number in range `[0,arr.le... | Create a function that maps integers to character sequences. ie:
```
0 -> a
1 -> b
...
26 -> aa
```
etc. You can use that to create a specific word or a list of words iteratively.
Inside your algorithm you will be using modulus `%26` a lot… |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | Create a function that maps integers to character sequences. ie:
```
0 -> a
1 -> b
...
26 -> aa
```
etc. You can use that to create a specific word or a list of words iteratively.
Inside your algorithm you will be using modulus `%26` a lot… | ```
final char[] tabC = "abcdefghijklmnopqrstuvwxyz".toCharArray();
for (final char c1 : tabC) {
System.out.println(c1 + "\t" + c1);
for (final char c2 : tabC) {
System.out.println(Character.toString(c1)
+ Character.toString(c2) + "\t" + (c1 + (c2 << 6)));
}
... |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | Create a function that maps integers to character sequences. ie:
```
0 -> a
1 -> b
...
26 -> aa
```
etc. You can use that to create a specific word or a list of words iteratively.
Inside your algorithm you will be using modulus `%26` a lot… | I would do this:
Input n - number of words you want to generate, [I,J] - the range for the words length.
The algorithm:
* Do n times:
+ i <- random number between I and J.
+ Do i times: (0 <= j <= i-1)
- Word[j] = random char between 'a' and 'z'
+ Add Word to result
* Return result |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | If you are looking for creating a single random word, then follow the next steps:
1. Populate an array of chars: `char[] arr = { 'a', 'b', ... , 'z'}`
2. get a random integer that denotes the size of the string.
3. initialize an empty string `s`
4. iterate from 0 to the drawed length, draw a number in range `[0,arr.le... | **Nudge served:**
Yes, it is possible. You run single for-loop and then convert every counter value to base 26. Then every digit in your new number will code one letter. Please see [here](http://rachel5nj.tripod.com/NOTC/convertingbases.html) on how to convert numbers to arbitrary base. (Sorry for ads overrun page) |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | If you are looking for creating a single random word, then follow the next steps:
1. Populate an array of chars: `char[] arr = { 'a', 'b', ... , 'z'}`
2. get a random integer that denotes the size of the string.
3. initialize an empty string `s`
4. iterate from 0 to the drawed length, draw a number in range `[0,arr.le... | I don't know whether you can use any random integer function library or not. However, I am giving you a simple pseudo code based on that:
```
1) Generate a Random Number I from 1 to 10.
2) For J = 0 to I
byte array[j] = (byte) Generate a Random Number from 0 to 128.
3) For J = 0 to I
String st = st + (char) byte arra... |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | If you are looking for creating a single random word, then follow the next steps:
1. Populate an array of chars: `char[] arr = { 'a', 'b', ... , 'z'}`
2. get a random integer that denotes the size of the string.
3. initialize an empty string `s`
4. iterate from 0 to the drawed length, draw a number in range `[0,arr.le... | I would do this:
Input n - number of words you want to generate, [I,J] - the range for the words length.
The algorithm:
* Do n times:
+ i <- random number between I and J.
+ Do i times: (0 <= j <= i-1)
- Word[j] = random char between 'a' and 'z'
+ Add Word to result
* Return result |
11,826,267 | I want to create a word generator, but in a way it almost seems like a numerical system.
Hex goes from `0` to `f`, this algorithm should go from `a` to `z`. So the word that is created goes like this (every `-` means a new word):
```
a - b - c - d - ... - z - aa - ab - ac - ad - ... - ba - bb - bc - ...
```
Each wor... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11826267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290498/"
] | I don't know whether you can use any random integer function library or not. However, I am giving you a simple pseudo code based on that:
```
1) Generate a Random Number I from 1 to 10.
2) For J = 0 to I
byte array[j] = (byte) Generate a Random Number from 0 to 128.
3) For J = 0 to I
String st = st + (char) byte arra... | You need to define how long are your words, otherwise this would be infinitve.
This is called Combinatorics in math, take a look [here](http://www.martinbroadhurst.com/combinatorial-algorithms.html) you can choose which algorthm suits your needs. |
42,019,358 | I have three tables :
```
CREATE TABLE workflow_roles (
role_id NUMBER PRIMARY KEY,
role_desc VARCHAR2(20)
);
CREATE TABLE tbl_workflow (
workflow_id VARCHAR2(5) PRIMARY KEY,
workflow_desc VARCHAR2(20)
);
CREATE TABLE workflow_detail (
role_id NUMBER REFERENCES workflow_roles( role_id )... | 2017/02/03 | [
"https://Stackoverflow.com/questions/42019358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5554359/"
] | A solution using a User-Defined Aggregation function to get the intersection of multiple collections:
**Oracle Setup**:
First, define a collection to hold the workflows:
```
CREATE OR REPLACE TYPE VARCHAR2s_Table IS TABLE OF VARCHAR2(4000);
/
```
Secondly, define an object to use in the aggregation process:
```
C... | I this way you have all the rols with number they are used
```
select wr.role_desc role_desc, count(*) role_nums
from workflow_detail wd
inner join workflow_roles wr on wr.role_id = wd.role_id
inner join tbl_workflow tw on tw.workflow_id = wd.workflow_id
group by wr.role_desc
order by role_n... |
42,019,358 | I have three tables :
```
CREATE TABLE workflow_roles (
role_id NUMBER PRIMARY KEY,
role_desc VARCHAR2(20)
);
CREATE TABLE tbl_workflow (
workflow_id VARCHAR2(5) PRIMARY KEY,
workflow_desc VARCHAR2(20)
);
CREATE TABLE workflow_detail (
role_id NUMBER REFERENCES workflow_roles( role_id )... | 2017/02/03 | [
"https://Stackoverflow.com/questions/42019358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5554359/"
] | A solution using a User-Defined Aggregation function to get the intersection of multiple collections:
**Oracle Setup**:
First, define a collection to hold the workflows:
```
CREATE OR REPLACE TYPE VARCHAR2s_Table IS TABLE OF VARCHAR2(4000);
/
```
Secondly, define an object to use in the aggregation process:
```
C... | One simple solution: you want the role to be in two sets, so query *two* sets with `IN`:
```
select * from workflow_roles
where role_id in (select role_id from workflow_detail where workflow_id = 1)
and role_id in (select role_id from workflow_detail where workflow_id = 2);
```
Another option is to count matches ... |
20,359,781 | file.data has the following values to fit with Weibull distribution,
```
x y
2.53 0.00
0.70 0.99
0.60 2.45
0.49 5.36
0.40 9.31
0.31 18.53
0.22 30.24
0.11 42.23
```
Following the Weibull distribution function `f(x)=1.0-exp(-lambda*x**n)`, it is giving error:
```
fit f(x) 'data.dat' via... | 2013/12/03 | [
"https://Stackoverflow.com/questions/20359781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/618021/"
] | Several things:
1. You must skip the first line (if it really is `x y`).
2. You must use the correct function (the pdf and not the CDF, see <http://en.wikipedia.org/wiki/Weibull_distribution>, like you did in <https://stackoverflow.com/q/20336051/2604213>)
3. You must use an additional scaling parameter, because your ... | If that's the actual command you provided to gnuplot, it won't work because you haven't yet defined f(x). |
81,196 | Would a "panel antenna" used for RFID (probably microstrip-based; e.g. <http://www.joymax.com.tw/index.php?_Page=product&mode=show&cid=2387&pid=364>) work for satellite communication, assuming a positive link margin? I can't see any reason why not: there is circular polarisation, directivity, gain, am I missing anythin... | 2013/09/04 | [
"https://electronics.stackexchange.com/questions/81196",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/18133/"
] | Which satellite frequency band were you expecting to work on the antenna you linked?
>
> assume the frequency of interest is within the antenna's bandwidth
>
>
>
What is the bandwidth of the signal to be received?
>
> Narrowband (< 1 MHz)
>
>
>
If the receiver frequency is in the frequency range of the ante... | I would suppose you're dealing with completely different frequency ranges and you will never get the required gain for the frequencies you need. |
81,196 | Would a "panel antenna" used for RFID (probably microstrip-based; e.g. <http://www.joymax.com.tw/index.php?_Page=product&mode=show&cid=2387&pid=364>) work for satellite communication, assuming a positive link margin? I can't see any reason why not: there is circular polarisation, directivity, gain, am I missing anythin... | 2013/09/04 | [
"https://electronics.stackexchange.com/questions/81196",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/18133/"
] | Which satellite frequency band were you expecting to work on the antenna you linked?
>
> assume the frequency of interest is within the antenna's bandwidth
>
>
>
What is the bandwidth of the signal to be received?
>
> Narrowband (< 1 MHz)
>
>
>
If the receiver frequency is in the frequency range of the ante... | Given the criteria you specify,
and absent any hidden unspecified gotchas,
quite possibly yes.
BUT achieving your criteria seems unlikely.
The RFID patch antenna will have a low gain and you may need to use
* a MBS (Main Battle Star) MASER as the downlink tx and
* liquid (or solid) Hydrogen cooled downlink... |
41,039,458 | I'm trying to insert CSV file into MySql but I'm getting an error.
>
> Warning: mysql\_real\_escape\_string() expects parameter 1 to be string,
>
>
>
My database table is:
```
:s_no :name :id :
:1 :Lim :678 :
:2 :Mary :623 :
:3 :Mimi :4124 :
```
The **number** is AUTO\_IN... | 2016/12/08 | [
"https://Stackoverflow.com/questions/41039458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7267483/"
] | The connection is the second parameter.
```
mysql_real_escape_string( $data[0], $connect);
```
Also remember it is a deprecated function
<http://php.net/manual/en/function.mysql-real-escape-string.php> | try this
```
mysql_real_escape_string("string")
```
means
```
mysql_real_escape_string($data[0]);
``` |
41,039,458 | I'm trying to insert CSV file into MySql but I'm getting an error.
>
> Warning: mysql\_real\_escape\_string() expects parameter 1 to be string,
>
>
>
My database table is:
```
:s_no :name :id :
:1 :Lim :678 :
:2 :Mary :623 :
:3 :Mimi :4124 :
```
The **number** is AUTO\_IN... | 2016/12/08 | [
"https://Stackoverflow.com/questions/41039458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7267483/"
] | The connection is the second parameter.
```
mysql_real_escape_string( $data[0], $connect);
```
Also remember it is a deprecated function
<http://php.net/manual/en/function.mysql-real-escape-string.php> | if you are using **mysqli** then
```
mysqli_real_escape_string($connect,$data[0]);
```
if you are use **mysql**
```
mysql_real_escape_string( $data[0]);
``` |
29,248,323 | I am implementing chosen dropdown in my project. But I have some problem which I want to solve.
Before proceeding, let me give you the jQuery fiddle:
<http://jsfiddle.net/jHvmg/278/>
Now I have a dropdown like this
```
<select id="drp_menu">
<option value="Option 1">Option 1</option>
<option value="Option 2... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29248323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1170507/"
] | add `{ search_contains: true }` and Enjoy :)
JS Code:
--------
```
$(document).ready(function()
{
$('#drp_menu').chosen({ search_contains: true });
});
```
[Demo](http://jsfiddle.net/jHvmg/279/) | Replace
```
$('#drp_menu').chosen();
```
with
```
$('#drp_menu').chosen({search_contains:true});
```
[Here is a fiddle](http://jsfiddle.net/jHvmg/282/)
Just look for the [documentation](http://harvesthq.github.io/chosen/options.html) for `configuration options` like this |
50,446,738 | I’m using *AWS Cognito to perform login authentication*. When login is successful we get below request body :
*Request body:*
```
> {"UserContextData":{"EncodedData":"eyJ..9”},”ClientMetadata":{"cognito:deviceName":"MacBookPro12-01","cognito:bundleShortV":"1.0.0",
> "cognito:idForVendor":"A6FD46FBB205","cognito:bundl... | 2018/05/21 | [
"https://Stackoverflow.com/questions/50446738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1753005/"
] | Unfortunately you can't just pass a string directly as the credentials argument (although perhaps we should make it where you can), you should do this instead:
```
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file('service_acc_key.json')
client = vision.Ima... | Add the following lines before calling the client
>
> os.environ["GOOGLE\_APPLICATION\_CREDENTIALS"] = path/to/service-account.json/file
>
>
> |
6,846,969 | I am writing a website and want a user to be able to click post to Facebook and have it open a window already filled out with a custom post. I do not want to have to authenticate them with my site or anything like that just send them to a Facebook url with the post already filled in.
Twitter has something like this th... | 2011/07/27 | [
"https://Stackoverflow.com/questions/6846969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/509967/"
] | I found the solution I was looking for. To post to a Facebook wall without actually managing tokens you must make a call to the url below with the parameters specified below.
"http://www.facebook.com/dialog/feed?app\_id=YOU\_APP\_ID&link=A\_LINK\_HERE&picture=PATH\_TO\_A\_PICTURE&name=SOME\_NAME&caption=SOME\_CAPTION&... | The Like and Send buttons provide this functionality:
<http://developers.facebook.com/docs/reference/plugins/like/>
You include meta tags on your page and the Like / Send button pick this up for sharing to a user's wall. |
6,846,969 | I am writing a website and want a user to be able to click post to Facebook and have it open a window already filled out with a custom post. I do not want to have to authenticate them with my site or anything like that just send them to a Facebook url with the post already filled in.
Twitter has something like this th... | 2011/07/27 | [
"https://Stackoverflow.com/questions/6846969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/509967/"
] | I found the solution I was looking for. To post to a Facebook wall without actually managing tokens you must make a call to the url below with the parameters specified below.
"http://www.facebook.com/dialog/feed?app\_id=YOU\_APP\_ID&link=A\_LINK\_HERE&picture=PATH\_TO\_A\_PICTURE&name=SOME\_NAME&caption=SOME\_CAPTION&... | You can't prefill story text, it's against FB policies. Twitter is cool with that, but on Facebook it's a no-no.
See: <http://developers.facebook.com/docs/guides/policy/examples_and_explanations/stream_stories/>
Scroll down a bit to 'Platform Policy IV.2'
You can put suggestions of what to say on the screen, but you... |
14,145,303 | I'd like to have a helper that works just like link\_to except that it merges in a data attribute (in this case for ease of creating tabs using bootstrap: <http://twitter.github.com/bootstrap/javascript.html#tabs>)
So I can call it like this:
```
link_to_tab("Name", @obj)
```
and get
```
<a href='/path' data-togg... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14145303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/625365/"
] | Not really. You could try this...
```
def link_to_tab(*args, &block)
toggle_hash = {'data-toggle' => 'tab'}
if args.last.is_a? Hash
args.last.merge!(toggle_hash)
else
args << toggle_hash
end
link_to(*args, &block)
end
```
Not that different though... | >
> I'd like to have a helper that works just like link\_to except that it merges in a data attribute
>
>
>
I might be missing something, but why not just pass a custom data argument to the link\_to helper?
```
= link_to "foo tab", {}, "data-toggle" => "tab"
```
Outputs:
```
<a data-toggle="tab" href="/">foo t... |
57,158,475 | Is there a way to disable "search wrapping" in VS code?
I.e. prevent the search from starting back at the top again after reaching the last occurrence of the search term in the file? | 2019/07/23 | [
"https://Stackoverflow.com/questions/57158475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1930462/"
] | **UPDATE** !!
A setting is being added to v1.45 to disable "search wrapping". See <https://github.com/microsoft/vscode/pull/92243>
>
> Editor > Find: Loop
>
>
>
default is enabled, it will loop or wrap.
---
---------------- old answer:
No, apparently not. See this issue: [disable search wrap](https://github.c... | In Preferences > Settings > Open Settings (Json)
Add:
```
"editor.find.loop": false
``` |
51,064,103 | I need to form several subqueries with sets of dates including only sundays between two set points, for example between 01.04.2018 and 30.06.2018.
The first thing which comes into mind is something like this:
```
SELECT '01.04.2018' STARTDATE FROM DUAL
UNION ALL
SELECT '08.04.2018' STARTDATE FROM DUAL
...
```
But i... | 2018/06/27 | [
"https://Stackoverflow.com/questions/51064103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9003662/"
] | You can use:
[SQL Fiddle](http://sqlfiddle.com/#!4/ae2cc8/473)
**Query 1**:
```
SELECT NEXT_DAY( DATE '2018-04-01' - 1, 'SUNDAY' ) + ( LEVEL - 1 ) * 7
AS startdate
FROM DUAL
CONNECT BY
NEXT_DAY( DATE '2018-04-01' - 1, 'SUNDAY' ) + ( LEVEL - 1 ) * 7
<= DATE '2018-06-30'
```
**[Results](ht... | The brute force approach would be to just generate the entire date range and then filter it to leave only Sundays:
```
WITH cte AS (
SELECT TRUNC (date '2018-06-30' - ROWNUM) dt
FROM DUAL CONNECT BY ROWNUM < 100
)
SELECT * FROM cte WHERE TO_CHAR(dt, 'DAY') = 'SUN'
``` |
11,391,088 | I need to draw a string over a Infragistics toolbar, and I cannot use a label since it's background will not be actually transparent (see in image).
I've managed to overlay the text as desired using DrawString method, but the problem is that the text does not resemble a label. it's thicker, aliased and for some reason... | 2012/07/09 | [
"https://Stackoverflow.com/questions/11391088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1887900/"
] | Try using [`TextRenderer`](http://msdn.microsoft.com/en-us/library/system.windows.forms.textrenderer.aspx) class:
```
TextRenderer.DrawString(
drawParams.Graphics,
"String Drawn with TextRenderer (GDI) method",
font,
new Point(textEditorLoc.X, textEditorLoc.Y + 25),
SystemColors.ControlText);
```
... | The standard text size of a label is 8,25 points, or approximately 11 pixels. Your size of 17 pixels results in a text size of 13 pt.
Try using this
```
FontFamily fontFamily = new FontFamily("Microsoft Sans Serif");
Font font = new Font(
fontFamily,
8.25f,
F... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | DI.fm allows you to download as `.pls`.
As for Sky.fm, you will have to manually download the files by entering this URL:
`listen.sky.fm/public3/STATIONNAME.pls`.
For example: `listen.sky.fm/public3/dreamscapes.pls` | You can download all the .pls files. After that you open this files in a text editor like notepad++. You´ll discover the true url for the station. Add these url in a streaming audio grabber.
You´ll download in real time as the music plays.
I recomend StremRipper for winamp (you really don´t need winamp to use it)
Open ... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | DI.fm allows you to download as `.pls`.
As for Sky.fm, you will have to manually download the files by entering this URL:
`listen.sky.fm/public3/STATIONNAME.pls`.
For example: `listen.sky.fm/public3/dreamscapes.pls` | My answer was initially the same as above, except I give the link to the di fm radio and not sky radio. The link would be something like this:
```
http://listen.di.fm/public3/insert_radio_name.pls
```
And you get radio name by clicking on any of the radios, it will be `http://www.di.fm/insert_radio_name` so this is ... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | DI.fm allows you to download as `.pls`.
As for Sky.fm, you will have to manually download the files by entering this URL:
`listen.sky.fm/public3/STATIONNAME.pls`.
For example: `listen.sky.fm/public3/dreamscapes.pls` | This solution uses command line programs:
`curl` - cURL tool to transfer data from or to a server
`grep` - Grep a command-line utility that can search and filter text
*Linux users should find these either already installed or simply use their distro's package manager to install. Windows users can install [Cygw... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | 1. Save the following text in a .pls file.
2. Edit with notepad to replace the text YOUR\_KEY by your premium key or delete it if you are not premium.
3. Open the pls file in your favorite player :)
>
> [playlist]
>
> NumberOfEntries=70
>
> File1=http://listen.di.fm/premium\_high/trance.pls?YOUR\_KEY
>
> ... | You can download all the .pls files. After that you open this files in a text editor like notepad++. You´ll discover the true url for the station. Add these url in a streaming audio grabber.
You´ll download in real time as the music plays.
I recomend StremRipper for winamp (you really don´t need winamp to use it)
Open ... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | My answer was initially the same as above, except I give the link to the di fm radio and not sky radio. The link would be something like this:
```
http://listen.di.fm/public3/insert_radio_name.pls
```
And you get radio name by clicking on any of the radios, it will be `http://www.di.fm/insert_radio_name` so this is ... | You can download all the .pls files. After that you open this files in a text editor like notepad++. You´ll discover the true url for the station. Add these url in a streaming audio grabber.
You´ll download in real time as the music plays.
I recomend StremRipper for winamp (you really don´t need winamp to use it)
Open ... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | This solution uses command line programs:
`curl` - cURL tool to transfer data from or to a server
`grep` - Grep a command-line utility that can search and filter text
*Linux users should find these either already installed or simply use their distro's package manager to install. Windows users can install [Cygw... | You can download all the .pls files. After that you open this files in a text editor like notepad++. You´ll discover the true url for the station. Add these url in a streaming audio grabber.
You´ll download in real time as the music plays.
I recomend StremRipper for winamp (you really don´t need winamp to use it)
Open ... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | 1. Save the following text in a .pls file.
2. Edit with notepad to replace the text YOUR\_KEY by your premium key or delete it if you are not premium.
3. Open the pls file in your favorite player :)
>
> [playlist]
>
> NumberOfEntries=70
>
> File1=http://listen.di.fm/premium\_high/trance.pls?YOUR\_KEY
>
> ... | My answer was initially the same as above, except I give the link to the di fm radio and not sky radio. The link would be something like this:
```
http://listen.di.fm/public3/insert_radio_name.pls
```
And you get radio name by clicking on any of the radios, it will be `http://www.di.fm/insert_radio_name` so this is ... |
21,798 | I would like to download the radio station playlists available for free (LQ) by www.di.fm and www.sky.fm, because they offer no web/desktop app! But I don't always use my iPhone or Android tablet and their website navigation is way too cumbersome.
Is there a quick way to download **all** their stations \*.pls?
I want... | 2011/12/08 | [
"https://webapps.stackexchange.com/questions/21798",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9898/"
] | 1. Save the following text in a .pls file.
2. Edit with notepad to replace the text YOUR\_KEY by your premium key or delete it if you are not premium.
3. Open the pls file in your favorite player :)
>
> [playlist]
>
> NumberOfEntries=70
>
> File1=http://listen.di.fm/premium\_high/trance.pls?YOUR\_KEY
>
> ... | This solution uses command line programs:
`curl` - cURL tool to transfer data from or to a server
`grep` - Grep a command-line utility that can search and filter text
*Linux users should find these either already installed or simply use their distro's package manager to install. Windows users can install [Cygw... |
64,774,158 | I am looking for a way to use grep on a linux server to find duplicate json records, is it possible to have a grep to search for duplicate id's in the example below ?
so the grep would return: 01
```
{
"book": [
{
"id": "01",
"language": "Java",
"edition": "third",
"author": "Herbert Schildt"
... | 2020/11/10 | [
"https://Stackoverflow.com/questions/64774158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2312005/"
] | use `grep` along with `uniq`.
```
grep '"id":' filename | sort | uniq -d
```
The `-d` option only prints duplicates.
However, this depends on the JSON being laid out neatly. To handle more general formatting, I recommend you use the `jq` utility. | Use a Perl one-liner to extract the numeric ids, then `sort | uniq -d` to print only the duplicates (as in the answer by *Barmar*):
This assumes that the id key/value pair is on the same line, but disregards whitespace (or lack of whitespace) anywhere on the line (leading, trailing, and in between):
```
perl -lne 'pr... |
64,774,158 | I am looking for a way to use grep on a linux server to find duplicate json records, is it possible to have a grep to search for duplicate id's in the example below ?
so the grep would return: 01
```
{
"book": [
{
"id": "01",
"language": "Java",
"edition": "third",
"author": "Herbert Schildt"
... | 2020/11/10 | [
"https://Stackoverflow.com/questions/64774158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2312005/"
] | OK, discarding any whitespace from the JSON strings I can offer this if `awk` is acceptable - `hutch` being the formatted chunk of JSON above in a file.
I use `tr` to remove any whitespace, use `,` as a field separator in awk; iterate over the one long lines elements with a for-loop, do some pattern-matching in awk to... | Use a Perl one-liner to extract the numeric ids, then `sort | uniq -d` to print only the duplicates (as in the answer by *Barmar*):
This assumes that the id key/value pair is on the same line, but disregards whitespace (or lack of whitespace) anywhere on the line (leading, trailing, and in between):
```
perl -lne 'pr... |
64,774,158 | I am looking for a way to use grep on a linux server to find duplicate json records, is it possible to have a grep to search for duplicate id's in the example below ?
so the grep would return: 01
```
{
"book": [
{
"id": "01",
"language": "Java",
"edition": "third",
"author": "Herbert Schildt"
... | 2020/11/10 | [
"https://Stackoverflow.com/questions/64774158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2312005/"
] | A `jq`-based approach:
```sh
jq -r '.book[].id' < in.json | sort | uniq -d
01
```
This should work even for minified JSON files with no newlines. | Use a Perl one-liner to extract the numeric ids, then `sort | uniq -d` to print only the duplicates (as in the answer by *Barmar*):
This assumes that the id key/value pair is on the same line, but disregards whitespace (or lack of whitespace) anywhere on the line (leading, trailing, and in between):
```
perl -lne 'pr... |
19,868,734 | I'm writing a jQuery plugin using a typical `$.extend` scenario for merging user settings with the defaults, as in:
```
var settings = $.extend({
title: '',
padding: [0,0,0,0]
}, options);
```
Is there a swift way to ensure that `padding` always be a 4-member array of integers, honouring user's prope... | 2013/11/08 | [
"https://Stackoverflow.com/questions/19868734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/776686/"
] | No, you have to check validity of `options` before extending the defaults. so no 'swift way' there.
I would however go for four separate properties to make the code more readable (which index is which padding; top, left, right, bottom?) and solve your problem...
```
var settings = $.extend({
title: '',
paddin... | I ended up with the following code, which so far has worked just fine:
```
if (options.padding && $.isArray(options.padding)) {
var pd = options.padding;
// Parsing shortcuts.
switch (pd.length) {
case 0:
options.padding = [0,0,0,0];
break;
case 1:
options.padding = [pd[0], pd[0], pd[0]... |
721,880 | I am trying to combine these 2 Nginx location definitions into 1
```
location /v1/login {
proxy_pass http://upstream/v1/login;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Authorization;
}
l... | 2015/09/12 | [
"https://serverfault.com/questions/721880",
"https://serverfault.com",
"https://serverfault.com/users/40672/"
] | What's wrong with this simple one?
```
location /v1/ {
proxy_pass http://upstream/v1/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
``` | You are not passing the complete URL to `proxy_pass`. Try something like this:
```
location ~ ^/v1/(login|logout) {
proxy_pass http://upstream;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
``` |
721,880 | I am trying to combine these 2 Nginx location definitions into 1
```
location /v1/login {
proxy_pass http://upstream/v1/login;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Authorization;
}
l... | 2015/09/12 | [
"https://serverfault.com/questions/721880",
"https://serverfault.com",
"https://serverfault.com/users/40672/"
] | Have you tried this one?
```
location ~ ^/v1/(login|logout) {
proxy_pass http://upstream/v1/$1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
```
***Edit:***
You may also add the following directive along with your `proxy_pass_header Authorizat... | You are not passing the complete URL to `proxy_pass`. Try something like this:
```
location ~ ^/v1/(login|logout) {
proxy_pass http://upstream;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
``` |
721,880 | I am trying to combine these 2 Nginx location definitions into 1
```
location /v1/login {
proxy_pass http://upstream/v1/login;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Authorization;
}
l... | 2015/09/12 | [
"https://serverfault.com/questions/721880",
"https://serverfault.com",
"https://serverfault.com/users/40672/"
] | Have you tried this one?
```
location ~ ^/v1/(login|logout) {
proxy_pass http://upstream/v1/$1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
```
***Edit:***
You may also add the following directive along with your `proxy_pass_header Authorizat... | What's wrong with this simple one?
```
location /v1/ {
proxy_pass http://upstream/v1/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
``` |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | ### Scope and Context are not the same
The way variable `x` is resolved has nothing to do with context. It is resolved by scope rules: does any of the closures define that variable? If not, look in the global object. At no point the variable is resolved by looking in the context.
You could have a look at [this articl... | whilst I recommend the answer provided by @trincot and in particular the great link. I am posting here my solution to the problem I faced
```
function evalInContext(scr, context)
{
// execute script in private context
return (new Function( "with(this) { return " + scr + "}")).call(context);
}
```
The `with(t... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | ### Scope and Context are not the same
The way variable `x` is resolved has nothing to do with context. It is resolved by scope rules: does any of the closures define that variable? If not, look in the global object. At no point the variable is resolved by looking in the context.
You could have a look at [this articl... | This is an alternative method (written in ES6):
```
(new Function(...Object.keys(context), codeYouWantToExecute))(...Object.values(context));
```
Credits to Jonas Wilms for the answer.
Here is my explanation, since I did not initially understand how it worked:
```
let example = new Function('a', 'b', 'return a+ b... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | ### Scope and Context are not the same
The way variable `x` is resolved has nothing to do with context. It is resolved by scope rules: does any of the closures define that variable? If not, look in the global object. At no point the variable is resolved by looking in the context.
You could have a look at [this articl... | This evaluates expressions in a given context without the need to prefix vars with 'this'.
Has caveats but works fine.
Can also incorporate custom functions in the expression.
Just call an 'evaluate' function, passing in your expression, context and an optional function.
The context must be a flat structure (no n... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | ### Scope and Context are not the same
The way variable `x` is resolved has nothing to do with context. It is resolved by scope rules: does any of the closures define that variable? If not, look in the global object. At no point the variable is resolved by looking in the context.
You could have a look at [this articl... | cannot comment so i post, Joe's answer is great but if the string holds multiple statements (like `x++; y++; x+y;`) the `y++` part would never be executed because it returns at first statement.
with this modification all statements will be executed and the last statement will be the return value.
>
>
> ```
> functi... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | whilst I recommend the answer provided by @trincot and in particular the great link. I am posting here my solution to the problem I faced
```
function evalInContext(scr, context)
{
// execute script in private context
return (new Function( "with(this) { return " + scr + "}")).call(context);
}
```
The `with(t... | This is an alternative method (written in ES6):
```
(new Function(...Object.keys(context), codeYouWantToExecute))(...Object.values(context));
```
Credits to Jonas Wilms for the answer.
Here is my explanation, since I did not initially understand how it worked:
```
let example = new Function('a', 'b', 'return a+ b... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | whilst I recommend the answer provided by @trincot and in particular the great link. I am posting here my solution to the problem I faced
```
function evalInContext(scr, context)
{
// execute script in private context
return (new Function( "with(this) { return " + scr + "}")).call(context);
}
```
The `with(t... | This evaluates expressions in a given context without the need to prefix vars with 'this'.
Has caveats but works fine.
Can also incorporate custom functions in the expression.
Just call an 'evaluate' function, passing in your expression, context and an optional function.
The context must be a flat structure (no n... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | whilst I recommend the answer provided by @trincot and in particular the great link. I am posting here my solution to the problem I faced
```
function evalInContext(scr, context)
{
// execute script in private context
return (new Function( "with(this) { return " + scr + "}")).call(context);
}
```
The `with(t... | cannot comment so i post, Joe's answer is great but if the string holds multiple statements (like `x++; y++; x+y;`) the `y++` part would never be executed because it returns at first statement.
with this modification all statements will be executed and the last statement will be the return value.
>
>
> ```
> functi... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | This is an alternative method (written in ES6):
```
(new Function(...Object.keys(context), codeYouWantToExecute))(...Object.values(context));
```
Credits to Jonas Wilms for the answer.
Here is my explanation, since I did not initially understand how it worked:
```
let example = new Function('a', 'b', 'return a+ b... | This evaluates expressions in a given context without the need to prefix vars with 'this'.
Has caveats but works fine.
Can also incorporate custom functions in the expression.
Just call an 'evaluate' function, passing in your expression, context and an optional function.
The context must be a flat structure (no n... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | This is an alternative method (written in ES6):
```
(new Function(...Object.keys(context), codeYouWantToExecute))(...Object.values(context));
```
Credits to Jonas Wilms for the answer.
Here is my explanation, since I did not initially understand how it worked:
```
let example = new Function('a', 'b', 'return a+ b... | cannot comment so i post, Joe's answer is great but if the string holds multiple statements (like `x++; y++; x+y;`) the `y++` part would never be executed because it returns at first statement.
with this modification all statements will be executed and the last statement will be the return value.
>
>
> ```
> functi... |
40,107,919 | I am trying to execute eval within a particular context. I have found the answer [here](https://stackoverflow.com/a/25859853/1972493) useful. However I am getting the following behavior in Chrome Version 53.0.2785.143 m. Not tried other browsers. The code I am using is the following:
```
function evalInContext(js, con... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972493/"
] | This evaluates expressions in a given context without the need to prefix vars with 'this'.
Has caveats but works fine.
Can also incorporate custom functions in the expression.
Just call an 'evaluate' function, passing in your expression, context and an optional function.
The context must be a flat structure (no n... | cannot comment so i post, Joe's answer is great but if the string holds multiple statements (like `x++; y++; x+y;`) the `y++` part would never be executed because it returns at first statement.
with this modification all statements will be executed and the last statement will be the return value.
>
>
> ```
> functi... |
45,033,943 | I am trying to compile the following code (simplified from actual use) using g++:
```
namespace A {
class B;
}
A::B operator+(A::B a, A::B b);
namespace A {
class B {
private:
int i;
public:
B() : i(0) {}
B(int j) : i(j) {}
friend B ::operator+(B a, B b);
};
}
A:... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45033943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2148502/"
] | Based on my understanding, you are talking about Azure SQL database. I assumed that you could [Export your Azure SQL database to a BACPAC file](https://learn.microsoft.com/en-us/azure/sql-database/sql-database-export).
>
> I try to do an export of an Azure DB, but I can't find how to do that in C#.
>
>
>
Accordin... | I've found the solution of my problem:
I had to update my Microsoft.Azure.Management.Sql library.
Now, I can use this export method:
>
> public static ImportExportResponse Export(this IDatabasesOperations
> operations, string resourceGroupName, string serverName, string
> databaseName, ExportRequest parameters);
> ... |
13,389,583 | I have UIDatePicker and I want to draw time in UIDatePicker for example in gray color
I need this, if in my graphic is draw some interval, so in datePicker user can't select this time
 | 2012/11/15 | [
"https://Stackoverflow.com/questions/13389583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1304878/"
] | You can enclose your strings with `NULLIF()`
You use it like this:
```
NULLIF('test','') --> returns 'test'
NULLIF('' ,'') --> returns NULL
``` | Alternatively to NULLIF you could set the default to NULL and just not pass empty fields along. |
70,800,272 | I have a flutter app and its working fine in debug mode but when i run flutter build apk command for android apk it shows the following error.
The error is cannot run with sound null safety.
**Error:**
```
C:\Users\RAILO\flutter\bin\flutter.bat --no-color build apk
Building with sound null safety
Running Gradle t... | 2022/01/21 | [
"https://Stackoverflow.com/questions/70800272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12752433/"
] | You can use `Series.str.get` to extract values from an `object` column with dictionaries in it.
```
df['idx'] = df['a'].str.get('word')
indices = df['idx'].to_list()
``` | Another option is to convert the column to a list, cast it to a DataFrame constructor. This creates a DataFrame where the columns correspond to dictionary keys and values correspond to dict values. Then simply select the relevant column/key and convert the values to list:
```
idx = pd.DataFrame(df['a'].tolist())['word... |
70,800,272 | I have a flutter app and its working fine in debug mode but when i run flutter build apk command for android apk it shows the following error.
The error is cannot run with sound null safety.
**Error:**
```
C:\Users\RAILO\flutter\bin\flutter.bat --no-color build apk
Building with sound null safety
Running Gradle t... | 2022/01/21 | [
"https://Stackoverflow.com/questions/70800272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12752433/"
] | You can use `Series.str.get` to extract values from an `object` column with dictionaries in it.
```
df['idx'] = df['a'].str.get('word')
indices = df['idx'].to_list()
``` | **Hi, you could just use a join**:
```
listElement = [''.join(i[1].values()) for i in df['a'].items()]
```
**Output:**
```
['3', '1', '0']
``` |
70,800,272 | I have a flutter app and its working fine in debug mode but when i run flutter build apk command for android apk it shows the following error.
The error is cannot run with sound null safety.
**Error:**
```
C:\Users\RAILO\flutter\bin\flutter.bat --no-color build apk
Building with sound null safety
Running Gradle t... | 2022/01/21 | [
"https://Stackoverflow.com/questions/70800272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12752433/"
] | Another option is to convert the column to a list, cast it to a DataFrame constructor. This creates a DataFrame where the columns correspond to dictionary keys and values correspond to dict values. Then simply select the relevant column/key and convert the values to list:
```
idx = pd.DataFrame(df['a'].tolist())['word... | **Hi, you could just use a join**:
```
listElement = [''.join(i[1].values()) for i in df['a'].items()]
```
**Output:**
```
['3', '1', '0']
``` |
8,383,680 | have a problem with object setters in a class.
I have the class GEOImage, where things like description, title etc. will be saved according
to an image.
```
@interface GEOImage : UIImage
{
NSString *title;
NSString *imgDescription;
NSString *latitude;
NSString *longitude;
NSDictionary *editInfo;
}... | 2011/12/05 | [
"https://Stackoverflow.com/questions/8383680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1055851/"
] | We can safely infer that `chosenImage` is not `nil`; if it were `nil`, sending it a message would simply do nothing, not crash.
(Also, I'm assuming that you meant `title` rather than `imgDescription` in your usage sample, or that you implemented `setImgDescription:` to set the `title` in turn.)
There are two possibil... | In fact, it was like Peter said: I never created an GEOImage. I now I create the GEOImage like this:
```
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info valueForKey:@"UIImagePickerControllerOriginalImage"];
NSURL *imgUR... |
41,676,391 | I am writing a web server, in which I recieve the data from a client through a `WinSock` socket, and parse the data into parts. Then, according to the method found and the resource requested, I want to build a new packet which I will send back to the client.
I have this function, used to build the packet to send nack ... | 2017/01/16 | [
"https://Stackoverflow.com/questions/41676391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6451874/"
] | Not such a good idea, but you can use jquery to select the radio by the value of the `value` attribute and disable the relevant radio (using the `prop` method):
```js
$('input[type="radio"][value=" Afternoon (1 PM - 5 PM)"]').prop('disabled', true);
$('input[type="radio"][value=" Evening (5 PM - 9 PM)"]').prop('disab... | ```js
$(document).ready(function(){
var testString="Afternoon (1 PM - 5 PM)";//show only this text control and hide other control
$.each($('input[type=radio]'),function(i,v){
if($.trim($(v).val())!=testString)// any condtion you can put here
{
$(v).addClass("disable").next().addClass("disable");
... |
20,113,895 | In my Android app I add `SearchBar` in headerview of `TableView`.
Problem is that when I scroll my `TableView` to load more data then my `SearchBar` automatically focus and table scroll to top.
I want to stop this auto focus. How do I do that? | 2013/11/21 | [
"https://Stackoverflow.com/questions/20113895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2621383/"
] | You can use your queries as derived tables and join on `ShowDate`.
```
SELECT T1.TotalShows,
T1.ScreenCapacity,
T1.ShowDate,
T2.TotalTicketsSold,
T2.Nett
FROM (
SELECT COUNT(showtimeId) AS TotalShows,
sum(sc.Capacity) AS ScreenCapacity,
ShowDate ------For all screens
... | Mybe this will work ?
```
SELECT
COUNT(showtimeId) AS TotalShows,
SUM(sc.Capacity) AS ScreenCapacity,
ShowDate ------For all screens,
,COUNT(ut.UserTicketID) AS TotalTicketsSold,
SUM(ISNULL((Price+ConvinienceCharge-DiscountAmount)/
(EntertainmentTax+BoxOfficeTax+1), 0)) AS Nett
FROM Shows... |
326,627 | Recently I watched a Youtube Video by
[Veritasium](https://www.youtube.com/watch?v=vqDbMEdLiCs)
He said we are actually feeling the rate of heat transfer, not the temperature.
But how do we feel temperature?
How is temperature different from heat and heat tranfer? | 2017/04/14 | [
"https://physics.stackexchange.com/questions/326627",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/122455/"
] | The answer to "How do we feel temperature" is "you define temperature in a way that is different from how physicists define it." [This video](https://www.youtube.com/watch?v=vqDbMEdLiCs) does an excellent job of showing the issue off.
In science, temperature is defined to be a measure of the energy of highly disorgani... | We are able to measure temperature because of the differences a temperature has upon the resultant bodies it affects. The temperature a body has is dependent upon its molecular structure and the vibration of its molecular construction. and and it is measurable, because of this difference between the two we are calculat... |
326,627 | Recently I watched a Youtube Video by
[Veritasium](https://www.youtube.com/watch?v=vqDbMEdLiCs)
He said we are actually feeling the rate of heat transfer, not the temperature.
But how do we feel temperature?
How is temperature different from heat and heat tranfer? | 2017/04/14 | [
"https://physics.stackexchange.com/questions/326627",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/122455/"
] | The answer to "How do we feel temperature" is "you define temperature in a way that is different from how physicists define it." [This video](https://www.youtube.com/watch?v=vqDbMEdLiCs) does an excellent job of showing the issue off.
In science, temperature is defined to be a measure of the energy of highly disorgani... | In a few words, temperature is a macroscopic property related to the kinetic energy of molecules.
What it **really is**, is a tricky question, because we don't know what **mass** is or what **force** is, but we know how to measure and relate each other and how to intuitively understand. Based on that, we can infer so... |
326,627 | Recently I watched a Youtube Video by
[Veritasium](https://www.youtube.com/watch?v=vqDbMEdLiCs)
He said we are actually feeling the rate of heat transfer, not the temperature.
But how do we feel temperature?
How is temperature different from heat and heat tranfer? | 2017/04/14 | [
"https://physics.stackexchange.com/questions/326627",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/122455/"
] | The answer to "How do we feel temperature" is "you define temperature in a way that is different from how physicists define it." [This video](https://www.youtube.com/watch?v=vqDbMEdLiCs) does an excellent job of showing the issue off.
In science, temperature is defined to be a measure of the energy of highly disorgani... | In short:
* **Temperature** is a measure of thermal energy.
* **Heat** (and **heat transfer**) is the *transfer* of thermal energy.
**Heat** is like **work**; work is energy and heat is energy, yes, but you cannot "have" work. You can *do* work. In the same way you can't "have" heat. Work is more correctly a *transfe... |
326,627 | Recently I watched a Youtube Video by
[Veritasium](https://www.youtube.com/watch?v=vqDbMEdLiCs)
He said we are actually feeling the rate of heat transfer, not the temperature.
But how do we feel temperature?
How is temperature different from heat and heat tranfer? | 2017/04/14 | [
"https://physics.stackexchange.com/questions/326627",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/122455/"
] | In a few words, temperature is a macroscopic property related to the kinetic energy of molecules.
What it **really is**, is a tricky question, because we don't know what **mass** is or what **force** is, but we know how to measure and relate each other and how to intuitively understand. Based on that, we can infer so... | We are able to measure temperature because of the differences a temperature has upon the resultant bodies it affects. The temperature a body has is dependent upon its molecular structure and the vibration of its molecular construction. and and it is measurable, because of this difference between the two we are calculat... |
326,627 | Recently I watched a Youtube Video by
[Veritasium](https://www.youtube.com/watch?v=vqDbMEdLiCs)
He said we are actually feeling the rate of heat transfer, not the temperature.
But how do we feel temperature?
How is temperature different from heat and heat tranfer? | 2017/04/14 | [
"https://physics.stackexchange.com/questions/326627",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/122455/"
] | In short:
* **Temperature** is a measure of thermal energy.
* **Heat** (and **heat transfer**) is the *transfer* of thermal energy.
**Heat** is like **work**; work is energy and heat is energy, yes, but you cannot "have" work. You can *do* work. In the same way you can't "have" heat. Work is more correctly a *transfe... | We are able to measure temperature because of the differences a temperature has upon the resultant bodies it affects. The temperature a body has is dependent upon its molecular structure and the vibration of its molecular construction. and and it is measurable, because of this difference between the two we are calculat... |
326,627 | Recently I watched a Youtube Video by
[Veritasium](https://www.youtube.com/watch?v=vqDbMEdLiCs)
He said we are actually feeling the rate of heat transfer, not the temperature.
But how do we feel temperature?
How is temperature different from heat and heat tranfer? | 2017/04/14 | [
"https://physics.stackexchange.com/questions/326627",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/122455/"
] | In a few words, temperature is a macroscopic property related to the kinetic energy of molecules.
What it **really is**, is a tricky question, because we don't know what **mass** is or what **force** is, but we know how to measure and relate each other and how to intuitively understand. Based on that, we can infer so... | In short:
* **Temperature** is a measure of thermal energy.
* **Heat** (and **heat transfer**) is the *transfer* of thermal energy.
**Heat** is like **work**; work is energy and heat is energy, yes, but you cannot "have" work. You can *do* work. In the same way you can't "have" heat. Work is more correctly a *transfe... |
63,255,407 | Edit: This question has gotten quite old and is no longer useful. Prestissimo isn't really useful any more now that Composer 2 is out. The way to use composer 2 in DDEV-Local v1.16 is `ddev config --composer-version=2`. In DDEV-Local v1.17 Composer 2 will be the default.
Original question:
I'd like to use [hirak/pres... | 2020/08/04 | [
"https://Stackoverflow.com/questions/63255407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/215713/"
] | In DDEV-Local v1.15+ you can globally put anything you want in the web container home directory using the [homeadditions feature](https://ddev.readthedocs.io/en/stable/users/extend/in-container-configuration/#in-container-home-directory-configuration), and in the web container the composer global configuration is in ~/... | In addition to what rfay said, and based on his solution here is another approach.
In your `.ddev/web-build/Dockerfile` add `RUN composer global require hirak/prestissimo`.
This will install `hirak/prestissimo` in the `/root/.composer` directory.
Then, in the `.ddev/homeadditions/.bash_aliases` add the following:
``... |
63,255,407 | Edit: This question has gotten quite old and is no longer useful. Prestissimo isn't really useful any more now that Composer 2 is out. The way to use composer 2 in DDEV-Local v1.16 is `ddev config --composer-version=2`. In DDEV-Local v1.17 Composer 2 will be the default.
Original question:
I'd like to use [hirak/pres... | 2020/08/04 | [
"https://Stackoverflow.com/questions/63255407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/215713/"
] | In DDEV-Local v1.15+ you can globally put anything you want in the web container home directory using the [homeadditions feature](https://ddev.readthedocs.io/en/stable/users/extend/in-container-configuration/#in-container-home-directory-configuration), and in the web container the composer global configuration is in ~/... | You can also update to composer 2 since it is fast enough to not need hirak. Update using `composer self-update --2` and then remove `hirak/prestissimo` with `composer global remove hirak/prestissimo`
resources:
* <https://github.com/hirak/prestissimo>
* <https://blog.packagist.com/composer-2-0-is-now-available/> - s... |
63,255,407 | Edit: This question has gotten quite old and is no longer useful. Prestissimo isn't really useful any more now that Composer 2 is out. The way to use composer 2 in DDEV-Local v1.16 is `ddev config --composer-version=2`. In DDEV-Local v1.17 Composer 2 will be the default.
Original question:
I'd like to use [hirak/pres... | 2020/08/04 | [
"https://Stackoverflow.com/questions/63255407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/215713/"
] | In addition to what rfay said, and based on his solution here is another approach.
In your `.ddev/web-build/Dockerfile` add `RUN composer global require hirak/prestissimo`.
This will install `hirak/prestissimo` in the `/root/.composer` directory.
Then, in the `.ddev/homeadditions/.bash_aliases` add the following:
``... | You can also update to composer 2 since it is fast enough to not need hirak. Update using `composer self-update --2` and then remove `hirak/prestissimo` with `composer global remove hirak/prestissimo`
resources:
* <https://github.com/hirak/prestissimo>
* <https://blog.packagist.com/composer-2-0-is-now-available/> - s... |
58,411,520 | After writing a file with the snippet below
```
with open("temp.trig", "wb") as f:
f.write(data)
```
I use `curl` to load it into the server
```
curl -X POST -F file=@"temp.trig" -H "Accept: application/json" http://localhost:8081/demo/upload
```
which works fine.
I am trying to replace the `curl` wi... | 2019/10/16 | [
"https://Stackoverflow.com/questions/58411520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2302244/"
] | Modern task manager uses internal private Windows functionality for its stay on top behaviour. The system does not make this available to user windows. The functionality that task manager uses simply isn't available to you.
Related question: [Is Task Manager a special kind of 'Always on Top' window for windows 10?](ht... | Just use the **Object Inspector** at design time to set the form's `FormStyle` property to `fsStayOnTop`. |
58,411,520 | After writing a file with the snippet below
```
with open("temp.trig", "wb") as f:
f.write(data)
```
I use `curl` to load it into the server
```
curl -X POST -F file=@"temp.trig" -H "Accept: application/json" http://localhost:8081/demo/upload
```
which works fine.
I am trying to replace the `curl` wi... | 2019/10/16 | [
"https://Stackoverflow.com/questions/58411520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2302244/"
] | Modern task manager uses internal private Windows functionality for its stay on top behaviour. The system does not make this available to user windows. The functionality that task manager uses simply isn't available to you.
Related question: [Is Task Manager a special kind of 'Always on Top' window for windows 10?](ht... | The code from the original post might work on a main form, but will not work on a secondary form. fsStayOnTop is only part of the solution for a secondary form. Below is an easy solution for making a secondary form stay on top while the main form is obscured by other applications - without resorting to showmodal or for... |
56,398,716 | I have an angular application that call my back-end written in Asp.net c#. The back-end works correctly (already used by a mobile application) but one entry point does not behave correctly while being hit by the angular Application.
I Serialize a tupple array of and send it to the API, but when API entry point gets hi... | 2019/05/31 | [
"https://Stackoverflow.com/questions/56398716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9414420/"
] | Tuples in C# are treated like classes, whereas you're setting up your client-side model as if they're arrays. Try something like this:
```
var listUpdate = new Array<{item1: number, item2: boolean}>();
arr.forEach(re => {
let el: {item1: number, item2: boolean} = {item1: re.userId, item2: re.wasThere};
listUpdate... | Binding happens by name. From [Model Binding](https://learn.microsoft.com/en-us/aspnet/core/mvc/models/model-binding?view=aspnetcore-2.2):
"MVC will try to bind request data to the action parameters by name. MVC will look for values for each parameter using the parameter name and the names of its public settable proper... |
549,779 | I have an AZURE virtual machine with a MySQL server installed on it running ubuntu 13.04. I am trying to remote connect to the MySQL server however get the simple error "Can't connect to MySQL server on {IP}"
I have already done the follow:
```
* commented out the bind-address within the /etc/mysql/my.cnf
* commented... | 2013/10/31 | [
"https://serverfault.com/questions/549779",
"https://serverfault.com",
"https://serverfault.com/users/110586/"
] | The 'official manual' quoted above didnt work for me and seems to set up a ssh tunnel to accomplish this... even after following the guide it still didnt work.
Heres my working solution
For a Ubuntu Azure VM see:
<https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-create-lamp-stack/>
Sp... | Check your firewall uring sudo ufw status. |
549,779 | I have an AZURE virtual machine with a MySQL server installed on it running ubuntu 13.04. I am trying to remote connect to the MySQL server however get the simple error "Can't connect to MySQL server on {IP}"
I have already done the follow:
```
* commented out the bind-address within the /etc/mysql/my.cnf
* commented... | 2013/10/31 | [
"https://serverfault.com/questions/549779",
"https://serverfault.com",
"https://serverfault.com/users/110586/"
] | The 'official manual' quoted above didnt work for me and seems to set up a ssh tunnel to accomplish this... even after following the guide it still didnt work.
Heres my working solution
For a Ubuntu Azure VM see:
<https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-create-lamp-stack/>
Sp... | [This](https://azure.microsoft.com/en-us/blog/create-your-own-dedicated-mysql-server-for-your-azure-websites/) succinct guide was useful for me to get mine to work.
While there are other essential steps [that I had already done] there, the one I was missing was this:
3306 port is not opened by default, hence you need... |
549,779 | I have an AZURE virtual machine with a MySQL server installed on it running ubuntu 13.04. I am trying to remote connect to the MySQL server however get the simple error "Can't connect to MySQL server on {IP}"
I have already done the follow:
```
* commented out the bind-address within the /etc/mysql/my.cnf
* commented... | 2013/10/31 | [
"https://serverfault.com/questions/549779",
"https://serverfault.com",
"https://serverfault.com/users/110586/"
] | [This](https://azure.microsoft.com/en-us/blog/create-your-own-dedicated-mysql-server-for-your-azure-websites/) succinct guide was useful for me to get mine to work.
While there are other essential steps [that I had already done] there, the one I was missing was this:
3306 port is not opened by default, hence you need... | Check your firewall uring sudo ufw status. |
52,461,392 | I'm trying to create code that will take a given integer, then output a set of integers, all of which are rotations of digits of the input integer.
Thus, if I inputted '197', the output should be '197', '971', and '791'.
However, when I try:
```
def rotation(n):
rotations = set()
for i in range( len( str(n) ) ):... | 2018/09/22 | [
"https://Stackoverflow.com/questions/52461392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10240052/"
] | You're almost there. Except you're erasing the input n at each iteration. Use another variable name.
```
def rotation(n):
rotations = set()
for i in range( len( str(n) ) ):
m = int( str(n)[i:] + str(n)[:i] )
rotations.add(m)
return rotations
print(rotation(197))
```
I would write it more like this, us... | The way you have your code structured does duplicate rotation because you reassign `n` on each step of the loop and use the iteration variable `i` in your slices.
So the process in the loop from your example is:
* `i = 0`
+ You have `n = 197` and the rotation logic does nothing with `i = 0` so you add `197` to rotat... |
61,090,282 | How would I add user input validation to the following code? not sure whether to use try and catch or if there is some other way that would be great, cheers :)
```
private static int ReadInteger(string prompt)
{
Console.Write(prompt + ": > ");
return Convert.ToInt32(Console.ReadLine());
}
... | 2020/04/07 | [
"https://Stackoverflow.com/questions/61090282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13253690/"
] | Without calculating the largest text size, you can simply use a `BoxConstraints` with a `minWidth` and `maxWidth` properties like this :
```
ToggleButtons(
children: [Text('long text'), Text('text')],
constraints: BoxConstraints(minWidth: 70, maxWidth: 70, minHeight: kMinInteractiveDimension),
isSelected: [true,... | I had the similar issue today when I had to create custom toggle buttons, where toggle button items where loading from a list of various options of various text sizes and client was ok to wrap the longer text options.
With in built toggle button, it would just fix the size for all items. So when I created the custom t... |
61,090,282 | How would I add user input validation to the following code? not sure whether to use try and catch or if there is some other way that would be great, cheers :)
```
private static int ReadInteger(string prompt)
{
Console.Write(prompt + ": > ");
return Convert.ToInt32(Console.ReadLine());
}
... | 2020/04/07 | [
"https://Stackoverflow.com/questions/61090282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13253690/"
] | Without calculating the largest text size, you can simply use a `BoxConstraints` with a `minWidth` and `maxWidth` properties like this :
```
ToggleButtons(
children: [Text('long text'), Text('text')],
constraints: BoxConstraints(minWidth: 70, maxWidth: 70, minHeight: kMinInteractiveDimension),
isSelected: [true,... | This is difficult to do without some custom layout code and re-implementing the toggle button, here I am using the [boxy](https://pub.dev/packages/boxy) package to make each button the same size:
[](https://i.stack.imgur.com/DSIMn.png)
```dart
class MyWidget extends StatefulWid... |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | Use colons to separate hours, minutes and seconds: "05-MAY-09 03:55:50" | That constructor is deprecated (since jdk 1.1).
It not even valid in java5
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html>
You should
```
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date date = sdf.parse("05-MAY-09 03:55:50");
``` |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | That [Date constructor is deprecated](http://java.sun.com/javase/6/docs/api/java/util/Date.html#Date(java.lang.String)) for a reason.
You should be using a [DateFormat](http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html) / [SimpleDateFormat](http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat... | Use colons to separate hours, minutes and seconds: "05-MAY-09 03:55:50" |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | Other than the fact that you are using a deprecated method (you should be using [SimpleDateFormat](http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html) instead), this should work:
```
new Date("05-MAY-09 03:55:50");
```
Also check out [Joda Time](http://joda-time.sourceforge.net/) | Use colons to separate hours, minutes and seconds: "05-MAY-09 03:55:50" |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | That [Date constructor is deprecated](http://java.sun.com/javase/6/docs/api/java/util/Date.html#Date(java.lang.String)) for a reason.
You should be using a [DateFormat](http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html) / [SimpleDateFormat](http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat... | That constructor is deprecated (since jdk 1.1).
It not even valid in java5
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html>
You should
```
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date date = sdf.parse("05-MAY-09 03:55:50");
``` |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | Other than the fact that you are using a deprecated method (you should be using [SimpleDateFormat](http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html) instead), this should work:
```
new Date("05-MAY-09 03:55:50");
```
Also check out [Joda Time](http://joda-time.sourceforge.net/) | That constructor is deprecated (since jdk 1.1).
It not even valid in java5
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html>
You should
```
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date date = sdf.parse("05-MAY-09 03:55:50");
``` |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | Don't use this method, as it has been deprecated for years (and years). Use DateFormat.parse() in which you can easily define the format you want to parse. | That constructor is deprecated (since jdk 1.1).
It not even valid in java5
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html>
You should
```
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date date = sdf.parse("05-MAY-09 03:55:50");
``` |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | That [Date constructor is deprecated](http://java.sun.com/javase/6/docs/api/java/util/Date.html#Date(java.lang.String)) for a reason.
You should be using a [DateFormat](http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html) / [SimpleDateFormat](http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat... | Other than the fact that you are using a deprecated method (you should be using [SimpleDateFormat](http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html) instead), this should work:
```
new Date("05-MAY-09 03:55:50");
```
Also check out [Joda Time](http://joda-time.sourceforge.net/) |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | That [Date constructor is deprecated](http://java.sun.com/javase/6/docs/api/java/util/Date.html#Date(java.lang.String)) for a reason.
You should be using a [DateFormat](http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html) / [SimpleDateFormat](http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat... | Don't use this method, as it has been deprecated for years (and years). Use DateFormat.parse() in which you can easily define the format you want to parse. |
852,887 | ```
new Date("05-MAY-09 03.55.50")
```
is any thing wrong with this ? i am getting illegalArgumentException | 2009/05/12 | [
"https://Stackoverflow.com/questions/852887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96180/"
] | Other than the fact that you are using a deprecated method (you should be using [SimpleDateFormat](http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html) instead), this should work:
```
new Date("05-MAY-09 03:55:50");
```
Also check out [Joda Time](http://joda-time.sourceforge.net/) | Don't use this method, as it has been deprecated for years (and years). Use DateFormat.parse() in which you can easily define the format you want to parse. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.