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
17,487,872
I want to add lines to /etc/my.conf as "sudo" using Shell. Without logging as sudo, I can do: ``` { echo "[mysqld]" ...
2013/07/05
[ "https://Stackoverflow.com/questions/17487872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2185098/" ]
Firstly, use cat with a here-doc rather than a series of echoes. It's much cleaner. You can use the special form with a dash which strips leading tabs (tabs, not spaces!) to let you indent the here-doc to make it stand out. Secondly, you can do the redirection as sudo by using `sudo sh -c` to start a root subshell, in...
To make everything easier you should place the commands in a script, and let sudo execute that script.
17,487,872
I want to add lines to /etc/my.conf as "sudo" using Shell. Without logging as sudo, I can do: ``` { echo "[mysqld]" ...
2013/07/05
[ "https://Stackoverflow.com/questions/17487872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2185098/" ]
An alternative to launching a new shell is to use the `tee` command: ``` { echo "[mysqld]" ec...
To make everything easier you should place the commands in a script, and let sudo execute that script.
17,487,872
I want to add lines to /etc/my.conf as "sudo" using Shell. Without logging as sudo, I can do: ``` { echo "[mysqld]" ...
2013/07/05
[ "https://Stackoverflow.com/questions/17487872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2185098/" ]
Firstly, use cat with a here-doc rather than a series of echoes. It's much cleaner. You can use the special form with a dash which strips leading tabs (tabs, not spaces!) to let you indent the here-doc to make it stand out. Secondly, you can do the redirection as sudo by using `sudo sh -c` to start a root subshell, in...
An alternative to launching a new shell is to use the `tee` command: ``` { echo "[mysqld]" ec...
69,248,698
Hi today I installed java 17 and eclipse(with latest version- 2021‑09). But after all configuration it is showing JavaSE-16 as jdk version. I ignored it and started writing a program with sealed classes. Then it is showing an error. I managed to solve the problem by installing the Java-17 support plugin from eclipse ma...
2021/09/20
[ "https://Stackoverflow.com/questions/69248698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436946/" ]
The release notes state this: > > Supports Java 17, including Pattern Matching for Switch (Preview), > Sealed Classes, and more **via Eclipse Marketplace** > > > That means currently you have to install the plugin, later support will be included. You might also want to read this: <https://www.eclipse.org/eclipse/...
Install java 17 plugin from [this](https://marketplace.eclipse.org/content/java-17-support-eclipse-2021-09-421) link. Then your likely to have a [content assist error](https://stackoverflow.com/questions/69357171/eclipse-2021-09-code-completion-not-showing-all-methods-and-classes). Fix it by [this](https://stackoverflo...
69,248,698
Hi today I installed java 17 and eclipse(with latest version- 2021‑09). But after all configuration it is showing JavaSE-16 as jdk version. I ignored it and started writing a program with sealed classes. Then it is showing an error. I managed to solve the problem by installing the Java-17 support plugin from eclipse ma...
2021/09/20
[ "https://Stackoverflow.com/questions/69248698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436946/" ]
The release notes state this: > > Supports Java 17, including Pattern Matching for Switch (Preview), > Sealed Classes, and more **via Eclipse Marketplace** > > > That means currently you have to install the plugin, later support will be included. You might also want to read this: <https://www.eclipse.org/eclipse/...
The support should be official with Eclipse 4.22 (Q4 2021) > > [Java 17](https://www.eclipse.org/eclipse/news/4.22/jdt.php#Java_17) > -------------------------------------------------------------------- > > > Java 17 is out and Eclipse JDT supports Java 17 in 4.22. > > > The release notably includes the following...
69,248,698
Hi today I installed java 17 and eclipse(with latest version- 2021‑09). But after all configuration it is showing JavaSE-16 as jdk version. I ignored it and started writing a program with sealed classes. Then it is showing an error. I managed to solve the problem by installing the Java-17 support plugin from eclipse ma...
2021/09/20
[ "https://Stackoverflow.com/questions/69248698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436946/" ]
Install java 17 plugin from [this](https://marketplace.eclipse.org/content/java-17-support-eclipse-2021-09-421) link. Then your likely to have a [content assist error](https://stackoverflow.com/questions/69357171/eclipse-2021-09-code-completion-not-showing-all-methods-and-classes). Fix it by [this](https://stackoverflo...
The support should be official with Eclipse 4.22 (Q4 2021) > > [Java 17](https://www.eclipse.org/eclipse/news/4.22/jdt.php#Java_17) > -------------------------------------------------------------------- > > > Java 17 is out and Eclipse JDT supports Java 17 in 4.22. > > > The release notably includes the following...
13,063,717
I am trying to write some C++ code in the momentics IDE with the project type as 'C++ Cascades Application'. To my surprise there's no Intellisense support. Does anyone know how to enable intellisense with C++?
2012/10/25
[ "https://Stackoverflow.com/questions/13063717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71292/" ]
You always need to optimize the *bottleneck* of your application. In a game, the speed of the engine is critical to the performance of the application. Hence, optimization makes sense there. In a line-of-business application, which spends X ms waiting for the execution of a database query, and Y << X ms drawing the u...
In short points: C or C++ gives you the posibility to work with many more details at a lower level so you can get performance and memory gains from where you can, and that is really required cause a game requires pretty high performance requirements for drawing and redrawing things continuosly. However such details ar...
13,063,717
I am trying to write some C++ code in the momentics IDE with the project type as 'C++ Cascades Application'. To my surprise there's no Intellisense support. Does anyone know how to enable intellisense with C++?
2012/10/25
[ "https://Stackoverflow.com/questions/13063717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71292/" ]
It's not primarily about the language, it's the platform. In .Net you can't use SSE, your ability to use the GPU is limited; some lock-free multithreaded algorithms can only really be implemented as originally intended (versioned pointers) in native code (and if multithreading is important, an efficient lock-free stru...
In short points: C or C++ gives you the posibility to work with many more details at a lower level so you can get performance and memory gains from where you can, and that is really required cause a game requires pretty high performance requirements for drawing and redrawing things continuosly. However such details ar...
13,063,717
I am trying to write some C++ code in the momentics IDE with the project type as 'C++ Cascades Application'. To my surprise there's no Intellisense support. Does anyone know how to enable intellisense with C++?
2012/10/25
[ "https://Stackoverflow.com/questions/13063717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71292/" ]
It's not primarily about the language, it's the platform. In .Net you can't use SSE, your ability to use the GPU is limited; some lock-free multithreaded algorithms can only really be implemented as originally intended (versioned pointers) in native code (and if multithreading is important, an efficient lock-free stru...
You always need to optimize the *bottleneck* of your application. In a game, the speed of the engine is critical to the performance of the application. Hence, optimization makes sense there. In a line-of-business application, which spends X ms waiting for the execution of a database query, and Y << X ms drawing the u...
67,604,427
I've created App Clip for my application , but i can't auto sign it , i am getting 2 errors : > > Automatic signing failedXcode failed to provision this target. Please > file a bug report at <https://feedbackassistant.apple.com> and include > the Update Signing report from the Report navigator. > > > Provisioning p...
2021/05/19
[ "https://Stackoverflow.com/questions/67604427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3059001/" ]
There are two values that need to match up. First, locate the provisioning profile Xcode is using for your App Clip (they're in `~/Library/MobileDevice/Provisioning Profiles`) and inspect it by highlighting the file and pressing space. The parent ID value in there: [![enter image description here](https://i.stack.imgu...
Pietro is correct. I would just add that when the error mentions the bundle identifier (from the app or the app clip), they mean the FULL bundle identifier (TeamID + bundle id). The Team ID prefix looks like `ABC123DEF456` and the bundle identifier like `com.example.app`. This means you must make sure that when you he...
46,516,752
I'm trying to use jQuery / jQuery UI in an Angular 4 app generated by Microsoft's SpaTemplate/JavaScript Services (dontnet new angular). This is not using Angular-CLI, and there is no angular-cli.json file. I've searched for this already, found a few hits on SO for projects generated with the CLI which I can't seem to...
2017/10/01
[ "https://Stackoverflow.com/questions/46516752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/721429/" ]
``` CREATE TABLE IF NOT EXISTName ``` You are missing a space between the keyword `EXIST` and the table name `Name`.
You can simply add the block of code in a try-catch block and then put debug point on it and determine the exception and correct it. e.g ``` try { //block of code in which you have an error or you want to debug } catch(e: Exception) { // you can use log for seeing error or you can simply view errors by //puttin...
16,070
I have purchased a high quality ZS6BKW from the U.K. I have it suspended up about 40' between 2 trees. There is 30' of coax from the ladder line to the radio (Kenwood TS-870).SWR on the MFJ269 shows below 1.5 from 80m all the way up to 10m. SWR on the radio shows below 1.5 too. However, I cannot hear anything on any b...
2020/02/07
[ "https://ham.stackexchange.com/questions/16070", "https://ham.stackexchange.com", "https://ham.stackexchange.com/users/5784/" ]
I have a homemade ZS6BKW antenna so I might be able to provide some insight, even though I've only used it for a few weeks now. I get good reception on 40m and 20m with it (when conditions are favorable), and have not spent much time on the other bands. No tuner except for the built-in one on the IC-7300. With it in a ...
I was going to suggest your coax might be too short as the package my ZS6BKW suggests over 70 ft etc (Might be even more) Glad u got it fixed. I am new to this antenna and still sorting SWR on various bands. Seems like 7300 internal tuner not sufficient for tuning some of the higher SWR bands like 15.
27,900,458
I've this method to read the database: class BDUtilities ``` private Context context; private BDHelper bd; private SQLiteDatabase db_reader; private SQLiteDatabase db_writer; public BDUtilities(Context context){ this.context = context; this.bd = new BDHelper(context); this...
2015/01/12
[ "https://Stackoverflow.com/questions/27900458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2940812/" ]
you are not closing `db_writer` Regardless of not using it, you still open it at the intialisation. ``` this.db_writer = bd.getWritableDatabase(); ``` It is recommended to close it also, else the connection is leaked. ``` this.db_writer.close(); ``` Better yet would be to write a helper method that you ca...
Try this.... ``` if (c.getCount() > 0){ c.moveToFirst(); resultados.add(parse(c.getString(c.getColumnIndex("cb_save_login")))); resultados.add(parse(c.getString(c.getColumnIndex("cb_save_pic_after_share")))); resultados.add(parse(c.getStri...
27,900,458
I've this method to read the database: class BDUtilities ``` private Context context; private BDHelper bd; private SQLiteDatabase db_reader; private SQLiteDatabase db_writer; public BDUtilities(Context context){ this.context = context; this.bd = new BDHelper(context); this...
2015/01/12
[ "https://Stackoverflow.com/questions/27900458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2940812/" ]
you are not closing `db_writer` Regardless of not using it, you still open it at the intialisation. ``` this.db_writer = bd.getWritableDatabase(); ``` It is recommended to close it also, else the connection is leaked. ``` this.db_writer.close(); ``` Better yet would be to write a helper method that you ca...
this code stops the leak and fixes cursor problems. ``` public class DatabaseHelper extends SQLiteOpenHelper { private static DatabaseHelper sInstance; private static final String DATABASE_NAME = "database_name"; private static final String DATABASE_TABLE = "table_name"; private static final int DATABASE_VE...
76,586
I am new to multiplayer mode in GOW3 . I am limited to a choice of two simple weapons. I have noticed I have to shoot a lot in order to injure an opponent but a lot of them can take me down with a single shot. Can I keep weapons that I pick up in multiplayer games for later matches? Thanks.
2012/07/12
[ "https://gaming.stackexchange.com/questions/76586", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/9633/" ]
This game is not like CoD in that you are always limited to the first five starting weapons (Lancer, Retro Lancer, Sawed-Off, Gnasher, Hammerburst). From the multiplayer options menu, you can rotate your primary and secondary weapons between these. However, you will never be able to start with weapons other than these....
Hint - The X Button is the use / interact button for picking up weapons/ammo, Screen shot below:) ![Hold X to pick up and switch weapons](https://i.stack.imgur.com/HyhaF.jpg) Heres a list of all the changes in the Gears of War 3 weapons since beta: Heres a list of ALL the weapons on Gears of War 3: <http://www.ign.co...
46,286,118
``` data <- data.frame(foo = c(0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1), bar = c(1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0)) ``` Hi, Here I am having a data frame with two columns foo and bar. I want to create a new column Complete, based on foo and bar data. * If foo and bar is zero then complete should be 0. * I...
2017/09/18
[ "https://Stackoverflow.com/questions/46286118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8628070/" ]
You can create a named vector (`vect` in this example) and lookup values from that vector using `match` ``` vect = c("0 0" = 0, "1 0" = 1, "0 1" = 2) unname(vect[match(with(data, paste(foo, bar)), names(vect))]) # [1] 2 1 0 0 NA 0 2 0 1 NA 1 ```
There's a lot of ways to do this, some more efficient depending on how many conditions you have. But a basic way is: ``` data$New_Column <- with(data,ifelse(foo == 0 & bar == 0, 0, ifelse(foo == 1 & bar == 0, 1, ifelse(foo == 0 & bar == 1, 2, NA)))) # foo bar New_Co...
46,286,118
``` data <- data.frame(foo = c(0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1), bar = c(1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0)) ``` Hi, Here I am having a data frame with two columns foo and bar. I want to create a new column Complete, based on foo and bar data. * If foo and bar is zero then complete should be 0. * I...
2017/09/18
[ "https://Stackoverflow.com/questions/46286118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8628070/" ]
Following suit, using `NA` when both columns are 1. Start with the row sums. If any of them are 2 (the number of columns), replace it with `NA`. Then multiply that by the `max.col()` value. ``` rs <- rowSums(data) cbind(data, complete = max.col(data) * replace(rs, rs == 2, NA)) # foo bar complete # 1 0 1 ...
You can create a named vector (`vect` in this example) and lookup values from that vector using `match` ``` vect = c("0 0" = 0, "1 0" = 1, "0 1" = 2) unname(vect[match(with(data, paste(foo, bar)), names(vect))]) # [1] 2 1 0 0 NA 0 2 0 1 NA 1 ```
46,286,118
``` data <- data.frame(foo = c(0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1), bar = c(1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0)) ``` Hi, Here I am having a data frame with two columns foo and bar. I want to create a new column Complete, based on foo and bar data. * If foo and bar is zero then complete should be 0. * I...
2017/09/18
[ "https://Stackoverflow.com/questions/46286118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8628070/" ]
If an algebraic approach is sought, we can try one of the lines below: ``` with(data, 2L * bar + foo + 0L * NA^(bar & foo)) with(data, 2L * bar + foo + NA^(bar & foo) - 1L) with(data, (2L * bar + foo) * NA^(bar & foo)) ``` All return > > > ``` > [1] 2 1 0 0 NA 0 2 0 1 NA 1 > > ``` > > ### Explanation...
You can create a named vector (`vect` in this example) and lookup values from that vector using `match` ``` vect = c("0 0" = 0, "1 0" = 1, "0 1" = 2) unname(vect[match(with(data, paste(foo, bar)), names(vect))]) # [1] 2 1 0 0 NA 0 2 0 1 NA 1 ```
46,286,118
``` data <- data.frame(foo = c(0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1), bar = c(1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0)) ``` Hi, Here I am having a data frame with two columns foo and bar. I want to create a new column Complete, based on foo and bar data. * If foo and bar is zero then complete should be 0. * I...
2017/09/18
[ "https://Stackoverflow.com/questions/46286118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8628070/" ]
Following suit, using `NA` when both columns are 1. Start with the row sums. If any of them are 2 (the number of columns), replace it with `NA`. Then multiply that by the `max.col()` value. ``` rs <- rowSums(data) cbind(data, complete = max.col(data) * replace(rs, rs == 2, NA)) # foo bar complete # 1 0 1 ...
There's a lot of ways to do this, some more efficient depending on how many conditions you have. But a basic way is: ``` data$New_Column <- with(data,ifelse(foo == 0 & bar == 0, 0, ifelse(foo == 1 & bar == 0, 1, ifelse(foo == 0 & bar == 1, 2, NA)))) # foo bar New_Co...
46,286,118
``` data <- data.frame(foo = c(0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1), bar = c(1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0)) ``` Hi, Here I am having a data frame with two columns foo and bar. I want to create a new column Complete, based on foo and bar data. * If foo and bar is zero then complete should be 0. * I...
2017/09/18
[ "https://Stackoverflow.com/questions/46286118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8628070/" ]
If an algebraic approach is sought, we can try one of the lines below: ``` with(data, 2L * bar + foo + 0L * NA^(bar & foo)) with(data, 2L * bar + foo + NA^(bar & foo) - 1L) with(data, (2L * bar + foo) * NA^(bar & foo)) ``` All return > > > ``` > [1] 2 1 0 0 NA 0 2 0 1 NA 1 > > ``` > > ### Explanation...
There's a lot of ways to do this, some more efficient depending on how many conditions you have. But a basic way is: ``` data$New_Column <- with(data,ifelse(foo == 0 & bar == 0, 0, ifelse(foo == 1 & bar == 0, 1, ifelse(foo == 0 & bar == 1, 2, NA)))) # foo bar New_Co...
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~16~~ ~~15~~ 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ========================================================================================================================================== ``` Au…b #âŽ7×bûÏ ``` -2 bytes thanks t...
[Canvas](https://github.com/dzaima/Canvas), 23 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md) ======================================================================================================================= ``` Z7m{#+¹¹b+]{“╷!↕„2┬²@?P ``` [Try it here!](https://dzaima.github.io/Canva...
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[Jelly](https://github.com/DennisMitchell/jelly), 18?\* 20 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ========================================================================================================================== ``` ØAḣ7µp⁾b#Żs6ḣ€4ẎḊ;W€ ``` A monadic Link returning a list of lists o...
Brainfuck, 214 Bytes ==================== ``` >>>>++++++++[<++++<++++<++++++++++++<++++++++>>>>-]<<+++<++<+.>.>>.<<<.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<+.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<+.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<.>>.>.<<<+ ``` [Try it Online!](https://tio.run/##SypKzMxLK03O/v/fD...
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[Brachylog](https://github.com/JCumin/Brachylog), 36 bytes ========================================================== ``` "#b"ẹ,Ẹ↺;Ṇh₇ᵗ↔{∋ᵐc}ᶠ⟨h₅ct₁₄⟩⟨h₁₂ct₅⟩ ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/r/X0k5Senhrp06D3fteNS2y/rhzraMR03tD7dOf9Q2pfpRR/fDrROSax9uW/Bo/gqgRGtyyaOmxkdNLY/mr4SIADlNIMFWoMj///@jAA ...
[Perl 5](https://www.perl.org/), ~~47~~ 41 bytes ================================================ ```perl say for'AbA#DbD#GbG#BbEbC#F#'=~/../g,A..G ``` [Try it online!](https://tio.run/##K0gtyjH9/784sVIhLb9I3THJUdklyUXZPcld2SnJNclZ2U1Z3bZOX09PP13HUU/P/f//f/kFJZn5ecX/dX1N9QwMDQA "Perl 5 – Try It Online")
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[R](https://www.r-project.org/), 50 bytes ========================================= ```r cat("Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#") ``` [Try it online!](https://tio.run/##BcHBDcAgDATBXrhPkLYJg8F14HSA0r8zc6ve8z3NEsPESAaTKTxxXKxksdkikiDUetUP "R – Try It Online") Boring answer. [R](https://www.r-project.org/)...
[Bash 5](https://www.gnu.org/software/bash/), 42 bytes ====================================================== ``` x=`echo {A..G}{b,,#}`;echo ${x//[BE]#???/} ``` Output: ``` Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G# ```
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[Malbolge](https://github.com/TryItOnline/malbolge), ~~482~~ ~~370~~ 353 bytes ============================================================================== R1: Removed commas inbetween (as not required by the challenge) R2: Shave off a few bytes ``` ('<;_#!=6Z|{8xUwvt,PrqonKmk)"FhCUTdb?`+<;:[Z7YtVU2T|/g-O+i(gJrHc#...
[JavaScript (Node.js)](https://nodejs.org), 84 bytes ==================================================== ```javascript _=>[...'ABCDEFG'].map((n,i)=>`${i%3!=2?n+'b,':''}${n}${i%3!=1?`,${n}#`:''}`).join`,` ``` [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/e1i5aT09P3dHJ2cXVzV09Vi83sUBDI08nU9PWLkGlOlPVW...
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[Keg](https://github.com/JonoCode9374/Keg), 43 bytes ---------------------------------------------------- The string, compressed. ``` AbAA\#BbBCC\#DbDD\#EbEFF\#GbGG\#(:H<[ $]')' ``` [TIO](https://tio.run/##y05N///fMcnRMUbZKcnJ2TlG2SXJxSVG2TXJ1c0tRtk9yd09RlnDysMmWkElVl1T/f9/AA)
C, 57 bytes =========== Trivial version 57 bytes in C (gcc) ```c #include <stdio.h> f(){puts("Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#");} int main() { f(); } ``` [Try it Online!](https://tio.run/##HcyxDsIgGEXhnacg/RdIrsYdY0JLy3MIVCVR2rTg0vTZsfFM33T86el9pZj8u4SRX9cc4nR@3epDyG0ueRWNdtDQhNahRYeOYBwMDKF36DFgI...
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[R](https://www.r-project.org/), 50 bytes ========================================= ```r cat("Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#") ``` [Try it online!](https://tio.run/##BcHBDcAgDATBXrhPkLYJg8F14HSA0r8zc6ve8z3NEsPESAaTKTxxXKxksdkikiDUetUP "R – Try It Online") Boring answer. [R](https://www.r-project.org/)...
[APL (Dyalog Unicode)](https://www.dyalog.com/), 45 bytes ========================================================= ```apl 2↓(,¨⎕A)⎕R', &'⊢'AbAA#BbBCC#DbDD#EbEFF#GbGG#' ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///3@hR22QNnUMrHvVNddQEEkHqOgpq6o@6Fqk7Jjk6KjslOTk7K7skubgouya5urkpuye5uyur/0971DbhUW8fUIOn/6Ou5...
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[PHP](https://php.net/), 65 bytes ================================= Makes the list with a loop. Items are separated by `_` with a trailing separator. ```php for(;$l=ABCDEFG[$i++];)echo$l._.[$a="$l#_",$a.$b=$l.b_,$b][$i%3]; ``` [Try it online!](https://tio.run/##K8go@G9jXwAk0/KLNKxVcmwdnZxdXN3co1UytbVjrTVTkzPyVXL04v...
[Perl 5](https://www.perl.org/), ~~47~~ 41 bytes ================================================ ```perl say for'AbA#DbD#GbG#BbEbC#F#'=~/../g,A..G ``` [Try it online!](https://tio.run/##K0gtyjH9/784sVIhLb9I3THJUdklyUXZPcld2SnJNclZ2U1Z3bZOX09PP13HUU/P/f//f/kFJZn5ecX/dX1N9QwMDQA "Perl 5 – Try It Online")
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[brainfuck](https://github.com/TryItOnline/brainfuck), 106 bytes ================================================================ ``` +++[[-<+>>++<]>]<<[-<->]++<<++<,+<-<[->+>+<<]<+[>>>>>+>-[<.<<<.>.[<]]>[>]<+[---<.<.<.[<]]>[>]<++<.<<.<<<-] ``` [Try it online!](https://tio.run/##RYpBCoBADAMfFLMvCPlI6UEFQQQPgu9f25MpO...
[Keg](https://github.com/JonoCode9374/Keg), 43 bytes ---------------------------------------------------- The string, compressed. ``` AbAA\#BbBCC\#DbDD\#EbEFF\#GbGG\#(:H<[ $]')' ``` [TIO](https://tio.run/##y05N///fMcnRMUbZKcnJ2TlG2SXJxSVG2TXJ1c0tRtk9yd09RlnDysMmWkElVl1T/f9/AA)
190,013
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of on...
2019/08/14
[ "https://codegolf.stackexchange.com/questions/190013", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/77338/" ]
[Python 3](https://docs.python.org/3/), 50 bytes ================================================ ```python print(*map(''.join,zip(3*'ADGBCEF',7*' '+5*'#b'))) ``` [Try it online!](https://tio.run/##K6gsycjPM/7/v6AoM69EQys3sUBDXV0vKz8zT6cqs0DDWEvd0cXdydnVTV3HXEtdQV3bVEtdOUldU1Pz/38A "Python 3 – Try It Online") Pytho...
[R](https://www.r-project.org/), 50 bytes ========================================= ```r cat("Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#") ``` [Try it online!](https://tio.run/##BcHBDcAgDATBXrhPkLYJg8F14HSA0r8zc6ve8z3NEsPESAaTKTxxXKxksdkikiDUetUP "R – Try It Online") Boring answer. [R](https://www.r-project.org/)...
36,911,204
I am using Xcode 7.2 and I have created a swift framework, I can import the framework without error but cannon access the class files of my framework.[![enter image description here](https://i.stack.imgur.com/qJdKd.png)](https://i.stack.imgur.com/qJdKd.png) In the DropDown class file set as public [![enter image des...
2016/04/28
[ "https://Stackoverflow.com/questions/36911204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3702516/" ]
You should call Alamofire Request Function in `viewDidLoad` function. and you should `reload table data` when you got response from completion block(from where you print the data). You can reload tableview like, ``` self.tableView.reloadData() ``` hope this will help :)
First create a global bool variable with false ``` override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "CellDetailSegue" && boolVar { if let indexPaths = self.dateCollectionView.indexPathsForSelectedItems() { let subViewController = seg...
36,911,204
I am using Xcode 7.2 and I have created a swift framework, I can import the framework without error but cannon access the class files of my framework.[![enter image description here](https://i.stack.imgur.com/qJdKd.png)](https://i.stack.imgur.com/qJdKd.png) In the DropDown class file set as public [![enter image des...
2016/04/28
[ "https://Stackoverflow.com/questions/36911204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3702516/" ]
The first thing I noticed is that you are doing 3 asynchronous requests, not one. You could use a completion handler but which one? I think you have 2 options. 1. Nest the network calls so that the completion of one starts the next one. The downside to this approach is that they will run sequentially and if you add mo...
First create a global bool variable with false ``` override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "CellDetailSegue" && boolVar { if let indexPaths = self.dateCollectionView.indexPathsForSelectedItems() { let subViewController = seg...
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
According to `phpurple` [requirements](http://phurple.php.belsky.info/ch01.html): ``` Please let me know, if you've successfully compiled on earlier versions. Actually the extension is being developed on the php v5.2.6 with the option to be upcomming php v5.3 compatible. ``` The authors will need to update their...
You can check the new sources shortly posted on <https://github.com/weltling/phurple>
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
What you are seeing is PHP's shifty interface (ahem, hold your down votes, I said **s h i f t y**). By that, I mean function prototypes are subject to change from version to version. Take this meta example: ``` int foo_call_bar(const char *foobar, size_t len); ``` And in a later version of something, the function ca...
Well, the new URL seems to be a persistent repo with fixes to PHP-5.3 and above. Maybe that should be mentioned, but that won't help with checking it out anyway. For me it worked fine, so I would say it is worth a try.
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
Well, the new URL seems to be a persistent repo with fixes to PHP-5.3 and above. Maybe that should be mentioned, but that won't help with checking it out anyway. For me it worked fine, so I would say it is worth a try.
You can check the new sources shortly posted on <https://github.com/weltling/phurple>
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
According to `phpurple` [requirements](http://phurple.php.belsky.info/ch01.html): ``` Please let me know, if you've successfully compiled on earlier versions. Actually the extension is being developed on the php v5.2.6 with the option to be upcomming php v5.3 compatible. ``` The authors will need to update their...
look at that man <http://sourceforge.net/news/?group_id=235197&id=296063>
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
According to `phpurple` [requirements](http://phurple.php.belsky.info/ch01.html): ``` Please let me know, if you've successfully compiled on earlier versions. Actually the extension is being developed on the php v5.2.6 with the option to be upcomming php v5.3 compatible. ``` The authors will need to update their...
Well, the new URL seems to be a persistent repo with fixes to PHP-5.3 and above. Maybe that should be mentioned, but that won't help with checking it out anyway. For me it worked fine, so I would say it is worth a try.
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
According to `phpurple` [requirements](http://phurple.php.belsky.info/ch01.html): ``` Please let me know, if you've successfully compiled on earlier versions. Actually the extension is being developed on the php v5.2.6 with the option to be upcomming php v5.3 compatible. ``` The authors will need to update their...
A little late, but here is the latest library that works with PHP 5.3: The new project page is: <http://sourceforge.net/projects/phurple> The blog post: <http://belski.net/archives/23-Phurple-per-se-PHPurple.html> I have ran into a problem after I have complied it and added the extension to PHP.ini configuration: `...
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
What you are seeing is PHP's shifty interface (ahem, hold your down votes, I said **s h i f t y**). By that, I mean function prototypes are subject to change from version to version. Take this meta example: ``` int foo_call_bar(const char *foobar, size_t len); ``` And in a later version of something, the function ca...
You can check the new sources shortly posted on <https://github.com/weltling/phurple>
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
look at that man <http://sourceforge.net/news/?group_id=235197&id=296063>
You can check the new sources shortly posted on <https://github.com/weltling/phurple>
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
What you are seeing is PHP's shifty interface (ahem, hold your down votes, I said **s h i f t y**). By that, I mean function prototypes are subject to change from version to version. Take this meta example: ``` int foo_call_bar(const char *foobar, size_t len); ``` And in a later version of something, the function ca...
look at that man <http://sourceforge.net/news/?group_id=235197&id=296063>
4,775,117
I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..." Thanks
2011/01/23
[ "https://Stackoverflow.com/questions/4775117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535967/" ]
What you are seeing is PHP's shifty interface (ahem, hold your down votes, I said **s h i f t y**). By that, I mean function prototypes are subject to change from version to version. Take this meta example: ``` int foo_call_bar(const char *foobar, size_t len); ``` And in a later version of something, the function ca...
A little late, but here is the latest library that works with PHP 5.3: The new project page is: <http://sourceforge.net/projects/phurple> The blog post: <http://belski.net/archives/23-Phurple-per-se-PHPurple.html> I have ran into a problem after I have complied it and added the extension to PHP.ini configuration: `...
59,401,565
I have created MySQL data model to store content along with its custom attributes/field. Below is a simplified version of it. One for storing content: ``` CREATE TABLE `cms_content` ( `id` int(11) NOT NULL, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `content_type_id` int(6) NOT NULL ) ENGINE=MyISAM ...
2019/12/18
[ "https://Stackoverflow.com/questions/59401565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2363857/" ]
I guess your enterprise app is from a public client/ native app right? Assign users and groups to a native app is meaningless. Because native app doesn't act as a service principal to ask for a token. It doesn't have a client secret. You won't get the app role from a token asked by a native app. So the “users and gro...
This happens when your Application Registration (which is bound to your Enterprise App) has the following setting to `Yes`. Simply change the switch to `No`. [![enter image description here](https://i.stack.imgur.com/3rZ5H.png)](https://i.stack.imgur.com/3rZ5H.png)
68,974,902
I'm coming from a JS background. In JS I could write something as follows: ```js let x = [[1, 0], [2, 1], [3, 2], [4, 3]] x.forEach(([n, i]) => console.log()) ``` So I was trying to convert to Scala, and I found a bunch of ways to do it. But I don't understand how the `match` and `case` statement are disappearing. ...
2021/08/29
[ "https://Stackoverflow.com/questions/68974902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14238358/" ]
> > > ```scala > // where did `match` go? > x.foreach({ > case (n, i) => println(s"$n $i") > }) > > ``` > > This is a *Pattern Matching Anonymous Function*, also sometimes called a *Partial Function Literal*. See [Scala Language Specification 8.5 *Pattern Matching Anonymous Functions*](https://scala-lang.org/...
About `match` keyword: ``` // where did `match` go? x.foreach({ case (n, i) => println(s"$n $i") }) ``` This is the language specification, you can ignore match keyword in anonymous functions: <https://scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#pattern-matching-anonymous-functions>
25,489,181
So I am currently doing some work with Multi-Threading in Java and I'm pretty stuck on a, most likely, simple thing. I currently have a JButton that, when pressed invokes the method as follows: ``` private void clickTest() throws InterruptedException{ statOrganizer.incrementHappiness(); Thread t = new Thread...
2014/08/25
[ "https://Stackoverflow.com/questions/25489181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3262422/" ]
Disable the button right before starting the thread. In the thread, at the end, post an event that would re-enable the button (using invokeLater). You may also need a cancel option, but that's a separate question.
The nice solution for this is to use a [glass pane](http://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html#glasspane) to capture all events and stopping them from propagating to any of your UI elements on the panel under the glass pane. Of course while you only have one or two, you can call `setEnabled...
25,489,181
So I am currently doing some work with Multi-Threading in Java and I'm pretty stuck on a, most likely, simple thing. I currently have a JButton that, when pressed invokes the method as follows: ``` private void clickTest() throws InterruptedException{ statOrganizer.incrementHappiness(); Thread t = new Thread...
2014/08/25
[ "https://Stackoverflow.com/questions/25489181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3262422/" ]
Disable the button right before starting the thread. In the thread, at the end, post an event that would re-enable the button (using invokeLater). You may also need a cancel option, but that's a separate question.
Try the following: ``` button.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 1) { try { clickTest(); button.setEnabled(false);//this assume 'button' is final ...
24,831,438
These are my main class ``` public class Customer { public Customer() { Products = new HashSet<Product>(); } public int Id { get; set; } public string Name { get; set; } public ICollection<Product> Products { get; set; } } public class Product { public int Id { get; set; } public int CustomerId {...
2014/07/18
[ "https://Stackoverflow.com/questions/24831438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1214293/" ]
This means that for any complete object type with a fundamental alignment, it should be possible to convert the pointer returned to a pointer to that object type, respecting the alignment requirement of that object type. In practice, since alignments are powers of two, this means that an allocation function is require...
Alignment is defined by the OS and platform. Usually it is the size of the largest basic type (a pointer or `double`), but it could be more. For instance, on Windows, x86 is 8 byte and x64 is 16 byte.
24,831,438
These are my main class ``` public class Customer { public Customer() { Products = new HashSet<Product>(); } public int Id { get; set; } public string Name { get; set; } public ICollection<Product> Products { get; set; } } public class Product { public int Id { get; set; } public int CustomerId {...
2014/07/18
[ "https://Stackoverflow.com/questions/24831438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1214293/" ]
This means that for any complete object type with a fundamental alignment, it should be possible to convert the pointer returned to a pointer to that object type, respecting the alignment requirement of that object type. In practice, since alignments are powers of two, this means that an allocation function is require...
§3.11/1 says, > > Object types have alignment requirements (3.9.1, 3.9.2) which place restrictions on the addresses at which an > object of that type may be allocated. > > > So if a pointer is "suitably aligned" it means that the address represented by the pointer satisfies these restrictions. What exactly this ...
13,030,486
Can somebody advise whether there's a good built-in way (= AppleScript command) to pull out statistics for a DB: I need to count the number of occurrences of a string in a particular field over all records. E.g. for a record that has * *Name* * *Phone* * *Town* the script would return how many records exist with id...
2012/10/23
[ "https://Stackoverflow.com/questions/13030486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1089245/" ]
Step 1 - Create a relationship. - File > Manage Database > Define Database - Relationships tab - Duplicate your table occurance and name it (I used `related_towns`) - Drag a relationship between the two from town to town - Click OK. ![This is what your relationships tab should look like](https://i.stack.imgur.com...
I would do this in FileMaker. It is built for exactly this. Do you know how to do it in FM?
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
You could use [`join`](http://perldoc.perl.org/functions/join.html) and modify the last element to include an `and`: ``` my @list = 1 .. 5; $list[-1] = "and $list[-1]" if $#list; print join ', ', @list; ```
Just in the spirit of TIMTOWTDI (though, frankly, @perreal's answer is better as far as readability): ``` sub commas { my $last_index = $#_; my @with_commas = map { (($_==$last_index) ? "and " : "") . $_[$_] } 0 .. $last_index; print join("," @with_commas) } ``` This is somewhat...
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
``` sub format_list { return "" if !@_; my $last = pop(@_); return $last if !@_; return join(', ', @_) . " and " . $last; } print format_list(@list), "\n"; ``` This also handles lists with only one element, unlike most of the other answers.
You could use [`join`](http://perldoc.perl.org/functions/join.html) and modify the last element to include an `and`: ``` my @list = 1 .. 5; $list[-1] = "and $list[-1]" if $#list; print join ', ', @list; ```
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
You could use [`join`](http://perldoc.perl.org/functions/join.html) and modify the last element to include an `and`: ``` my @list = 1 .. 5; $list[-1] = "and $list[-1]" if $#list; print join ', ', @list; ```
Small hint ``` for( 1 .. 10 ) { print ; $_ == 10 ? print '' : ($_ != 9 ? print ', ' : print ' and '); } ```
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
``` #!/usr/bin/perl use warnings; use strict; sub commas { return "" if @_ == 0; return $_[0] if @_ == 1; my $last = pop @_; my $rest = join (", ", @_); return $rest.", and ".$last; } my @a = (1,2,3,4,5); print commas(@a), "\n"; ```
Small hint ``` for( 1 .. 10 ) { print ; $_ == 10 ? print '' : ($_ != 9 ? print ', ' : print ' and '); } ```
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
Add the commas then add the "and ": ``` use v5.10; my $string = join ', ', 1 .. 5; substr $string, rindex( $string, ', ' ) + 2, 0, 'and ' ; say $string; ``` So, work that in as the case when you have more than two elements: ``` use v5.10; my @array = 1..5; my $string = do { if( @array ...
Small hint ``` for( 1 .. 10 ) { print ; $_ == 10 ? print '' : ($_ != 9 ? print ', ' : print ' and '); } ```
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
There is a CPAN module for this, [Lingua::Conjunction](https://metacpan.org/module/Lingua%3a%3aConjunction). I use it myself, and recommend it over rolling your own solution. The usage syntax is very simple: ``` conjunction(@list); ```
Just in the spirit of TIMTOWTDI (though, frankly, @perreal's answer is better as far as readability): ``` sub commas { my $last_index = $#_; my @with_commas = map { (($_==$last_index) ? "and " : "") . $_[$_] } 0 .. $last_index; print join("," @with_commas) } ``` This is somewhat...
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
``` sub format_list { return "" if !@_; my $last = pop(@_); return $last if !@_; return join(', ', @_) . " and " . $last; } print format_list(@list), "\n"; ``` This also handles lists with only one element, unlike most of the other answers.
Small hint ``` for( 1 .. 10 ) { print ; $_ == 10 ? print '' : ($_ != 9 ? print ', ' : print ' and '); } ```
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
There is a CPAN module for this, [Lingua::Conjunction](https://metacpan.org/module/Lingua%3a%3aConjunction). I use it myself, and recommend it over rolling your own solution. The usage syntax is very simple: ``` conjunction(@list); ```
Add the commas then add the "and ": ``` use v5.10; my $string = join ', ', 1 .. 5; substr $string, rindex( $string, ', ' ) + 2, 0, 'and ' ; say $string; ``` So, work that in as the case when you have more than two elements: ``` use v5.10; my @array = 1..5; my $string = do { if( @array ...
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
``` sub format_list { return "" if !@_; my $last = pop(@_); return $last if !@_; return join(', ', @_) . " and " . $last; } print format_list(@list), "\n"; ``` This also handles lists with only one element, unlike most of the other answers.
There is a CPAN module for this, [Lingua::Conjunction](https://metacpan.org/module/Lingua%3a%3aConjunction). I use it myself, and recommend it over rolling your own solution. The usage syntax is very simple: ``` conjunction(@list); ```
12,201,472
I want to create a subroutine that adds commas to elements and adds an "and" before the last element, e.g., so that "12345" becomes "1, 2, 3, 4, and 5". I know how to add the commas, but the problem is the result I get is "1, 2, 3, 4, and 5," and I don't know how to get rid of the last comma. ``` sub commas { my @wi...
2012/08/30
[ "https://Stackoverflow.com/questions/12201472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572378/" ]
``` sub format_list { return "" if !@_; my $last = pop(@_); return $last if !@_; return join(', ', @_) . " and " . $last; } print format_list(@list), "\n"; ``` This also handles lists with only one element, unlike most of the other answers.
Add the commas then add the "and ": ``` use v5.10; my $string = join ', ', 1 .. 5; substr $string, rindex( $string, ', ' ) + 2, 0, 'and ' ; say $string; ``` So, work that in as the case when you have more than two elements: ``` use v5.10; my @array = 1..5; my $string = do { if( @array ...
4,209,875
* A Graph DB that can handle around 100k-1M nodes * We need nodes that can have different types and attributes * We need edges (associations between nodes) that also can have different types and attributes * Transactional support (all or nothing commits to DB) * History of changes to elements (add/remove element, add/r...
2010/11/17
[ "https://Stackoverflow.com/questions/4209875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/300314/" ]
[Neo4j](http://neo4j.org/) supports everything that you need, but it is not free for commercial projects;
Not sure if it fullfills all your requirements but IntelliDimension has a commercial product that sits on top of Microsoft SQL Server and supports SPARQL. They also provide a SDK for .Net. <http://www.intellidimension.com>
1,897,064
Prove that if $\cos^2{A} + \cos^2{B} + \cos^2{C} = 1$, then $ABC$ is right-angled. I only found that $\sin^2{A} + \sin^2{B} + \sin^2{C} = 2$, but I have no idea what to do next. Thank you in advance for your answers!
2016/08/19
[ "https://math.stackexchange.com/questions/1897064", "https://math.stackexchange.com", "https://math.stackexchange.com/users/215665/" ]
$$\cos^2{A} + \cos^2{B} + \cos^2{C} = 1$$ Use $\cos^2{A} =\frac{1+\cos2A}2$. Then $$\cos2A+\cos2B+\cos2C=-1$$ Use $\cos2A+\cos2B+\cos2C=-1-4\cos A\cos B\cos C$ Then $$-1-4\cos A\cos B\cos C=-1$$ $$4\cos A\cos B\cos C=0$$ Then $\angle A$ or $\angle B$ or $\angle C$ is $\frac{\pi}{2}$
HINT: $$F=\cos^2A+\cos^2B+\cos^2C=\cos^2A-\sin^2B+\cos^2C+1$$ Now using [Prove that $\cos (A + B)\cos (A - B) = {\cos ^2}A - {\sin ^2}B$](https://math.stackexchange.com/questions/345703/prove-that-cos-a-b-cos-a-b-cos-2a-sin-2b), $$F=\cos(A+B)\cos(A-B)+\cos^2C+1$$ Now as $\cos(A+B)=\cos(\pi-C)=-\cos C,$ $$F=-\cos C...
1,897,064
Prove that if $\cos^2{A} + \cos^2{B} + \cos^2{C} = 1$, then $ABC$ is right-angled. I only found that $\sin^2{A} + \sin^2{B} + \sin^2{C} = 2$, but I have no idea what to do next. Thank you in advance for your answers!
2016/08/19
[ "https://math.stackexchange.com/questions/1897064", "https://math.stackexchange.com", "https://math.stackexchange.com/users/215665/" ]
$$\cos^2{A} + \cos^2{B} + \cos^2{C} = 1$$ Use $\cos^2{A} =\frac{1+\cos2A}2$. Then $$\cos2A+\cos2B+\cos2C=-1$$ Use $\cos2A+\cos2B+\cos2C=-1-4\cos A\cos B\cos C$ Then $$-1-4\cos A\cos B\cos C=-1$$ $$4\cos A\cos B\cos C=0$$ Then $\angle A$ or $\angle B$ or $\angle C$ is $\frac{\pi}{2}$
By $½$-angle relations, $cos²(A)+cos²(B)+cos² (C) = 1 + ½{cos(2A)+cos(2B)} + cos²(C)$ $= 1 + cos(A+B)cos(A−B) + cos²(C) = 1 – cos (C)cos(A−B) + cos²(C),$ using $A+B=π−C$ $= 1 + cos(C){cos(C) −cos(A−B)} = 1 − 2cos (C)sin(½(C−A+B))sin(½(C+A−B))$ $= 1 – 2cos(C)sin(½π−A)sin( ½π−B) = 1 – 2cos(A)cos(B)cos(C)$ $∴ cos²(A)+...
1,897,064
Prove that if $\cos^2{A} + \cos^2{B} + \cos^2{C} = 1$, then $ABC$ is right-angled. I only found that $\sin^2{A} + \sin^2{B} + \sin^2{C} = 2$, but I have no idea what to do next. Thank you in advance for your answers!
2016/08/19
[ "https://math.stackexchange.com/questions/1897064", "https://math.stackexchange.com", "https://math.stackexchange.com/users/215665/" ]
$$\cos^2{A} + \cos^2{B} + \cos^2{C} = 1$$ Use $\cos^2{A} =\frac{1+\cos2A}2$. Then $$\cos2A+\cos2B+\cos2C=-1$$ Use $\cos2A+\cos2B+\cos2C=-1-4\cos A\cos B\cos C$ Then $$-1-4\cos A\cos B\cos C=-1$$ $$4\cos A\cos B\cos C=0$$ Then $\angle A$ or $\angle B$ or $\angle C$ is $\frac{\pi}{2}$
As you found that $\sin^2{A} + \sin^2{B} + \sin^2{C} = 2$ note that $\sin^2 \theta + \cos^2 \theta =1$ Then $1-\cos^2 A + 1- \cos^2 B + 1 - \cos^2 C = 2$ $ 3 -(\cos^2 A + \cos^2 B + \cos^2 C)= 2$ $3 - 2 = \cos^2 A + \cos^2 B + \cos^2 C$ $\cos^2 A + \cos^2 B + \cos^2 C =1$
261,222
There is issue in saving lightning components. Lightning components which has controller(which is referring User's fields). Error message are stating like - There is no such column "Email" on User entity; where as the running user is System administrator. Let us know, if someone found root cause, or work around for...
2019/05/06
[ "https://salesforce.stackexchange.com/questions/261222", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/25920/" ]
I also experienced this same issue in one my of custom lightning component. Where it was throwing the error message - There is no such column "ContactId" on User entity; After struggling the whole day I got a solution for this. **It is just to recompile APEX Classes.** **Steps to fix it:** 1. Login to Salesforce or...
You need to recompile classes then it will work. When ever it doesn't save I compile all classes and i was able to save it. I suspect it might be due to summer 19 release patches.
30,788,175
I am working on improving my coding/ development skills and am new to using Ant. My goal is to be able to compile programs more complicated than "Hello World" from the command line. The program I am trying to compile and run uses libraries at that stored in an API, and I think I have included the correct path in my bui...
2015/06/11
[ "https://Stackoverflow.com/questions/30788175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4972109/" ]
I had the same error. Turns out that Eclipse was using a symlink in the Eclipse setup for Ant Home (external ant installation). I solved it by changing Eclipse's Ant Home to a definitive location. In Eclipse `Window`->`Preferences` then `Ant`->`Runtime` then click on the `Ant Home...` button on the right and choose ...
You compiled with the classpath set to the `dropbox-core-sdk-1.7.7.jar` jar, but you didn't *run* the code with that classpath. You need to do the same for the `java` task, otherwise the JVM won't find the third-party classes. ``` <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"> <classpath> ...
29,293,464
I am working on a Javascript object exercise. My output is not what I expected. Please take a look at my code and give some advise. Here is the code: ``` function myFunction(name) { this.name = name; this.models = new Array(); this.add = function (brand){ this.models = brand; }; } var c = new myFunction ...
2015/03/27
[ "https://Stackoverflow.com/questions/29293464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3222088/" ]
Change the add function. You want to push the brand into the model. Not set the model to it. ``` this.add = function (brand){ this.models.push(brand); }; ```
To add something to an array, you should use the `.push()` method. Change your code to: ``` function myFunction(name) { this.name = name; this.models = new Array(); this.add = function (brand){ this.models.push(brand); }; } ``` P.S. It is customary to name such constructor type of functions starting wi...
50,054,890
I've been trying to change the font color of the status bar using Xamarin (where the Battery, Signal and Clock is)... Can somebody advice me how to do this? Thank you
2018/04/27
[ "https://Stackoverflow.com/questions/50054890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3562775/" ]
I'm not sure what API level your trying to target, but if you can use API 23 specific stuff, you can add the following to your AppTheme styles.xml: ``` <item name="android:statusBarColor">@color/colorPrimaryDark</item> <item name="android:windowLightStatusBar">true</item> ``` when android:windowLightStatusBar is set...
You can change it by changing "colorPrimaryDark" attiribute of "color.xml" file where under android native project.
50,054,890
I've been trying to change the font color of the status bar using Xamarin (where the Battery, Signal and Clock is)... Can somebody advice me how to do this? Thank you
2018/04/27
[ "https://Stackoverflow.com/questions/50054890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3562775/" ]
``` if (Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.M) { var activity = Activity; //your activity ref.. var needWhite = true; //your goal // Fetch the current flags. var flags = activity.Window.DecorView.SystemUiVisibility; // Update the SystemUiVisibility dependening o...
You can change it by changing "colorPrimaryDark" attiribute of "color.xml" file where under android native project.
50,054,890
I've been trying to change the font color of the status bar using Xamarin (where the Battery, Signal and Clock is)... Can somebody advice me how to do this? Thank you
2018/04/27
[ "https://Stackoverflow.com/questions/50054890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3562775/" ]
I'm not sure what API level your trying to target, but if you can use API 23 specific stuff, you can add the following to your AppTheme styles.xml: ``` <item name="android:statusBarColor">@color/colorPrimaryDark</item> <item name="android:windowLightStatusBar">true</item> ``` when android:windowLightStatusBar is set...
``` if (Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.M) { var activity = Activity; //your activity ref.. var needWhite = true; //your goal // Fetch the current flags. var flags = activity.Window.DecorView.SystemUiVisibility; // Update the SystemUiVisibility dependening o...
367,132
I have a text file which contains (among others) the following lines: ``` {chapter}{{1}Einleitung}{27}{chapter.1} {chapter}{{2}Grundlagen}{35}{chapter.2} ``` How can I * get the 2 lines from this text file (they will always contain `}Einleitung` resp. `}Grundlagen}` and * extract the 2 page numbers (in this case...
2011/12/12
[ "https://superuser.com/questions/367132", "https://superuser.com", "https://superuser.com/users/92184/" ]
calc.awk: ``` BEGIN { FS="}{"; # split lines by '}{' e=0; # set variable 'e' to 0 g=0; # set variable 'g' to 0 } /Einleitung/ { e=$3; } # 'Einleitung' matches, extract the page /Grundlagen/ { g=$3;} # 'Grundlagen' matches, extract the page END { print g-e; ...
``` $ DIFFERENCE=$(( $( cat FILENAME | grep Grundlagen | head -n1 | cut -c26-27 ) - $( cat FILENAME | grep Einleitung | head -n1 | cut -c26-27 ) )) $ echo $DIFFERENCE 8 ``` This requires that the lines always look exactly like this (i.e. no different headline), because of the `cut`.
367,132
I have a text file which contains (among others) the following lines: ``` {chapter}{{1}Einleitung}{27}{chapter.1} {chapter}{{2}Grundlagen}{35}{chapter.2} ``` How can I * get the 2 lines from this text file (they will always contain `}Einleitung` resp. `}Grundlagen}` and * extract the 2 page numbers (in this case...
2011/12/12
[ "https://superuser.com/questions/367132", "https://superuser.com", "https://superuser.com/users/92184/" ]
~~I do not know if Mac OS X has awk. If it does, this should work:~~ This should work: ``` DIFFERENZ=$(awk 'BEGIN { FS="[{}]+" } { if ($4=="Einleitung") EINLEITUNG=$5 if ($4=="Grundlagen") GRUNDLAGEN=$5 } END { print GRUNDLAGEN-EINLEITUNG }' textfile) ``` How it works: * `FS="[{}]+"` sets the fie...
``` $ DIFFERENCE=$(( $( cat FILENAME | grep Grundlagen | head -n1 | cut -c26-27 ) - $( cat FILENAME | grep Einleitung | head -n1 | cut -c26-27 ) )) $ echo $DIFFERENCE 8 ``` This requires that the lines always look exactly like this (i.e. no different headline), because of the `cut`.
367,132
I have a text file which contains (among others) the following lines: ``` {chapter}{{1}Einleitung}{27}{chapter.1} {chapter}{{2}Grundlagen}{35}{chapter.2} ``` How can I * get the 2 lines from this text file (they will always contain `}Einleitung` resp. `}Grundlagen}` and * extract the 2 page numbers (in this case...
2011/12/12
[ "https://superuser.com/questions/367132", "https://superuser.com", "https://superuser.com/users/92184/" ]
Pure bash 4.x, and shows the differences for every chapter: ``` unset page_last title_last page_cur title_cur re='\{chapter\}\{\{[[:digit:]]+\}([^}]+)\}\{([[:digit:]]+)\}' while read -r line; do if [[ $line =~ $re ]]; then title_cur=${BASH_REMATCH[1]} page_cur=${BASH_REMATCH[2]} diff=$((page_cur-pa...
``` $ DIFFERENCE=$(( $( cat FILENAME | grep Grundlagen | head -n1 | cut -c26-27 ) - $( cat FILENAME | grep Einleitung | head -n1 | cut -c26-27 ) )) $ echo $DIFFERENCE 8 ``` This requires that the lines always look exactly like this (i.e. no different headline), because of the `cut`.
367,132
I have a text file which contains (among others) the following lines: ``` {chapter}{{1}Einleitung}{27}{chapter.1} {chapter}{{2}Grundlagen}{35}{chapter.2} ``` How can I * get the 2 lines from this text file (they will always contain `}Einleitung` resp. `}Grundlagen}` and * extract the 2 page numbers (in this case...
2011/12/12
[ "https://superuser.com/questions/367132", "https://superuser.com", "https://superuser.com/users/92184/" ]
~~I do not know if Mac OS X has awk. If it does, this should work:~~ This should work: ``` DIFFERENZ=$(awk 'BEGIN { FS="[{}]+" } { if ($4=="Einleitung") EINLEITUNG=$5 if ($4=="Grundlagen") GRUNDLAGEN=$5 } END { print GRUNDLAGEN-EINLEITUNG }' textfile) ``` How it works: * `FS="[{}]+"` sets the fie...
calc.awk: ``` BEGIN { FS="}{"; # split lines by '}{' e=0; # set variable 'e' to 0 g=0; # set variable 'g' to 0 } /Einleitung/ { e=$3; } # 'Einleitung' matches, extract the page /Grundlagen/ { g=$3;} # 'Grundlagen' matches, extract the page END { print g-e; ...
367,132
I have a text file which contains (among others) the following lines: ``` {chapter}{{1}Einleitung}{27}{chapter.1} {chapter}{{2}Grundlagen}{35}{chapter.2} ``` How can I * get the 2 lines from this text file (they will always contain `}Einleitung` resp. `}Grundlagen}` and * extract the 2 page numbers (in this case...
2011/12/12
[ "https://superuser.com/questions/367132", "https://superuser.com", "https://superuser.com/users/92184/" ]
calc.awk: ``` BEGIN { FS="}{"; # split lines by '}{' e=0; # set variable 'e' to 0 g=0; # set variable 'g' to 0 } /Einleitung/ { e=$3; } # 'Einleitung' matches, extract the page /Grundlagen/ { g=$3;} # 'Grundlagen' matches, extract the page END { print g-e; ...
Pure bash 4.x, and shows the differences for every chapter: ``` unset page_last title_last page_cur title_cur re='\{chapter\}\{\{[[:digit:]]+\}([^}]+)\}\{([[:digit:]]+)\}' while read -r line; do if [[ $line =~ $re ]]; then title_cur=${BASH_REMATCH[1]} page_cur=${BASH_REMATCH[2]} diff=$((page_cur-pa...
367,132
I have a text file which contains (among others) the following lines: ``` {chapter}{{1}Einleitung}{27}{chapter.1} {chapter}{{2}Grundlagen}{35}{chapter.2} ``` How can I * get the 2 lines from this text file (they will always contain `}Einleitung` resp. `}Grundlagen}` and * extract the 2 page numbers (in this case...
2011/12/12
[ "https://superuser.com/questions/367132", "https://superuser.com", "https://superuser.com/users/92184/" ]
~~I do not know if Mac OS X has awk. If it does, this should work:~~ This should work: ``` DIFFERENZ=$(awk 'BEGIN { FS="[{}]+" } { if ($4=="Einleitung") EINLEITUNG=$5 if ($4=="Grundlagen") GRUNDLAGEN=$5 } END { print GRUNDLAGEN-EINLEITUNG }' textfile) ``` How it works: * `FS="[{}]+"` sets the fie...
Pure bash 4.x, and shows the differences for every chapter: ``` unset page_last title_last page_cur title_cur re='\{chapter\}\{\{[[:digit:]]+\}([^}]+)\}\{([[:digit:]]+)\}' while read -r line; do if [[ $line =~ $re ]]; then title_cur=${BASH_REMATCH[1]} page_cur=${BASH_REMATCH[2]} diff=$((page_cur-pa...
66,559,622
I want to update some data from the DB, so I added this Controller method: ``` public function updateAnswer(Answer $anss) { $validate_data = Validator::make(request()->all(),[ 'answer' => 'required' ])->validated(); $answer = Answer::findOrFail($anss); $answer->update($v...
2021/03/10
[ "https://Stackoverflow.com/questions/66559622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You are already resolving `$anss` using [route-model binding](https://laravel.com/docs/8.x/routing#route-model-binding). ``` public function updateAnswer(Answer $anss) ``` You are trying to call `findOrFail` with a model as an argument, which since `Model` implements `Arrayable` will return a `Collection`, thus brea...
`$anss` is already an Answer object so you do not need to query it from the database. ``` $anss->answer = $validate_data['answer']; $anss->save(); ``` or ``` Answer::where('id', $anss->id) ->update($validate_data); ```
4,592,363
I am developing an RSS-reader-type application. I am toying with the possibility of using a normal TableView application but showing the articles as a film-strip. I am mainly thinking for an iPad application (but possible it works on the smaller iPhone as well). The idea is to have the cells passing/scrolling across t...
2011/01/04
[ "https://Stackoverflow.com/questions/4592363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/542664/" ]
The most obvious solution that springs to mind would be to use a UIScrollView, as this will provide the inertial effects, etc. for free - all you'd have to do it populate it with the relevant sub-views. (UITableView's actually use a UIScrollView.) For more information and sample code, see Apple's [UIScrollView docs](h...
If you want horizontal scrolling, take a look at Jeremy Tregunna’s [JScrollingRow](http://codaset.com/jer/jscrollingrow). It’s open source under a public domain licence.
504,060
If a body goes to the deep space then what is the temperature of that body? At that point of space is colder than the body, then the body also maintain temperature if not then what will be happen?
2019/09/21
[ "https://physics.stackexchange.com/questions/504060", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/242992/" ]
There is a geometric picture of the electromagnetic field in terms of "warps and curves," as you put it. This picture is in precise analogy to that general relativity, although it involves different mathematical objects with different physical interpretations. In general relativity, the "warps and curves" in spacetime...
You cannot explain electric and magnetic fields as curved spacetime. Gravity is different. Gravity affects everything - electrons, protons, neutrons, and so on. Even light from a distant start is bent by the sun's gravity as it passes close to the surface. Gravity is a distortion of times and distances. Clocks run a...
10,789,410
I am making a website in Joomla. And on my front page I have some images, which are links. I want these images a's to get a slightly green effect, like opacity + green and stil have the original images below. Is this possible to do with only css? I can get the opacity to work, but not the green color. Hope some o...
2012/05/28
[ "https://Stackoverflow.com/questions/10789410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1089353/" ]
This is doable with CSS. The main trick is that the links currently aren't surrounding the img block because their display type is inline. Assuming the following HTML: ``` <a href="#" class="greenish"><img src="..." /></a> ``` This is the CSS you need: ``` a.greenish { background: green; display: inline-b...
You won't be able to do what you want with pure CSS easily. There is no "overlay" in CSS. You can manipulate the background color/opacity, but the image would always be on top of that so it would not achieve the effect you want. What you will need to do is to make the image the background of the A, then change the bac...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
you can that ``` #include <iostream> template<typename T> struct Facility { template<T head,T ... list> struct List { static void print() { std::cout<<"\"" << head; ((std::cout << " " << list), ...); std::cout<<"\""; } }; }; template<int ... intlist> using IntList = typename Facility<int>...
In general, you use recursion for tasks like this. You have to define what happens when there are 2 or more and 1 elements in the list and recursively fall back to those definitions: ``` template <int ...> struct List; template <int First, int Second, int ... More> struct List { static void print() { std:...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
In general, you use recursion for tasks like this. You have to define what happens when there are 2 or more and 1 elements in the list and recursively fall back to those definitions: ``` template <int ...> struct List; template <int First, int Second, int ... More> struct List { static void print() { std:...
You can reuse `print()` to achieve this behaviour. Afterall you are doing a `fold` operation which is by definition resursive. [Live Demo](https://wandbox.org/permlink/qLg7dneQhB2nrRLR) ``` template<T head,T ... rest_of_pack> struct List<head , rest_of_pack...> { static void print_() { std::cout<<head<...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
In general, you use recursion for tasks like this. You have to define what happens when there are 2 or more and 1 elements in the list and recursively fall back to those definitions: ``` template <int ...> struct List; template <int First, int Second, int ... More> struct List { static void print() { std:...
Not perfectly aligned with the question but I think may be useful putting here a solution based on fold expressions that generates a string from string-like arguments that should minimize dynamic memory allocations: ```cpp #include <iostream> #include <concepts> // std::convertible_to #include <string> #include <strin...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
you can that ``` #include <iostream> template<typename T> struct Facility { template<T head,T ... list> struct List { static void print() { std::cout<<"\"" << head; ((std::cout << " " << list), ...); std::cout<<"\""; } }; }; template<int ... intlist> using IntList = typename Facility<int>...
You can reuse `print()` to achieve this behaviour. Afterall you are doing a `fold` operation which is by definition resursive. [Live Demo](https://wandbox.org/permlink/qLg7dneQhB2nrRLR) ``` template<T head,T ... rest_of_pack> struct List<head , rest_of_pack...> { static void print_() { std::cout<<head<...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
you can that ``` #include <iostream> template<typename T> struct Facility { template<T head,T ... list> struct List { static void print() { std::cout<<"\"" << head; ((std::cout << " " << list), ...); std::cout<<"\""; } }; }; template<int ... intlist> using IntList = typename Facility<int>...
If you need space only between numbers (and not after the last or before the first too), you might do: ``` template <std::size_t... Is> void print_seq(std::index_sequence<Is...>) { const char* sep = ""; (((std::cout << sep << Is), sep = " "), ...); } ``` [Demo](http://coliru.stacked-crooked.com/a/0ed85128df8...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
you can that ``` #include <iostream> template<typename T> struct Facility { template<T head,T ... list> struct List { static void print() { std::cout<<"\"" << head; ((std::cout << " " << list), ...); std::cout<<"\""; } }; }; template<int ... intlist> using IntList = typename Facility<int>...
Not perfectly aligned with the question but I think may be useful putting here a solution based on fold expressions that generates a string from string-like arguments that should minimize dynamic memory allocations: ```cpp #include <iostream> #include <concepts> // std::convertible_to #include <string> #include <strin...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
If you need space only between numbers (and not after the last or before the first too), you might do: ``` template <std::size_t... Is> void print_seq(std::index_sequence<Is...>) { const char* sep = ""; (((std::cout << sep << Is), sep = " "), ...); } ``` [Demo](http://coliru.stacked-crooked.com/a/0ed85128df8...
You can reuse `print()` to achieve this behaviour. Afterall you are doing a `fold` operation which is by definition resursive. [Live Demo](https://wandbox.org/permlink/qLg7dneQhB2nrRLR) ``` template<T head,T ... rest_of_pack> struct List<head , rest_of_pack...> { static void print_() { std::cout<<head<...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
You can reuse `print()` to achieve this behaviour. Afterall you are doing a `fold` operation which is by definition resursive. [Live Demo](https://wandbox.org/permlink/qLg7dneQhB2nrRLR) ``` template<T head,T ... rest_of_pack> struct List<head , rest_of_pack...> { static void print_() { std::cout<<head<...
Not perfectly aligned with the question but I think may be useful putting here a solution based on fold expressions that generates a string from string-like arguments that should minimize dynamic memory allocations: ```cpp #include <iostream> #include <concepts> // std::convertible_to #include <string> #include <strin...
51,281,811
I am using a fold expression to print elements in a variadic pack, but how do I get a space in between each element? Currently the output is "1 234", the desired output is "1 2 3 4" ``` template<typename T, typename Comp = std::less<T> > struct Facility { template<T ... list> struct List { static void print() ...
2018/07/11
[ "https://Stackoverflow.com/questions/51281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9917671/" ]
If you need space only between numbers (and not after the last or before the first too), you might do: ``` template <std::size_t... Is> void print_seq(std::index_sequence<Is...>) { const char* sep = ""; (((std::cout << sep << Is), sep = " "), ...); } ``` [Demo](http://coliru.stacked-crooked.com/a/0ed85128df8...
Not perfectly aligned with the question but I think may be useful putting here a solution based on fold expressions that generates a string from string-like arguments that should minimize dynamic memory allocations: ```cpp #include <iostream> #include <concepts> // std::convertible_to #include <string> #include <strin...
26,970,250
I'm trying to get my head around the following sql problem: I have an `ACTIONS` table that contains the following: ``` ------------------------------------ | ACTIONS | |----------------------------------| | ID | | GROUP_ID | | ...
2014/11/17
[ "https://Stackoverflow.com/questions/26970250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3425703/" ]
The `fwrite` function writes a *chunk of memory* to a file and your chunk of memory in this case is an integer in *binary* form. For example, the decimal integer `314,159` (`4CB2F16`) in 32-bit big-endian format would be stored in memory as the hex digits: ```none +----+----+----+----+ | 00 | 04 | CB | 2F | +----+----...
Your problem lies with the fact that *you have used* the **fwrite** function instead of the **fprintf** function. The fwrite function is a function commonly used to write binary data into a file. The data which we read in a file is generally ASCII. ASCII text uses 1 byte (8 bits or 8 0/1 places to fill) to represent e...
27,027,447
So for my responsive site, when in the mobile-scale, I have an "Email Us" button that the user can tap to open up the email client. Originally this was a simple mailto:, but I've since changed it, but as I wanted to keep the changes to an absolute minimum, I decided upon the following method: Replace the `"mailto:exa...
2014/11/19
[ "https://Stackoverflow.com/questions/27027447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2352022/" ]
Yes, the java access modifier's define a classes boundaries and to some extent a package's boundaries but a module is larger than a single class or package. You may want to see <http://www.slideshare.net/bjhargrave/why-osgi> which explains the progression of encapsulation through classes and onto modules.
I thought about it a little bit, and realized that there are certain privacy restrictions that OSGI's export mechanism can impose that plain old Java access modifiers cannot. See the diagrams below. ![enter image description here](https://i.stack.imgur.com/ncqoP.png) ![enter image description here](https://i.stack.imgu...
27,027,447
So for my responsive site, when in the mobile-scale, I have an "Email Us" button that the user can tap to open up the email client. Originally this was a simple mailto:, but I've since changed it, but as I wanted to keep the changes to an absolute minimum, I decided upon the following method: Replace the `"mailto:exa...
2014/11/19
[ "https://Stackoverflow.com/questions/27027447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2352022/" ]
**Short answer** In a modularized system it is very important to separate API from implementation where only API is exported. You cannot do that based on class modifiers. Other very important part of OSGi is the versioning of packages. You have to assign version only to those packages that are exported. **Long answer...
I thought about it a little bit, and realized that there are certain privacy restrictions that OSGI's export mechanism can impose that plain old Java access modifiers cannot. See the diagrams below. ![enter image description here](https://i.stack.imgur.com/ncqoP.png) ![enter image description here](https://i.stack.imgu...
21,260,272
I need a Set object type in my code. But in some browsers such object type [already exists](http://msdn.microsoft.com/en-us/library/ie/dn251547%28v=vs.94%29.aspx) and my class and standard are compatible by members. How I can declare my class only if it not exists in browser script host ? For example: ``` if (typeof ...
2014/01/21
[ "https://Stackoverflow.com/questions/21260272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987850/" ]
The most robust way is probably to use this: ``` if (!("Set" in window)) { window.Set = function () { ... } } ``` In the chance that `window.Set` is defined, but its value is `undefined`, this will correctly see that it has been defined, unlike checking the value, or using `typeof`. If you need ...
Something like this should work. ``` if (window.Set === undefined) { window.Set = MySet; } ```
21,260,272
I need a Set object type in my code. But in some browsers such object type [already exists](http://msdn.microsoft.com/en-us/library/ie/dn251547%28v=vs.94%29.aspx) and my class and standard are compatible by members. How I can declare my class only if it not exists in browser script host ? For example: ``` if (typeof ...
2014/01/21
[ "https://Stackoverflow.com/questions/21260272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987850/" ]
The most robust way is probably to use this: ``` if (!("Set" in window)) { window.Set = function () { ... } } ``` In the chance that `window.Set` is defined, but its value is `undefined`, this will correctly see that it has been defined, unlike checking the value, or using `typeof`. If you need ...
Simply use [`typeof`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) to determine whether it is `undefined`: ``` if (typeof window.Set === 'undefined') ... ```
21,260,272
I need a Set object type in my code. But in some browsers such object type [already exists](http://msdn.microsoft.com/en-us/library/ie/dn251547%28v=vs.94%29.aspx) and my class and standard are compatible by members. How I can declare my class only if it not exists in browser script host ? For example: ``` if (typeof ...
2014/01/21
[ "https://Stackoverflow.com/questions/21260272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987850/" ]
The most robust way is probably to use this: ``` if (!("Set" in window)) { window.Set = function () { ... } } ``` In the chance that `window.Set` is defined, but its value is `undefined`, this will correctly see that it has been defined, unlike checking the value, or using `typeof`. If you need ...
A simple truthiness test will suffice: ``` if (!window.Set) { window.Set = ... ```
47,975,191
I've been reading on compiler optimizations vs CPU optimizations, and `volatile` vs memory barriers. One thing which isn't clear to me is that my current understanding is that CPU optimizations and compiler optimizations are orthogonal. I.e. can occur independently of each other. However, the article [volatile consid...
2017/12/26
[ "https://Stackoverflow.com/questions/47975191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5154090/" ]
1. Yes, gcc has special knowledge of the semantics of `cpu_relax` or whatever it expands to, and must translate it to something for which the hardware will respect the semantics too. 2. Yes, any kind of memory fencing primitive needs special respect by the compiler and hardware. 3. Look at what the macro expands to, e....
There are a number subtle questions related to cpu and smp concurrency in your questions which will require you to look at the kernel code. Here are some quick ideas to get you started on the research specifically for the x86 architecture. The idea is that you are trying to perform a concurrency operation where your k...
64,085,488
I am trying to show results that I get from a SQL table, it is this: [![enter image description here](https://i.stack.imgur.com/HLtWC.png)](https://i.stack.imgur.com/HLtWC.png) what I want to do is show results 3 by 3, like this: [![enter image description here](https://i.stack.imgur.com/EGeWV.png)](https://i.stack....
2020/09/27
[ "https://Stackoverflow.com/questions/64085488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6441762/" ]
in `onChange` you need to call like this ``` onChange={(e) => { setValue(e.target.value); props.handleSliderChange(e.target.value); }} ``` since value is not updated instantly when you call `setValue(e.target.value);` , `value` will have previous value that you are passing in `props.handl...
The issue is on the `onClick` callback of `FlightRange` `input`, see comments on code below ``` onChange = {(e) => { setValue(e.target.value); // this is async // therefore, the value you are passing here is not the same as e.target.value but simply the value before setting the state props.handleSliderChange(va...
64,085,488
I am trying to show results that I get from a SQL table, it is this: [![enter image description here](https://i.stack.imgur.com/HLtWC.png)](https://i.stack.imgur.com/HLtWC.png) what I want to do is show results 3 by 3, like this: [![enter image description here](https://i.stack.imgur.com/EGeWV.png)](https://i.stack....
2020/09/27
[ "https://Stackoverflow.com/questions/64085488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6441762/" ]
in `onChange` you need to call like this ``` onChange={(e) => { setValue(e.target.value); props.handleSliderChange(e.target.value); }} ``` since value is not updated instantly when you call `setValue(e.target.value);` , `value` will have previous value that you are passing in `props.handl...
It because the child is having it's own life cycle since you are using `useState` in child. so whatever props you pass to your child, the child's state won't affected. plus you are passing incorrect value in `onChange` **Solution:** just use the props value directly on child (do not store in state): ``` export const...
64,085,488
I am trying to show results that I get from a SQL table, it is this: [![enter image description here](https://i.stack.imgur.com/HLtWC.png)](https://i.stack.imgur.com/HLtWC.png) what I want to do is show results 3 by 3, like this: [![enter image description here](https://i.stack.imgur.com/EGeWV.png)](https://i.stack....
2020/09/27
[ "https://Stackoverflow.com/questions/64085488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6441762/" ]
The issue is on the `onClick` callback of `FlightRange` `input`, see comments on code below ``` onChange = {(e) => { setValue(e.target.value); // this is async // therefore, the value you are passing here is not the same as e.target.value but simply the value before setting the state props.handleSliderChange(va...
It because the child is having it's own life cycle since you are using `useState` in child. so whatever props you pass to your child, the child's state won't affected. plus you are passing incorrect value in `onChange` **Solution:** just use the props value directly on child (do not store in state): ``` export const...
3,815,606
The plane $/4+/4+/7=1$ intersects the $-$ , $ -$ , and $-$ axes in points $, , $. Find the area of the triangle $Δ$. So here's my attempt. First I find the normal vector: $\left\langle\frac{1}{4}+\frac{1}{4}+\frac{1}{7}\right\rangle$ And then I find its magnitude: $\frac{\sqrt{57}}{14\sqrt{2}}$ And then I take a h...
2020/09/05
[ "https://math.stackexchange.com/questions/3815606", "https://math.stackexchange.com", "https://math.stackexchange.com/users/752703/" ]
The points $P,Q,R$ are easily seen to be $P=(4,0,0),Q=(0,4,0),R=(0,0,7)$. By the symmetry in the $x-$ and $y-$coordinates, this is an isosceles triangle with base $PQ$ and height $TR$, where $T$ is the mid-point of $PQ$. Can you take it from there?
The process you're going through doesn't find the area of the correct triangle. Finding the x-, y-, and z-intercepts is actually quite simple, as they are the solutions to the equation of the plane with two of the three variables equal to $0$. $x/4+0/4+0/7=1$ implies the x-intercept is $(4,0,0)$. Similarly, the y- and...
3,815,606
The plane $/4+/4+/7=1$ intersects the $-$ , $ -$ , and $-$ axes in points $, , $. Find the area of the triangle $Δ$. So here's my attempt. First I find the normal vector: $\left\langle\frac{1}{4}+\frac{1}{4}+\frac{1}{7}\right\rangle$ And then I find its magnitude: $\frac{\sqrt{57}}{14\sqrt{2}}$ And then I take a h...
2020/09/05
[ "https://math.stackexchange.com/questions/3815606", "https://math.stackexchange.com", "https://math.stackexchange.com/users/752703/" ]
Points of intersection are $$P=(4,0,0)\quad Q=(0,4,0)\quad R=(0,0,7)\quad$$ then we can find the base and hight and then the area. Otherwise we can use [cross product](https://en.wikipedia.org/wiki/Triangle#Using_vectors) $$S=\frac12 \left|\vec{RP}\times \vec{RQ}\right|$$
The process you're going through doesn't find the area of the correct triangle. Finding the x-, y-, and z-intercepts is actually quite simple, as they are the solutions to the equation of the plane with two of the three variables equal to $0$. $x/4+0/4+0/7=1$ implies the x-intercept is $(4,0,0)$. Similarly, the y- and...