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
81,049
I was thinking of exploring Lovecraftian horror the other day, and the thought occurred to me: say a couple decades after the American civil war, there was a certain city in New England of 10,000 people whose inhabitants committed atrocities, summoned beings so heinous and devolved into creatures themselves over time t...
2017/05/16
[ "https://worldbuilding.stackexchange.com/questions/81049", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/-1/" ]
**Absolutely** In fact, there are multiple Reverse [Bielefeld Conspiracies](https://en.wikipedia.org/wiki/Bielefeld_Conspiracy) going on right now, across multiple locations in the US, and many more abroad. There are 3 locations in Maine, 1 in Washington and 1 in Arizona that I am currently aware of. (shh, don't tell...
**You probably don't want to cut contact. Keep an eye on them. But do move them.** So, put them in a very remote part of a military training complex. No civilians can go there. Area 51 is for the public eye, this two levels more secure. Place this village in a valley so no easy line of sight. Put up multiple rings w...
81,049
I was thinking of exploring Lovecraftian horror the other day, and the thought occurred to me: say a couple decades after the American civil war, there was a certain city in New England of 10,000 people whose inhabitants committed atrocities, summoned beings so heinous and devolved into creatures themselves over time t...
2017/05/16
[ "https://worldbuilding.stackexchange.com/questions/81049", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/-1/" ]
The US has closed off towns before ---------------------------------- Adapt the model used for [Hanford](https://en.wikipedia.org/wiki/Hanford,_Washington) during the Manhattan Project. Or maybe you model it after [Centralia](https://en.wikipedia.org/wiki/Centralia,_Pennsylvania), which was condemned in the 1990s due ...
It can be done, but it is hard. It should be masked *by a different activity*. For example, it can be some factory, next to the Mexican border, working with many legal and illegal migrants. Below the factory, you can have your hidden city. It shouldn't even have to be dug in the ground. The black & dirty activites c...
81,049
I was thinking of exploring Lovecraftian horror the other day, and the thought occurred to me: say a couple decades after the American civil war, there was a certain city in New England of 10,000 people whose inhabitants committed atrocities, summoned beings so heinous and devolved into creatures themselves over time t...
2017/05/16
[ "https://worldbuilding.stackexchange.com/questions/81049", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/-1/" ]
**Absolutely** In fact, there are multiple Reverse [Bielefeld Conspiracies](https://en.wikipedia.org/wiki/Bielefeld_Conspiracy) going on right now, across multiple locations in the US, and many more abroad. There are 3 locations in Maine, 1 in Washington and 1 in Arizona that I am currently aware of. (shh, don't tell...
1. Cities are in no way, shape or form self-sufficient. Thus, if you sealed it off, enterprising residents (pseudo-blockade runners) would soon travel cross-country to get food and other supplies from others. 2. The people that these pseudo-blockade runners buy from would ask where they came from, and... most important...
81,049
I was thinking of exploring Lovecraftian horror the other day, and the thought occurred to me: say a couple decades after the American civil war, there was a certain city in New England of 10,000 people whose inhabitants committed atrocities, summoned beings so heinous and devolved into creatures themselves over time t...
2017/05/16
[ "https://worldbuilding.stackexchange.com/questions/81049", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/-1/" ]
Cover it up with something else... Something scary -------------------------------------------------- Do you really know what's going on at the Hanford Site? Supposedly all the riverside reactors are shutdown with all the auxiliary buildings torn down. But there are still vast complexes, many underground (e.g. the 200...
**You probably don't want to cut contact. Keep an eye on them. But do move them.** So, put them in a very remote part of a military training complex. No civilians can go there. Area 51 is for the public eye, this two levels more secure. Place this village in a valley so no easy line of sight. Put up multiple rings w...
5,437,870
I'm currently using mysqldump to back up databases that are growing rapidly in size. Though I run it late at night, there have been occasional problems when it happens to run during a moment of high traffic (which happens at night sometimes). For example, last night one of my sites locked up just after the time of the ...
2011/03/25
[ "https://Stackoverflow.com/questions/5437870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/151472/" ]
Two thoughts: 1. run the slave. If nothing else, it gives you a warm spare for your production traffic in case of failure. You can also run reports and tools from it, freeing up cycles from your production server. 2. get to innodb and use mysqldump --single-transaction [(see man page)](http://dev.mysql.com/doc/refman/...
I use [Percona Xtrabackup](http://www.percona.com/docs/wiki/percona-xtrabackup%3astart), which is similar to [InnoDB Hot Backup](http://www.innodb.com/products/hot-backup/) with more functionality and is distributed for free. Xtrabackup takes snapshots without locking innodb tables and will record the current master lo...
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
None of my dictionaries from the 80s contain the word, though it is in the Merriam-Webster's Collegiate Dictionary 10th edition from 1993 I.B.S.N. 0-87779-709-9. The definition in my Merriam-Webster's 10th collegiate edition is "*n* (ca. 1963) *slang*: an unattractive or offensive person." It is listed as two words. I...
***Early underworld use of 'douchebag'*** Here are three early (1939–1950) instances, courtesy of Hathi Trust and Google Books search results, of *douchebag* used in a (presumably) pejorative sense. First, from a footnote in the preface to the first edition of Hickman Powell, [*Ninety Times Guilty*](https://babel.hath...
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
Yes, the slang usage of "douchebag" was known before the '80s. The following interesting piece from [dialect blog](http://dialectblog.com/2011/07/01/on-the-evolution-of-douchebag/) traces douchebag usage as a slang term from its earliest documented usage in 1951. Though there are usage instances during the following de...
My understanding (derived from other posters) is that "douchebag" first made it into the "literature" in 1951. It would have been "popularized" (in the U.S.) during the [sexual revolution](https://en.wikipedia.org/wiki/Sexual_revolution) of the 1960s and 1970s, at least for oral (spoken) use. (No pun intended.) That's...
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
Yes, the slang usage of "douchebag" was known before the '80s. The following interesting piece from [dialect blog](http://dialectblog.com/2011/07/01/on-the-evolution-of-douchebag/) traces douchebag usage as a slang term from its earliest documented usage in 1951. Though there are usage instances during the following de...
***Early underworld use of 'douchebag'*** Here are three early (1939–1950) instances, courtesy of Hathi Trust and Google Books search results, of *douchebag* used in a (presumably) pejorative sense. First, from a footnote in the preface to the first edition of Hickman Powell, [*Ninety Times Guilty*](https://babel.hath...
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
None of my dictionaries from the 80s contain the word, though it is in the Merriam-Webster's Collegiate Dictionary 10th edition from 1993 I.B.S.N. 0-87779-709-9. The definition in my Merriam-Webster's 10th collegiate edition is "*n* (ca. 1963) *slang*: an unattractive or offensive person." It is listed as two words. I...
My understanding (derived from other posters) is that "douchebag" first made it into the "literature" in 1951. It would have been "popularized" (in the U.S.) during the [sexual revolution](https://en.wikipedia.org/wiki/Sexual_revolution) of the 1960s and 1970s, at least for oral (spoken) use. (No pun intended.) That's...
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
My understanding (derived from other posters) is that "douchebag" first made it into the "literature" in 1951. It would have been "popularized" (in the U.S.) during the [sexual revolution](https://en.wikipedia.org/wiki/Sexual_revolution) of the 1960s and 1970s, at least for oral (spoken) use. (No pun intended.) That's...
Too long for a comment. Regarding the popularizing of the phrase — Bruce Springsteen's *Blinded by the Light* song, which was rerecorded in 1976 by Manfred Mann's Earth Band, had a line in the lyrics that was mostly misheard and is one of the more notorious mondegreens in songdom. > > Manfred Mann's Earth Band's reco...
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
To quote from James Jones's 1951, debut novel, *From Here To Eternity* (p. 308 in [the version Google Books has online](http://books.google.de/books?id=qbpqAAAAQBAJ)): > > “The trouble with you, Pete,” the voice that did not seem to come with him but from that cigaret said savagely, “is that you can’t see any further...
Hell yes. Just ask someone over the age of about 45! This isn't obscure or mysterious. Everyone in school said "douche" and "douchebag" in my childhood in the 1970s and 1980s. Northeastern USA. Very common. Also see SNL circa 1980; <https://www.youtube.com/watch?v=C6XF4RxU7xQ>
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
Yes, the slang usage of "douchebag" was known before the '80s. The following interesting piece from [dialect blog](http://dialectblog.com/2011/07/01/on-the-evolution-of-douchebag/) traces douchebag usage as a slang term from its earliest documented usage in 1951. Though there are usage instances during the following de...
Hell yes. Just ask someone over the age of about 45! This isn't obscure or mysterious. Everyone in school said "douche" and "douchebag" in my childhood in the 1970s and 1980s. Northeastern USA. Very common. Also see SNL circa 1980; <https://www.youtube.com/watch?v=C6XF4RxU7xQ>
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
***Early underworld use of 'douchebag'*** Here are three early (1939–1950) instances, courtesy of Hathi Trust and Google Books search results, of *douchebag* used in a (presumably) pejorative sense. First, from a footnote in the preface to the first edition of Hickman Powell, [*Ninety Times Guilty*](https://babel.hath...
Hell yes. Just ask someone over the age of about 45! This isn't obscure or mysterious. Everyone in school said "douche" and "douchebag" in my childhood in the 1970s and 1980s. Northeastern USA. Very common. Also see SNL circa 1980; <https://www.youtube.com/watch?v=C6XF4RxU7xQ>
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
None of my dictionaries from the 80s contain the word, though it is in the Merriam-Webster's Collegiate Dictionary 10th edition from 1993 I.B.S.N. 0-87779-709-9. The definition in my Merriam-Webster's 10th collegiate edition is "*n* (ca. 1963) *slang*: an unattractive or offensive person." It is listed as two words. I...
Too long for a comment. Regarding the popularizing of the phrase — Bruce Springsteen's *Blinded by the Light* song, which was rerecorded in 1976 by Manfred Mann's Earth Band, had a line in the lyrics that was mostly misheard and is one of the more notorious mondegreens in songdom. > > Manfred Mann's Earth Band's reco...
343,893
This is the original sentence I wrote: > > She seems fascinated **with** her married life. > > > But my proofreader thinks that "with" should be changed into "by": > > She seems fascinated **by** her married life. > > > I noticed that someone else asked a similar question before, but it seems like not much ...
2016/08/21
[ "https://english.stackexchange.com/questions/343893", "https://english.stackexchange.com", "https://english.stackexchange.com/users/164583/" ]
***Early underworld use of 'douchebag'*** Here are three early (1939–1950) instances, courtesy of Hathi Trust and Google Books search results, of *douchebag* used in a (presumably) pejorative sense. First, from a footnote in the preface to the first edition of Hickman Powell, [*Ninety Times Guilty*](https://babel.hath...
Too long for a comment. Regarding the popularizing of the phrase — Bruce Springsteen's *Blinded by the Light* song, which was rerecorded in 1976 by Manfred Mann's Earth Band, had a line in the lyrics that was mostly misheard and is one of the more notorious mondegreens in songdom. > > Manfred Mann's Earth Band's reco...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
To enumerate all prime number below a limit you could use [Sieve of Eratosthenes](http://rosettacode.org/wiki/Sieve_of_Eratosthenes#C.2B.2B) as mentioned by [@David Schwartz in the comment](https://stackoverflow.com/a/8633196/4279): ``` #include <cmath> #include <iostream> #include <vector> #include <stdint.h> namesp...
Your `IsPrime` function looks OK. This won't help it's speed very much, but it will a little... ``` bool isPrime(unsigned int number) { if (number <= 1) { return false; } else if (number % 2 == 0) { return number == 2; } else { for (unsigned int i = 3; true; i += 2) { const unsigned...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
There are dozens of possible optimizations. The most obvious -- why are you multiplying `i` by itself every pass in the loop?! Just calculate the loop cut off *once*. And why `i++`?! After you test 2, there's no reason to test 4, 6, or 8. You can test 2, and then start from 3 adding *2* each time instead of one. Also...
To enumerate all prime number below a limit you could use [Sieve of Eratosthenes](http://rosettacode.org/wiki/Sieve_of_Eratosthenes#C.2B.2B) as mentioned by [@David Schwartz in the comment](https://stackoverflow.com/a/8633196/4279): ``` #include <cmath> #include <iostream> #include <vector> #include <stdint.h> namesp...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
To enumerate all prime number below a limit you could use [Sieve of Eratosthenes](http://rosettacode.org/wiki/Sieve_of_Eratosthenes#C.2B.2B) as mentioned by [@David Schwartz in the comment](https://stackoverflow.com/a/8633196/4279): ``` #include <cmath> #include <iostream> #include <vector> #include <stdint.h> namesp...
For every prime number `n>=5`, `n mod 6 returns 1` or `n mod 6 returns 5`. If you check these candidates for primeness by seeing if any prime number that is less than or equal to sqrt(n) divides a candidate could help eliminate many checks. When you do find a prime number, you could add to a list or, just add up to get...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
I have done that before. The point is that you don't have to divide your number by all odd numbers smaller than it, but by all PRIME numbers smaller than it. So, pass the list of the prime numbers you had found to the function and divide your new number by each them.
Your `IsPrime` function looks OK. This won't help it's speed very much, but it will a little... ``` bool isPrime(unsigned int number) { if (number <= 1) { return false; } else if (number % 2 == 0) { return number == 2; } else { for (unsigned int i = 3; true; i += 2) { const unsigned...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
I have done that before. The point is that you don't have to divide your number by all odd numbers smaller than it, but by all PRIME numbers smaller than it. So, pass the list of the prime numbers you had found to the function and divide your new number by each them.
For every prime number `n>=5`, `n mod 6 returns 1` or `n mod 6 returns 5`. If you check these candidates for primeness by seeing if any prime number that is less than or equal to sqrt(n) divides a candidate could help eliminate many checks. When you do find a prime number, you could add to a list or, just add up to get...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
I have done that before. The point is that you don't have to divide your number by all odd numbers smaller than it, but by all PRIME numbers smaller than it. So, pass the list of the prime numbers you had found to the function and divide your new number by each them.
As others have pointed out, you can cut your work in half by avoiding even numbers. However, avoiding even numbers after 2 is just the first part of using a sieve: if you filter by every prime number found up to the square root of a particular number that you want to test, you can check by only those numbers. Here is...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
There are dozens of possible optimizations. The most obvious -- why are you multiplying `i` by itself every pass in the loop?! Just calculate the loop cut off *once*. And why `i++`?! After you test 2, there's no reason to test 4, 6, or 8. You can test 2, and then start from 3 adding *2* each time instead of one. Also...
For every prime number `n>=5`, `n mod 6 returns 1` or `n mod 6 returns 5`. If you check these candidates for primeness by seeing if any prime number that is less than or equal to sqrt(n) divides a candidate could help eliminate many checks. When you do find a prime number, you could add to a list or, just add up to get...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
There are dozens of possible optimizations. The most obvious -- why are you multiplying `i` by itself every pass in the loop?! Just calculate the loop cut off *once*. And why `i++`?! After you test 2, there's no reason to test 4, 6, or 8. You can test 2, and then start from 3 adding *2* each time instead of one. Also...
As others have pointed out, you can cut your work in half by avoiding even numbers. However, avoiding even numbers after 2 is just the first part of using a sieve: if you filter by every prime number found up to the square root of a particular number that you want to test, you can check by only those numbers. Here is...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
For every prime number `n>=5`, `n mod 6 returns 1` or `n mod 6 returns 5`. If you check these candidates for primeness by seeing if any prime number that is less than or equal to sqrt(n) divides a candidate could help eliminate many checks. When you do find a prime number, you could add to a list or, just add up to get...
As others have pointed out, you can cut your work in half by avoiding even numbers. However, avoiding even numbers after 2 is just the first part of using a sieve: if you filter by every prime number found up to the square root of a particular number that you want to test, you can check by only those numbers. Here is...
7,167
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ``` int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if...
2011/12/26
[ "https://codereview.stackexchange.com/questions/7167", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/-1/" ]
To enumerate all prime number below a limit you could use [Sieve of Eratosthenes](http://rosettacode.org/wiki/Sieve_of_Eratosthenes#C.2B.2B) as mentioned by [@David Schwartz in the comment](https://stackoverflow.com/a/8633196/4279): ``` #include <cmath> #include <iostream> #include <vector> #include <stdint.h> namesp...
As others have pointed out, you can cut your work in half by avoiding even numbers. However, avoiding even numbers after 2 is just the first part of using a sieve: if you filter by every prime number found up to the square root of a particular number that you want to test, you can check by only those numbers. Here is...
71,627,150
I have a variable of a large JSON data of students' data of different classes containing their names and numbers respectively. The variable is "data" and here is what the variable contains: ``` { "Class001": [ { "Jesse": 001 }, { "Adam": 002 } ], "Class002": [ { "Jill": 111 ...
2022/03/26
[ "https://Stackoverflow.com/questions/71627150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17414714/" ]
i have created a file.json with: ``` { "Class001": [ { "Jesse": "001" }, { "Adam": "002" } ], "Class002": [ { "Jill": "111" }, { "Ray": "112" } ] } ``` this playbook does the job: ``` - hosts: localhost gather_facts:...
A dictionary is a better structure to store students' names and numbers. Optionally, store the dictionaries instead of lists ```yaml - copy: dest: "files/{{ item.key }}.yml" content: "{{ item.value|combine|to_nice_yaml }}" loop: "{{ json|dict2items }}" ``` gives ```yaml shell> cat files/Cl...
212,203
I used to have my website hosted through Godaddy and 4 months ago something weird started happening. Every time that I would make changes to my site, it wouldn't show up on the live website. The only exception was the homepage. Every change on the homepage would show up on the live website. I did what everyone then to...
2015/12/17
[ "https://wordpress.stackexchange.com/questions/212203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85502/" ]
Here is an example of getting the user IDs, looping through each, grabbing a meta\_key as an array, adding new values to it and remove old values, saving the meta back, then grabbing it again to loop through each item in the array for output. Array is just an example of duplicate keys. ``` $user_query = new WP_User_Qu...
I was a long time looking for a solution to this type of query in wp\_usermeta and now I can sort the values for each registered user creating a query and making use of a LEFT JOIN using the wpdb class, I know that this post is a bit outdated but I felt compelled to share my script because your post makes me persist un...
166,794
I got white blank page after copying the functions.php to my child theme. How can I change "like\_escape"? What file can I find that? And I see this notice: ``` Notice: like_escape is deprecated since version 4.0! Use wpdb::esc_like() instead. in /home7/homecre1/public_html/betasite/wp-includes/functions.php on line...
2014/10/29
[ "https://wordpress.stackexchange.com/questions/166794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62725/" ]
Reordering the way you want is really pretty trivial. Proof of concept: ``` $p = array(1,2,3); var_dump($p); array_push($p,array_shift($p)); var_dump($p); ``` With the WordPress code: ``` $p = get_posts('posts_per_page=3'); array_push($p,array_shift($p)); var_dump($p); ``` To make it more interesting, you can do...
I don't think WordPress offers any way to order posts as you like. It has `ASC` and `DESC` order to list posts. But you can create a custom field for each carousel post to define carousel item orders. Let's say if you created custom field named `carousel-order` and add numerical value to each post. Then you can add c...
166,794
I got white blank page after copying the functions.php to my child theme. How can I change "like\_escape"? What file can I find that? And I see this notice: ``` Notice: like_escape is deprecated since version 4.0! Use wpdb::esc_like() instead. in /home7/homecre1/public_html/betasite/wp-includes/functions.php on line...
2014/10/29
[ "https://wordpress.stackexchange.com/questions/166794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62725/" ]
Reordering the way you want is really pretty trivial. Proof of concept: ``` $p = array(1,2,3); var_dump($p); array_push($p,array_shift($p)); var_dump($p); ``` With the WordPress code: ``` $p = get_posts('posts_per_page=3'); array_push($p,array_shift($p)); var_dump($p); ``` To make it more interesting, you can do...
Thanks for your ideas. I ended up creating two different queries for the carousel re-ordering using offset: The first query displays the third most recent post: ``` $args = array( 'posts_per_page' => 1, 'offset'=> 2 ); $thirdPost = get_posts( $args ); ``` and then spit the required fields into the first carousel s...
20,480,578
I'm a C noob, going back to school for my masters in CS so I'm taking some time to ramp up my skills. I wanted to see if anybody could lend some assistance on why I'm having problems compiling the following code. I've been following the videos on WiBit.net and develop on a 64 bit Linux environment (Ubuntu 13.10). I am ...
2013/12/09
[ "https://Stackoverflow.com/questions/20480578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3083657/" ]
strcmpi problem: strcasecmp() is the posix standard and so is it in linux. strupr and strlwr doesn't exist in glibc, although you can implement them with a single line of code, as this: [c - convert a mixed-case string to all lower case](https://stackoverflow.com/questions/2661766/c-convert-a-mixed-case-string-to-all...
As you noted, the *gets* function is unsafe because it does not perform any boundary checking: you have called it with a 255-character string buffer, but if another program wrote a line longer than 255 characters, it could write data into your process's stack, and thereby cause your process to execute malicious code (o...
24,897,801
I'm trying to allow CORS in node.js but the problem is that I can't set `*` to `Access-Control-Allow-Origin` if `Access-Control-Allow-Credentials` is set. Also the specification said I can't do an array or comma separated value for `Access-Control-Allow-Origin` and the suggested method would be to do something similar...
2014/07/22
[ "https://Stackoverflow.com/questions/24897801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/775119/" ]
Not sure if this is to late but I solved it by setting: `res.setHeader("Access-Control-Allow-Origin", req.headers.origin);` This will simply allow every connection as the headers.origin will be sent with every query. You may want to write a function to check if the req.headers.origin is a whitelisted domain (from a h...
Check your whitelist against what your req.headers.origin e.g. ``` var origins = ['a.com', 'b.com', 'c.com', 'boobies.com']; for(var i=0;i<origins.length;i++){ var origin = origins[i]; if(req.headers.origin.indexOf(origin) > -1){ res.setHeader('Access-Control-Allow-Origin', req.headers.origin); ...
24,897,801
I'm trying to allow CORS in node.js but the problem is that I can't set `*` to `Access-Control-Allow-Origin` if `Access-Control-Allow-Credentials` is set. Also the specification said I can't do an array or comma separated value for `Access-Control-Allow-Origin` and the suggested method would be to do something similar...
2014/07/22
[ "https://Stackoverflow.com/questions/24897801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/775119/" ]
Not sure if this is to late but I solved it by setting: `res.setHeader("Access-Control-Allow-Origin", req.headers.origin);` This will simply allow every connection as the headers.origin will be sent with every query. You may want to write a function to check if the req.headers.origin is a whitelisted domain (from a h...
Here's a simple middleware function to serve up the correct CORS header from a whitelist. Setting this near the top of your express app will allow all your routes to set the proper header from the whitelist before serving up content. ``` app.use(function(req, res, next){ var whitelist = ['localhost:4000', 'localhos...
24,897,801
I'm trying to allow CORS in node.js but the problem is that I can't set `*` to `Access-Control-Allow-Origin` if `Access-Control-Allow-Credentials` is set. Also the specification said I can't do an array or comma separated value for `Access-Control-Allow-Origin` and the suggested method would be to do something similar...
2014/07/22
[ "https://Stackoverflow.com/questions/24897801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/775119/" ]
Here is what I use in my express application to allow multiple origins ``` app.use((req, res, next) => { const allowedOrigins = ['http://127.0.0.1:8020', 'http://localhost:8020', 'http://127.0.0.1:9000', 'http://localhost:9000']; const origin = req.headers.origin; if (allowedOrigins.includes(origin)) { re...
Not sure if this is to late but I solved it by setting: `res.setHeader("Access-Control-Allow-Origin", req.headers.origin);` This will simply allow every connection as the headers.origin will be sent with every query. You may want to write a function to check if the req.headers.origin is a whitelisted domain (from a h...
24,897,801
I'm trying to allow CORS in node.js but the problem is that I can't set `*` to `Access-Control-Allow-Origin` if `Access-Control-Allow-Credentials` is set. Also the specification said I can't do an array or comma separated value for `Access-Control-Allow-Origin` and the suggested method would be to do something similar...
2014/07/22
[ "https://Stackoverflow.com/questions/24897801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/775119/" ]
Here is what I use in my express application to allow multiple origins ``` app.use((req, res, next) => { const allowedOrigins = ['http://127.0.0.1:8020', 'http://localhost:8020', 'http://127.0.0.1:9000', 'http://localhost:9000']; const origin = req.headers.origin; if (allowedOrigins.includes(origin)) { re...
Check your whitelist against what your req.headers.origin e.g. ``` var origins = ['a.com', 'b.com', 'c.com', 'boobies.com']; for(var i=0;i<origins.length;i++){ var origin = origins[i]; if(req.headers.origin.indexOf(origin) > -1){ res.setHeader('Access-Control-Allow-Origin', req.headers.origin); ...
24,897,801
I'm trying to allow CORS in node.js but the problem is that I can't set `*` to `Access-Control-Allow-Origin` if `Access-Control-Allow-Credentials` is set. Also the specification said I can't do an array or comma separated value for `Access-Control-Allow-Origin` and the suggested method would be to do something similar...
2014/07/22
[ "https://Stackoverflow.com/questions/24897801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/775119/" ]
Here is what I use in my express application to allow multiple origins ``` app.use((req, res, next) => { const allowedOrigins = ['http://127.0.0.1:8020', 'http://localhost:8020', 'http://127.0.0.1:9000', 'http://localhost:9000']; const origin = req.headers.origin; if (allowedOrigins.includes(origin)) { re...
Here's a simple middleware function to serve up the correct CORS header from a whitelist. Setting this near the top of your express app will allow all your routes to set the proper header from the whitelist before serving up content. ``` app.use(function(req, res, next){ var whitelist = ['localhost:4000', 'localhos...
54,976,223
I have a client-server scenario where the client sends images to the server every second. I don't want to close the connection every time I send an image to signal the end of stream. I want to keep the network stream open to reduce overhead of reestablishing a connection. How can I signal the end of an image stream? I...
2019/03/04
[ "https://Stackoverflow.com/questions/54976223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3509337/" ]
You can send the image size before send the image content. ``` stream.Write(BitConverter.GetBytes(buffer.Length), 0, 4); stream.Write(buffer, 0, buffer.Length); ``` At server side stop as soon as received affirmatory bytes. ``` int read = stream.Read(buffer, 0, 4); int imageSize = BitConverter.ToInt32(buffer, 0); ...
**Update** Firstly, you need to work out if the overhead of opening and closing the connection is really that bad, my gut feeling is this would be minimal... if it is totally unacceptable to you, then you really only have 2 reliable options. Send some sort of byte combination that that signals the end. Or send a size ...
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
In your example, it should work if your data parameter is: ``` data: "{'items':" + JSON.stringify(items) + "}" ``` Keep in mind that you need to send a JSON string to ASP.NET AJAX. If you specify an actual JSON object as jQuery's data parameter, it will serialize it as &k=v?k=v pairs instead. It looks like you've r...
This is the way you define your data (JSON) ``` data: { 'items': items }, ``` and the this the way it should be ``` data: '{ items: " '+items +' "}', ``` basically you are serializing the parameter.
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
The following is a code snippet from our project - I had trouble with not wrapping the object as a string and also with Date values - hopefully this helps someone: ``` // our JSON data has to be a STRING - need to send a JSON string to ASP.NET AJAX. // if we specify an actual JSON object as jQuery's d...
This is the way you define your data (JSON) ``` data: { 'items': items }, ``` and the this the way it should be ``` data: '{ items: " '+items +' "}', ``` basically you are serializing the parameter.
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
In your example, it should work if your data parameter is: ``` data: "{'items':" + JSON.stringify(items) + "}" ``` Keep in mind that you need to send a JSON string to ASP.NET AJAX. If you specify an actual JSON object as jQuery's data parameter, it will serialize it as &k=v?k=v pairs instead. It looks like you've r...
see link <http://www.andrewrowland.com/article/display/consume-dot-net-web-service-with-jquery>
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
In your example, it should work if your data parameter is: ``` data: "{'items':" + JSON.stringify(items) + "}" ``` Keep in mind that you need to send a JSON string to ASP.NET AJAX. If you specify an actual JSON object as jQuery's data parameter, it will serialize it as &k=v?k=v pairs instead. It looks like you've r...
When using AJAX.NET I always make the input parameter just a plain old object and then use the javascript deserializer to covert it to whatever type I want. At least that way you can debug and see what type of object the web method in is recieving. You need to convert your object to a string when using jQuery ``` <!D...
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
When using AJAX.NET I always make the input parameter just a plain old object and then use the javascript deserializer to covert it to whatever type I want. At least that way you can debug and see what type of object the web method in is recieving. You need to convert your object to a string when using jQuery ``` <!D...
Decorate your [WebMethod] with another attribute: ``` [ScriptMethod(ResponseFormat = ResponseFormat.Json)] ``` I believe this is in System.Web.Services.Scripting...
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
In your example, it should work if your data parameter is: ``` data: "{'items':" + JSON.stringify(items) + "}" ``` Keep in mind that you need to send a JSON string to ASP.NET AJAX. If you specify an actual JSON object as jQuery's data parameter, it will serialize it as &k=v?k=v pairs instead. It looks like you've r...
The following is a code snippet from our project - I had trouble with not wrapping the object as a string and also with Date values - hopefully this helps someone: ``` // our JSON data has to be a STRING - need to send a JSON string to ASP.NET AJAX. // if we specify an actual JSON object as jQuery's d...
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
When using AJAX.NET I always make the input parameter just a plain old object and then use the javascript deserializer to covert it to whatever type I want. At least that way you can debug and see what type of object the web method in is recieving. You need to convert your object to a string when using jQuery ``` <!D...
The following is a code snippet from our project - I had trouble with not wrapping the object as a string and also with Date values - hopefully this helps someone: ``` // our JSON data has to be a STRING - need to send a JSON string to ASP.NET AJAX. // if we specify an actual JSON object as jQuery's d...
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
Decorate your [WebMethod] with another attribute: ``` [ScriptMethod(ResponseFormat = ResponseFormat.Json)] ``` I believe this is in System.Web.Services.Scripting...
This is the way you define your data (JSON) ``` data: { 'items': items }, ``` and the this the way it should be ``` data: '{ items: " '+items +' "}', ``` basically you are serializing the parameter.
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
In your example, it should work if your data parameter is: ``` data: "{'items':" + JSON.stringify(items) + "}" ``` Keep in mind that you need to send a JSON string to ASP.NET AJAX. If you specify an actual JSON object as jQuery's data parameter, it will serialize it as &k=v?k=v pairs instead. It looks like you've r...
Decorate your [WebMethod] with another attribute: ``` [ScriptMethod(ResponseFormat = ResponseFormat.Json)] ``` I believe this is in System.Web.Services.Scripting...
1,146,110
I've been working on this for 3 hours and have given up. I am simply trying to send data to an ASP.NET WebMethod, using jQuery. The data is basically a bunch of key/value pairs. So I've tried to create an array and adding the pairs to that array. My WebMethod (aspx.cs) looks like this (this may be wrong for what I'm b...
2009/07/17
[ "https://Stackoverflow.com/questions/1146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130560/" ]
The following is a code snippet from our project - I had trouble with not wrapping the object as a string and also with Date values - hopefully this helps someone: ``` // our JSON data has to be a STRING - need to send a JSON string to ASP.NET AJAX. // if we specify an actual JSON object as jQuery's d...
Decorate your [WebMethod] with another attribute: ``` [ScriptMethod(ResponseFormat = ResponseFormat.Json)] ``` I believe this is in System.Web.Services.Scripting...
52,060
Assume a cyclic group $G=\langle g\rangle$ of order $q$ and $g\_1,g\_2$ are two generators of $G$. Alice computes and sends to Bob $m\_1=g\_1^{a\_1}g\_2^{x\_1}, a\gets R $ is a uniformly random element $m\_2=g\_1^bg\_2^{a\_2x\_2}, a,b\gets R $ are uniformly random elements A malicious Alice selects $a\_1 \ne a\_2$ ...
2017/10/06
[ "https://crypto.stackexchange.com/questions/52060", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/1147/" ]
You are asking to prove the existence of a,b,x which satisfy both equations. For any such triplet it is easily verifiable, and therefore the problem is in NP, and therefor there is a zero knowledge proof.
Aren't you curious! I don't fully grasp why you designed your constraints the way you did. Either * you were given m1 and m2 and you wonder if it's possible to verify a1 = a2 and x1 = x2 in a ZK manner. In that case I won't answer your question but suggest looking towards Schnorr's scheme(s). * Or I can imagine the f...
52,060
Assume a cyclic group $G=\langle g\rangle$ of order $q$ and $g\_1,g\_2$ are two generators of $G$. Alice computes and sends to Bob $m\_1=g\_1^{a\_1}g\_2^{x\_1}, a\gets R $ is a uniformly random element $m\_2=g\_1^bg\_2^{a\_2x\_2}, a,b\gets R $ are uniformly random elements A malicious Alice selects $a\_1 \ne a\_2$ ...
2017/10/06
[ "https://crypto.stackexchange.com/questions/52060", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/1147/" ]
On assumption $x\_1 = x\_2 = x$ and $a\_1 = a\_2 = a$, introduce linear polynomials over $F\_q$: $X(z) = x z + \eta\_x$, $A(z) = a z + \eta\_a$, $B(z) = b z + \eta\_b$. Consider two group elements: $g\_1^{A(z)} g\_2^{X(z)} m\_1^{-z}$ and $ g\_1^{z B(z)} g\_2^{A(z) X(z)} m\_2^{-z^2}$. First element is a constant (zero d...
You are asking to prove the existence of a,b,x which satisfy both equations. For any such triplet it is easily verifiable, and therefore the problem is in NP, and therefor there is a zero knowledge proof.
52,060
Assume a cyclic group $G=\langle g\rangle$ of order $q$ and $g\_1,g\_2$ are two generators of $G$. Alice computes and sends to Bob $m\_1=g\_1^{a\_1}g\_2^{x\_1}, a\gets R $ is a uniformly random element $m\_2=g\_1^bg\_2^{a\_2x\_2}, a,b\gets R $ are uniformly random elements A malicious Alice selects $a\_1 \ne a\_2$ ...
2017/10/06
[ "https://crypto.stackexchange.com/questions/52060", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/1147/" ]
On assumption $x\_1 = x\_2 = x$ and $a\_1 = a\_2 = a$, introduce linear polynomials over $F\_q$: $X(z) = x z + \eta\_x$, $A(z) = a z + \eta\_a$, $B(z) = b z + \eta\_b$. Consider two group elements: $g\_1^{A(z)} g\_2^{X(z)} m\_1^{-z}$ and $ g\_1^{z B(z)} g\_2^{A(z) X(z)} m\_2^{-z^2}$. First element is a constant (zero d...
Aren't you curious! I don't fully grasp why you designed your constraints the way you did. Either * you were given m1 and m2 and you wonder if it's possible to verify a1 = a2 and x1 = x2 in a ZK manner. In that case I won't answer your question but suggest looking towards Schnorr's scheme(s). * Or I can imagine the f...
203,772
Two Deterministic Finite Automata or [DFAs](https://en.wikipedia.org/wiki/Deterministic_finite_automaton) can be checked to see if they accept same set of strings in polynomial time. See [section 3.3 of this](https://scholarworks.rit.edu/cgi/viewcontent.cgi?article=7944&context=theses) for a long list of methods and th...
2020/04/22
[ "https://codegolf.stackexchange.com/questions/203772", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/-1/" ]
[K (ngn/k)](https://bitbucket.org/ngn/k), 101 bytes =================================================== ``` {a:&,/~=\:/+/'x[2]=\:'!'#'*'*x:+@[;0;0,']'x;n:#**|*x;~#a^a^{?y@<y:y,/x@\:y}[,/'+\:'/(n;1)**x]/,n/x 1} ``` [Try it online!](https://tio.run/##7Vvbrh03cn2fr9iBg8hHVqDmvVudIP4PjQbjFwfBBAowmAcJjv3rTq21imx2731kY3yS...
[Prolog (SWI)](http://www.swi-prolog.org), 431 program + 5 interpreter = 436 bytes ================================================================================== ``` m-->member. g(A):-read_string(user_input,"\n",[],_,S),term_string(A,S). f(I,T,S,R):-select(S,T,R),m(I,S),!;S=[I],R=T. x(S,R)-->[N],{nth1(S,R,N);S=0,N...
26,746,127
I'm in an interactive Python 2.7 Terminal (Terminal default output is "utf-8"). I have a string from the internet, lets call it `a` ``` >>> a u'M\xfcssen' >>> a[1] u'\xfc' ``` I wonder why its value is not `ü` so I try ``` >>> print(a) Müssen >>> print(a[1]) ü ``` which works as intended. So my first question is...
2014/11/04
[ "https://Stackoverflow.com/questions/26746127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/620053/" ]
Can you try this ``` updateToServer: function(e) { e.preventDefault(); var id = e.target.getAttribute('data-id'); var file = this.collection.get(id); var data = {}; $(e.target).serializeArray().map(function(x) {data[x.name] = x.value;}); this.$el.modal('hide'); setTimeout(function(...
This was not at all what I suspected, and I hadn't given enough information in the question without realizing it. The line in my code that triggered the exception was `file.save()`, but the actual exception was happening inside Backgrid. I provide a form to allow users to update models from the collection displayed in...
39,572,918
I'm trying to install ionic 2 for some hours and I don't succee. while I'm install cordova by cmd with the command "npm install -g cordova" I get this error ```html npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Adir\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-c...
2016/09/19
[ "https://Stackoverflow.com/questions/39572918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6455516/" ]
What fixed my problem was I tried unistalling and re-installing node via brew in mac `npm cache clean` `brew uninstall --force node` `rm -r /usr/local/lib/node_modules` `brew install node` Now if you run "which node" It should `/usr/local/bin/node` And now set NODE\_PATH in my .bash\_profile as ...
The checksum failed npm ERR! shasum check failed You can try upgrading to the latest version of npm : ``` npm install -g npm ``` To upgrade to npm 3. Also : ``` npm cache clean ``` and ``` enter code here ``` npm set registry <https://registry.npmjs.org/>
39,572,918
I'm trying to install ionic 2 for some hours and I don't succee. while I'm install cordova by cmd with the command "npm install -g cordova" I get this error ```html npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Adir\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-c...
2016/09/19
[ "https://Stackoverflow.com/questions/39572918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6455516/" ]
seems like you have some version mismatch issue. so download latest node,install latest npm and start afresh. ``` npm install npm@latest -g npm cache clean npm uninstall -g cordova npm intsall -g cordova ```
The checksum failed npm ERR! shasum check failed You can try upgrading to the latest version of npm : ``` npm install -g npm ``` To upgrade to npm 3. Also : ``` npm cache clean ``` and ``` enter code here ``` npm set registry <https://registry.npmjs.org/>
39,572,918
I'm trying to install ionic 2 for some hours and I don't succee. while I'm install cordova by cmd with the command "npm install -g cordova" I get this error ```html npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Adir\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-c...
2016/09/19
[ "https://Stackoverflow.com/questions/39572918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6455516/" ]
What fixed my problem was I tried unistalling and re-installing node via brew in mac `npm cache clean` `brew uninstall --force node` `rm -r /usr/local/lib/node_modules` `brew install node` Now if you run "which node" It should `/usr/local/bin/node` And now set NODE\_PATH in my .bash\_profile as ...
``` 1 - Install the latest version of NodeJS from their website (e.g. 6.X.X). 2 - Open the Node.js command prompt as administrator. 3 - Run: npm cache clean 4 - Run: npm uninstall -g ionic 5 - Run: npm uninstall -g cordova 6 - Run: npm install -g ionic 7 - Run: npm install -g cordova ```
39,572,918
I'm trying to install ionic 2 for some hours and I don't succee. while I'm install cordova by cmd with the command "npm install -g cordova" I get this error ```html npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Adir\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-c...
2016/09/19
[ "https://Stackoverflow.com/questions/39572918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6455516/" ]
seems like you have some version mismatch issue. so download latest node,install latest npm and start afresh. ``` npm install npm@latest -g npm cache clean npm uninstall -g cordova npm intsall -g cordova ```
``` 1 - Install the latest version of NodeJS from their website (e.g. 6.X.X). 2 - Open the Node.js command prompt as administrator. 3 - Run: npm cache clean 4 - Run: npm uninstall -g ionic 5 - Run: npm uninstall -g cordova 6 - Run: npm install -g ionic 7 - Run: npm install -g cordova ```
2,535,472
Using the method presented here: <http://cslibrary.stanford.edu/110/BinaryTrees.html#java> ``` 12. countTrees() Solution (Java) /** For the key values 1...numKeys, how many structurally unique binary search trees are possible that store those keys? Strategy: consider that each value could be the root. Recursivel...
2010/03/29
[ "https://Stackoverflow.com/questions/2535472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303885/" ]
The number of full binary trees with number of nodes n is the nth Catalan number. Catalan Numbers are calculated as ![alt text](https://upload.wikimedia.org/math/8/a/4/8a49332e4a46b3a2c7accec81160f5e3.png) which is complexity O(n). <http://mathworld.wolfram.com/BinaryTree.html> <http://en.wikipedia.org/wiki/Catala...
It's easy enough to count the number of calls to `countTrees` this algorithm uses for a given node count. After a few trial runs, it looks to me like it requires 5\*3^(n-2) calls for n >= 2, which grows much more slowly than n!. The proof of this assertion is left as an exercise for the reader. :-) A memoized version ...
2,535,472
Using the method presented here: <http://cslibrary.stanford.edu/110/BinaryTrees.html#java> ``` 12. countTrees() Solution (Java) /** For the key values 1...numKeys, how many structurally unique binary search trees are possible that store those keys? Strategy: consider that each value could be the root. Recursivel...
2010/03/29
[ "https://Stackoverflow.com/questions/2535472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303885/" ]
The number of full binary trees with number of nodes n is the nth Catalan number. Catalan Numbers are calculated as ![alt text](https://upload.wikimedia.org/math/8/a/4/8a49332e4a46b3a2c7accec81160f5e3.png) which is complexity O(n). <http://mathworld.wolfram.com/BinaryTree.html> <http://en.wikipedia.org/wiki/Catala...
Not sure of how many hits to the look-up table is the memoized version going to make (which is definitely super-linear and will have the overheads of function calling) but with the mathematical proof yielding the result to be the same as nth Catalan number, one can quickly cook up a linear-time tabular method: ``` ...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
I do recall some papers presented on proxy during conferences I attended during undergrad. There were also some other presentations that were presented by the researchers themselves on Skype. If someone is presenting your research paper on your behalf, it is no harm in asking for the session to be videoed real time for...
Since you are doing a PhD it is likely that you are considering a potential future as TT faculty or researcher? A job in which your expertise on a particular field is your Intellectual Property and recognition of which is part of the basis for gaining funding for grants and facilitating authorship in peer-reviewed jour...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
In my experience, it is very common for one person to present someone else's conference talk. I know this happens because at about 5% of talks speaker announces they are doing it at the beginning of the talk. The reason for this occurring is not usually given. I would guess the most common reason is that the original s...
Since you are doing a PhD it is likely that you are considering a potential future as TT faculty or researcher? A job in which your expertise on a particular field is your Intellectual Property and recognition of which is part of the basis for gaining funding for grants and facilitating authorship in peer-reviewed jour...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
In my experience, it is very common for one person to present someone else's conference talk. I know this happens because at about 5% of talks speaker announces they are doing it at the beginning of the talk. The reason for this occurring is not usually given. I would guess the most common reason is that the original s...
> > "What do you think about that offer?" > > > I would **accept** the offer. TDLR; I would see it is a good way to **maximize the impact** of my work. Indeed, the more people talk about your work the better it is. In the end of the day, it is *the paper* which is cited and not the talk. In particular, if this i...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
That is a common practice, and actually a very bad practice in many ways. First, the replacement will generally know less than you do for your work, and also will be reluctant to present it others. Second, you will miss the opportunity to get to know more people related to your research interests, it is actually all ...
I do recall some papers presented on proxy during conferences I attended during undergrad. There were also some other presentations that were presented by the researchers themselves on Skype. If someone is presenting your research paper on your behalf, it is no harm in asking for the session to be videoed real time for...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
In my experience, it is very common for one person to present someone else's conference talk. I know this happens because at about 5% of talks speaker announces they are doing it at the beginning of the talk. The reason for this occurring is not usually given. I would guess the most common reason is that the original s...
That is a common practice, and actually a very bad practice in many ways. First, the replacement will generally know less than you do for your work, and also will be reluctant to present it others. Second, you will miss the opportunity to get to know more people related to your research interests, it is actually all ...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
> > "What do you think about that offer?" > > > I would **accept** the offer. TDLR; I would see it is a good way to **maximize the impact** of my work. Indeed, the more people talk about your work the better it is. In the end of the day, it is *the paper* which is cited and not the talk. In particular, if this i...
**I would be very concerned about maintaining authorship of the work**, especially in fields like computer science where conferences are taken really seriously. There may be some work-around -- for example, letting the other student present it "on your behalf" with you as first author. In your case, though, it sounds l...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
> > "What do you think about that offer?" > > > I would **accept** the offer. TDLR; I would see it is a good way to **maximize the impact** of my work. Indeed, the more people talk about your work the better it is. In the end of the day, it is *the paper* which is cited and not the talk. In particular, if this i...
I admit to little experience with this, having not missed an opportunity to present or presented on someone else's behalf. In my field (which is not a scientific area of academia,) this would not be a big deal. But it is fairly uncommon, just because remote appearance is now so easy. It is routine for a presenter to ap...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
> > "What do you think about that offer?" > > > I would **accept** the offer. TDLR; I would see it is a good way to **maximize the impact** of my work. Indeed, the more people talk about your work the better it is. In the end of the day, it is *the paper* which is cited and not the talk. In particular, if this i...
It depends on the field as to whether this is common practice. I have been to a number of conferences where a presentation/paper has been delivered on behalf of another person. On each occasion, the slides were done the same as if it were the author delivering the presentation. On most of the occasions, the proxy pre...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
**I would be very concerned about maintaining authorship of the work**, especially in fields like computer science where conferences are taken really seriously. There may be some work-around -- for example, letting the other student present it "on your behalf" with you as first author. In your case, though, it sounds l...
Since you are doing a PhD it is likely that you are considering a potential future as TT faculty or researcher? A job in which your expertise on a particular field is your Intellectual Property and recognition of which is part of the basis for gaining funding for grants and facilitating authorship in peer-reviewed jour...
115,711
I'm doing a PhD with a professor with serious funding problems. He invited me to prepare a presentation for a conference, making it clear that he wouldn't pay for my travel expenses. I, in turn, replied that I didn't have the money to travel to that conference. He offered that another student go present my research bec...
2018/08/23
[ "https://academia.stackexchange.com/questions/115711", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/97306/" ]
I admit to little experience with this, having not missed an opportunity to present or presented on someone else's behalf. In my field (which is not a scientific area of academia,) this would not be a big deal. But it is fairly uncommon, just because remote appearance is now so easy. It is routine for a presenter to ap...
Since you are doing a PhD it is likely that you are considering a potential future as TT faculty or researcher? A job in which your expertise on a particular field is your Intellectual Property and recognition of which is part of the basis for gaining funding for grants and facilitating authorship in peer-reviewed jour...
23,339,448
trying to achieve an output of having a new column after the last which uses the first letter of the first name and the rest of the last name. what is the proper way to type this out using awk? INPUT: ``` Vincent Nguyen David Pham Bobby Hill ``` Output: ``` Vincent Nguyen vnguyen David Pham dpham Bobby Hill bhill ...
2014/04/28
[ "https://Stackoverflow.com/questions/23339448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535640/" ]
You could do: ``` awk '{print $0,tolower(substr($1,1,1)$NF)}' file Vincent Nguyen vnguyen David Pham dpham Bobby Hill bhill ``` Could be shorten some to: (but less robust) ``` awk '$0=$0FS tolower(substr($1,1,1)$NF)' file ``` --- Updated to support longer name like: ``` Bobby Bigfoot Hill ``` gives ``` Bobby...
based on your example, try this `sed` oneliner: ``` sed -r 's/(.)\S* (.*)/& \L\1\2/' file ``` test: ``` kent$ cat f Vincent Nguyen David Pham Bobby Hill kent$ sed -r 's/(.)\S* (.*)/& \L\1\2/' f Vincent Nguyen vnguyen David Pham dpham Bobby Hill bhill ```
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
Works for me ``` >>> class MyClass( object ): ... def aFunc( self ): ... print( some_global ) ... >>> some_global= 3 >>> x= MyClass() >>> x.aFunc() 3 ``` The code that's posted has probably had too many details removed to show the real error.
If you don't declare var as global and don't initialize it, accessing value of non-defined variable is error so ``` global the_parameter = config.getint(...) ``` is the answer
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
Works for me ``` >>> class MyClass( object ): ... def aFunc( self ): ... print( some_global ) ... >>> some_global= 3 >>> x= MyClass() >>> x.aFunc() 3 ``` The code that's posted has probably had too many details removed to show the real error.
Put `global the_parameter` in the function to fix the issue.
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
Works for me ``` >>> class MyClass( object ): ... def aFunc( self ): ... print( some_global ) ... >>> some_global= 3 >>> x= MyClass() >>> x.aFunc() 3 ``` The code that's posted has probably had too many details removed to show the real error.
S.Lott is right: the OP's code works. It works either with **the\_parameter** defined before the class's definition or after, it doesn't matter. What happens is that when the function **my\_func** is called as a method of one of the instances, the object **the\_parameter** is searched in the environment of the **m...
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
Put `global the_parameter` in the function to fix the issue.
If you don't declare var as global and don't initialize it, accessing value of non-defined variable is error so ``` global the_parameter = config.getint(...) ``` is the answer
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
Don't try to use global variables in your classes, this is somewhat against the purpose of classes. If your class requires a config object, you could pass it via dependency injection, i.e. explicitely pass it as an argument to your class: ``` config = ConfigParser.ConfigParser() config.read('config.cfg') class MyClas...
If you don't declare var as global and don't initialize it, accessing value of non-defined variable is error so ``` global the_parameter = config.getint(...) ``` is the answer
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
S.Lott is right: the OP's code works. It works either with **the\_parameter** defined before the class's definition or after, it doesn't matter. What happens is that when the function **my\_func** is called as a method of one of the instances, the object **the\_parameter** is searched in the environment of the **m...
If you don't declare var as global and don't initialize it, accessing value of non-defined variable is error so ``` global the_parameter = config.getint(...) ``` is the answer
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
Don't try to use global variables in your classes, this is somewhat against the purpose of classes. If your class requires a config object, you could pass it via dependency injection, i.e. explicitely pass it as an argument to your class: ``` config = ConfigParser.ConfigParser() config.read('config.cfg') class MyClas...
Put `global the_parameter` in the function to fix the issue.
6,663,866
I have a class which is instantiated many times. It requires a certain parameter from a configuration file. I thought of reading the config file once in the module level so that each instance can refer to the loaded parameter. I'm probably missing something as I'm receiving: `UnboundLocalError: local variable 'the_...
2011/07/12
[ "https://Stackoverflow.com/questions/6663866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348545/" ]
Don't try to use global variables in your classes, this is somewhat against the purpose of classes. If your class requires a config object, you could pass it via dependency injection, i.e. explicitely pass it as an argument to your class: ``` config = ConfigParser.ConfigParser() config.read('config.cfg') class MyClas...
S.Lott is right: the OP's code works. It works either with **the\_parameter** defined before the class's definition or after, it doesn't matter. What happens is that when the function **my\_func** is called as a method of one of the instances, the object **the\_parameter** is searched in the environment of the **m...
48,032,649
I have a view controller with XIB, with a view (`contentView`) inside. This view contains some buttons. The content view has round corners and clips to bounds, but it doesn't respect the clipping rect. I set the corner radius and the `clipsToBounds` in the `viewDidLoad` of the view controller. Here you can see the re...
2017/12/30
[ "https://Stackoverflow.com/questions/48032649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4106520/" ]
I found a solution, I move the clipsToBound in the viewDidLayoutSubviews instead viewDidLoad and now works ``` override func viewDidLoad() { super.viewDidLoad() contentView.layer.cornerRadius = Dimensions.CornerRaius contentView.dropShadow() } override func viewDidLayoutSubviews() { super.viewDidLayo...
I defined my view (UIView in my case) like that: ``` fileprivate let backView: UIView = { let view = UIView() view.clipsToBounds = true view.layer.masksToBounds = false view.layer.cornerRadius = 10 view.translatesAutoresizingMaskIntoConstraints = false return view }() ``` The image: ``` file...
606,327
I have the below output from a command in a bash shell: ``` username country ``` But I would like to modify the printed output to be: ``` username - country ``` Thanks.
2020/08/25
[ "https://unix.stackexchange.com/questions/606327", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/408932/" ]
I'd do something like: ``` $ seq 6 | awk '{printf "%s", sep $0; sep = " - "}; END {if (NR) print ""}' 1 - 2 - 3 - 4 - 5 - 6 ``` Or: ``` $ seq 6 | paste -d ' - \n' - /dev/null /dev/null - 1 - 2 3 - 4 5 - 6 ``` Or: ``` $ seq 5 | sed '$!N;s/\n/ - /' 1 - 2 3 - 4 5 ``` If it's just a two line output, you can also d...
Pipe it to this: ``` sed -z 's|\n| - |' ``` That uses GNU `sed` to replace the newline with `-`.
606,327
I have the below output from a command in a bash shell: ``` username country ``` But I would like to modify the printed output to be: ``` username - country ``` Thanks.
2020/08/25
[ "https://unix.stackexchange.com/questions/606327", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/408932/" ]
`tr` can transform a character into another: ``` echo "username country town" | tr '\n' ' ' ``` output: ``` username country town ``` use `tr -d` to replace a character (newline) by nothing: ``` echo "username country town" | tr -d '\n' ``` output: ``` usernamecountrytown ``` but if you want to replace newl...
Pipe it to this: ``` sed -z 's|\n| - |' ``` That uses GNU `sed` to replace the newline with `-`.
606,327
I have the below output from a command in a bash shell: ``` username country ``` But I would like to modify the printed output to be: ``` username - country ``` Thanks.
2020/08/25
[ "https://unix.stackexchange.com/questions/606327", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/408932/" ]
I'd do something like: ``` $ seq 6 | awk '{printf "%s", sep $0; sep = " - "}; END {if (NR) print ""}' 1 - 2 - 3 - 4 - 5 - 6 ``` Or: ``` $ seq 6 | paste -d ' - \n' - /dev/null /dev/null - 1 - 2 3 - 4 5 - 6 ``` Or: ``` $ seq 5 | sed '$!N;s/\n/ - /' 1 - 2 3 - 4 5 ``` If it's just a two line output, you can also d...
``` awk 'ORS=" - "{print $0}' filename|awk '{gsub(/- $/,"",$0);print }' ``` output ``` username - country ```
606,327
I have the below output from a command in a bash shell: ``` username country ``` But I would like to modify the printed output to be: ``` username - country ``` Thanks.
2020/08/25
[ "https://unix.stackexchange.com/questions/606327", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/408932/" ]
`tr` can transform a character into another: ``` echo "username country town" | tr '\n' ' ' ``` output: ``` username country town ``` use `tr -d` to replace a character (newline) by nothing: ``` echo "username country town" | tr -d '\n' ``` output: ``` usernamecountrytown ``` but if you want to replace newl...
``` awk 'ORS=" - "{print $0}' filename|awk '{gsub(/- $/,"",$0);print }' ``` output ``` username - country ```
606,327
I have the below output from a command in a bash shell: ``` username country ``` But I would like to modify the printed output to be: ``` username - country ``` Thanks.
2020/08/25
[ "https://unix.stackexchange.com/questions/606327", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/408932/" ]
I'd do something like: ``` $ seq 6 | awk '{printf "%s", sep $0; sep = " - "}; END {if (NR) print ""}' 1 - 2 - 3 - 4 - 5 - 6 ``` Or: ``` $ seq 6 | paste -d ' - \n' - /dev/null /dev/null - 1 - 2 3 - 4 5 - 6 ``` Or: ``` $ seq 5 | sed '$!N;s/\n/ - /' 1 - 2 3 - 4 5 ``` If it's just a two line output, you can also d...
`tr` can transform a character into another: ``` echo "username country town" | tr '\n' ' ' ``` output: ``` username country town ``` use `tr -d` to replace a character (newline) by nothing: ``` echo "username country town" | tr -d '\n' ``` output: ``` usernamecountrytown ``` but if you want to replace newl...
33,611
I am new in Sitecore and I have installed Sitecore 10.2 XP1 instance on my local machine. I just want to know more about different topologies and they communicate with others. 1. Collection 2. Ma 3. Marketing Reporting 4. Prc 5. ProcessingEngine 6. RefData 7. Reporting 8. Search
2022/12/12
[ "https://sitecore.stackexchange.com/questions/33611", "https://sitecore.stackexchange.com", "https://sitecore.stackexchange.com/users/8744/" ]
To understand it very simply, Sitecore has produced a number of pre-built topologies which offer combinations of the split-out functionality: **On-premise (IaaS) topologies** Default on-premise (IaaS) topologies include: * XP Single * XP Scaled * XM Scaled **Azure (PaaS) topologies** Azure (PaaS) includes the follow...
In a nutshell, The entire Sitecore product suite contains over 50 logical system roles or entities that can be scaled and configured in a wide variety of topologies to form a running Sitecore solution catering to specific business needs or requirements. The logical roles can be grouped and described from different per...
10,277,516
I'm using the simple\_form gem. I have a fairly straightforward scenario. I have a scoped route and I'm trying to get a form: ``` = simple_form_for(@scope, @post) do |f| = f.input :comment ``` Simplified routes file: ``` scope ':scope' do resources :posts end ``` However I get the error: ``` undefined metho...
2012/04/23
[ "https://Stackoverflow.com/questions/10277516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/671422/" ]
One way around it this (although not ideal is to use simple\_fields for. I'll stick with this until there is a better solution. ``` = form_for(@scope, @post) do |f| =f.simple_fields_for :posts do |ff| =ff.input :comment ```
Have you restart the server after installing Gem?
10,277,516
I'm using the simple\_form gem. I have a fairly straightforward scenario. I have a scoped route and I'm trying to get a form: ``` = simple_form_for(@scope, @post) do |f| = f.input :comment ``` Simplified routes file: ``` scope ':scope' do resources :posts end ``` However I get the error: ``` undefined metho...
2012/04/23
[ "https://Stackoverflow.com/questions/10277516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/671422/" ]
This is occurring because the `simple_form_for` (and the `for_form` too because `simple_form_for` is only a method delegation to it) receives as second argument the options hash. So your `@post` is being interpreted as options, preventing to the SimpleForm to change the form builder. The correct way to work with scope...
One way around it this (although not ideal is to use simple\_fields for. I'll stick with this until there is a better solution. ``` = form_for(@scope, @post) do |f| =f.simple_fields_for :posts do |ff| =ff.input :comment ```
10,277,516
I'm using the simple\_form gem. I have a fairly straightforward scenario. I have a scoped route and I'm trying to get a form: ``` = simple_form_for(@scope, @post) do |f| = f.input :comment ``` Simplified routes file: ``` scope ':scope' do resources :posts end ``` However I get the error: ``` undefined metho...
2012/04/23
[ "https://Stackoverflow.com/questions/10277516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/671422/" ]
This is occurring because the `simple_form_for` (and the `for_form` too because `simple_form_for` is only a method delegation to it) receives as second argument the options hash. So your `@post` is being interpreted as options, preventing to the SimpleForm to change the form builder. The correct way to work with scope...
Have you restart the server after installing Gem?
31,076,650
In previous versions of R I could combine factor levels that didn't have a "significant" threshold of volume using the following little function: ``` whittle = function(data, cutoff_val){ #convert to a data frame tab = as.data.frame.table(table(data)) #returns vector of indices where value is below cutoff_val ...
2015/06/26
[ "https://Stackoverflow.com/questions/31076650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1641862/" ]
I've always found it easiest (less typing and less headache) to convert to character and back for these sorts of operations. Keeping with your `as.data.frame.table` and using `replace` to do the replacement of the low-frequency levels: ``` whittle <- function(data, cutoff_val) { tab = as.data.frame.table(table(data)...
I think this verison should work. The `levels<-` function allows you to collapse by assigning a list (see `?levels`). ``` whittle <- function(data, cutoff_val){ tab <- table(data) shouldmerge <- tab < cutoff_val tokeep <- names(tab)[!shouldmerge] tomerge <- names(tab)[shouldmerge] nv <- c(as.list(setNames(t...
31,076,650
In previous versions of R I could combine factor levels that didn't have a "significant" threshold of volume using the following little function: ``` whittle = function(data, cutoff_val){ #convert to a data frame tab = as.data.frame.table(table(data)) #returns vector of indices where value is below cutoff_val ...
2015/06/26
[ "https://Stackoverflow.com/questions/31076650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1641862/" ]
I think this verison should work. The `levels<-` function allows you to collapse by assigning a list (see `?levels`). ``` whittle <- function(data, cutoff_val){ tab <- table(data) shouldmerge <- tab < cutoff_val tokeep <- names(tab)[!shouldmerge] tomerge <- names(tab)[shouldmerge] nv <- c(as.list(setNames(t...
Here's another way of doing it by replacing all the items below the threshold with the first and then renaming that level to Other. ``` whittle <- function(x, thresh) { belowThresh <- names(which(table(x) < thresh)) x[x %in% belowThresh] <- belowThresh[1] levels(x)[levels(x) == belowThresh[1]] <- "Other" facto...
31,076,650
In previous versions of R I could combine factor levels that didn't have a "significant" threshold of volume using the following little function: ``` whittle = function(data, cutoff_val){ #convert to a data frame tab = as.data.frame.table(table(data)) #returns vector of indices where value is below cutoff_val ...
2015/06/26
[ "https://Stackoverflow.com/questions/31076650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1641862/" ]
I think this verison should work. The `levels<-` function allows you to collapse by assigning a list (see `?levels`). ``` whittle <- function(data, cutoff_val){ tab <- table(data) shouldmerge <- tab < cutoff_val tokeep <- names(tab)[!shouldmerge] tomerge <- names(tab)[shouldmerge] nv <- c(as.list(setNames(t...
It's worth adding to this answer that the new `forcats` package contains the `fct_lump()` function which is dedicated to this. Using @MrFlick's data: ``` x <- factor(c(sample(letters[1:10], 100, replace=T), sample(letters[11:13], 10, replace=T))) library(forcats) library(magrittr) ## for %>% ; could ...
31,076,650
In previous versions of R I could combine factor levels that didn't have a "significant" threshold of volume using the following little function: ``` whittle = function(data, cutoff_val){ #convert to a data frame tab = as.data.frame.table(table(data)) #returns vector of indices where value is below cutoff_val ...
2015/06/26
[ "https://Stackoverflow.com/questions/31076650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1641862/" ]
I've always found it easiest (less typing and less headache) to convert to character and back for these sorts of operations. Keeping with your `as.data.frame.table` and using `replace` to do the replacement of the low-frequency levels: ``` whittle <- function(data, cutoff_val) { tab = as.data.frame.table(table(data)...
Here's another way of doing it by replacing all the items below the threshold with the first and then renaming that level to Other. ``` whittle <- function(x, thresh) { belowThresh <- names(which(table(x) < thresh)) x[x %in% belowThresh] <- belowThresh[1] levels(x)[levels(x) == belowThresh[1]] <- "Other" facto...
31,076,650
In previous versions of R I could combine factor levels that didn't have a "significant" threshold of volume using the following little function: ``` whittle = function(data, cutoff_val){ #convert to a data frame tab = as.data.frame.table(table(data)) #returns vector of indices where value is below cutoff_val ...
2015/06/26
[ "https://Stackoverflow.com/questions/31076650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1641862/" ]
I've always found it easiest (less typing and less headache) to convert to character and back for these sorts of operations. Keeping with your `as.data.frame.table` and using `replace` to do the replacement of the low-frequency levels: ``` whittle <- function(data, cutoff_val) { tab = as.data.frame.table(table(data)...
It's worth adding to this answer that the new `forcats` package contains the `fct_lump()` function which is dedicated to this. Using @MrFlick's data: ``` x <- factor(c(sample(letters[1:10], 100, replace=T), sample(letters[11:13], 10, replace=T))) library(forcats) library(magrittr) ## for %>% ; could ...
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
When grouping by column `Y`, all rows for which the value in `Y` is `NULL` are grouped together. [This behaviour is defined by the SQL-2003 standard](http://msdn.microsoft.com/en-us/library/ms187007%28v=sql.90%29.aspx), though it's slightly surprising because `NULL` is not equal to `NULL`. You can work around it by g...
Maybe faster version of previous solution in case you have unique identifier in table1 (let suppose it is table1.id) : ``` SELECT `table1`.*, GROUP_CONCAT(id SEPARATOR ',') AS `children_ids`, IF(ISNULL(ancestor),table1.id,NULL) as `do_not_group_on_null_ancestor` FROM `table1` WHERE (enabled = 1) GROUP BY `a...
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
Perhaps you should add something to the null columns to make them unique and group on that? I was looking for some sort of sequence to use instead of UUID() but this might work just as well. ``` SELECT `table1`.*, IFNULL(ancestor,UUID()) as unq_ancestor GROUP_CONCAT(id SEPARATOR ',') AS `children_ids` FROM `t...
**To union multiple tables and group\_concat different column and a sum of the column for the (unique primary or foreign key) column to display a value in the same row** ``` select column1,column2,column3,GROUP_CONCAT(if(column4='', null, column4)) as column4,sum(column5) as column5 from ( select column1,group_...
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
When grouping by column `Y`, all rows for which the value in `Y` is `NULL` are grouped together. [This behaviour is defined by the SQL-2003 standard](http://msdn.microsoft.com/en-us/library/ms187007%28v=sql.90%29.aspx), though it's slightly surprising because `NULL` is not equal to `NULL`. You can work around it by g...
`GROUP BY IFNULL(required_field, id)`
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
Maybe faster version of previous solution in case you have unique identifier in table1 (let suppose it is table1.id) : ``` SELECT `table1`.*, GROUP_CONCAT(id SEPARATOR ',') AS `children_ids`, IF(ISNULL(ancestor),table1.id,NULL) as `do_not_group_on_null_ancestor` FROM `table1` WHERE (enabled = 1) GROUP BY `a...
**To union multiple tables and group\_concat different column and a sum of the column for the (unique primary or foreign key) column to display a value in the same row** ``` select column1,column2,column3,GROUP_CONCAT(if(column4='', null, column4)) as column4,sum(column5) as column5 from ( select column1,group_...
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
`GROUP BY IFNULL(required_field, id)`
Maybe faster version of previous solution in case you have unique identifier in table1 (let suppose it is table1.id) : ``` SELECT `table1`.*, GROUP_CONCAT(id SEPARATOR ',') AS `children_ids`, IF(ISNULL(ancestor),table1.id,NULL) as `do_not_group_on_null_ancestor` FROM `table1` WHERE (enabled = 1) GROUP BY `a...
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
When grouping by column `Y`, all rows for which the value in `Y` is `NULL` are grouped together. [This behaviour is defined by the SQL-2003 standard](http://msdn.microsoft.com/en-us/library/ms187007%28v=sql.90%29.aspx), though it's slightly surprising because `NULL` is not equal to `NULL`. You can work around it by g...
**To union multiple tables and group\_concat different column and a sum of the column for the (unique primary or foreign key) column to display a value in the same row** ``` select column1,column2,column3,GROUP_CONCAT(if(column4='', null, column4)) as column4,sum(column5) as column5 from ( select column1,group_...
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
When grouping by column `Y`, all rows for which the value in `Y` is `NULL` are grouped together. [This behaviour is defined by the SQL-2003 standard](http://msdn.microsoft.com/en-us/library/ms187007%28v=sql.90%29.aspx), though it's slightly surprising because `NULL` is not equal to `NULL`. You can work around it by g...
``` SELECT table1.*, GROUP_CONCAT(id SEPARATOR ',') AS children_ids FROM table1 WHERE (enabled = 1) GROUP BY ancestor , CASE WHEN ancestor IS NULL THEN table1.id ELSE 0 END ```
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
Perhaps you should add something to the null columns to make them unique and group on that? I was looking for some sort of sequence to use instead of UUID() but this might work just as well. ``` SELECT `table1`.*, IFNULL(ancestor,UUID()) as unq_ancestor GROUP_CONCAT(id SEPARATOR ',') AS `children_ids` FROM `t...
`GROUP BY IFNULL(required_field, id)`
4,588,935
I'm trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. ``` SELECT `tab...
2011/01/03
[ "https://Stackoverflow.com/questions/4588935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238975/" ]
``` SELECT table1.*, GROUP_CONCAT(id SEPARATOR ',') AS children_ids FROM table1 WHERE (enabled = 1) GROUP BY ancestor , CASE WHEN ancestor IS NULL THEN table1.id ELSE 0 END ```
Maybe faster version of previous solution in case you have unique identifier in table1 (let suppose it is table1.id) : ``` SELECT `table1`.*, GROUP_CONCAT(id SEPARATOR ',') AS `children_ids`, IF(ISNULL(ancestor),table1.id,NULL) as `do_not_group_on_null_ancestor` FROM `table1` WHERE (enabled = 1) GROUP BY `a...