text:
Q: Jenkins & dredd. "npm ERR! Failed at the protagonist@0.8.0 install script" I'm trying to integrate dredd apiary tests into Jenkins. I followed these steps to install NodeJS, npm and dredd on Jenkins (on Linux):
https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
While running the test I got this ERR message:
npm ERR! Failed at the protagonist@0.8.0 install script.
npm ERR! This is most likely a problem with the protagonist package,
npm ERR! not with npm itself....

Do you know this problem? Is there a solution for it? The complete log:
Building in workspace /data/jenkins/jobs/Automatic APIary Test/workspace
Checkout:workspace / /data/jenkins/jobs/Automatic APIary Test/workspace - hudson.remoting.LocalChannel@14e4ed4
Using strategy: Default
Last Built Revision: Revision 367475bec30334f138309b9c28e63e953b773adc (origin/master, origin/HEAD)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 367475bec30334f138309b9c28e63e953b773adc (origin/master, origin/HEAD)
Checking out Revision 367475bec30334f138309b9c28e63e953b773adc (origin/master, origin/HEAD)
Warning : There are multiple branch changesets here
$ /data/jenkins/tools/nodejs/bin/npm install -g dredd
npm http GET https://registry.npmjs.org/dredd
npm http 304 https://registry.npmjs.org/dredd
npm http GET https://registry.npmjs.org/protagonist
npm http GET https://registry.npmjs.org/uri-template
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/html
npm http GET https://registry.npmjs.org/htmlencode
npm http GET https://registry.npmjs.org/marked
npm http GET https://registry.npmjs.org/advisable
npm http GET https://registry.npmjs.org/proxyquire
npm http GET https://registry.npmjs.org/coffee-script/1.6.3
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/file
npm http GET https://registry.npmjs.org/gavel
npm http GET https://registry.npmjs.org/winston
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/proxyquire
npm http 304 https://registry.npmjs.org/htmlencode
npm http 304 https://registry.npmjs.org/uri-template
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/html
npm http 304 https://registry.npmjs.org/coffee-script/1.6.3
npm http 304 https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/winston
npm http 304 https://registry.npmjs.org/advisable
npm http 304 https://registry.npmjs.org/file
npm http 304 https://registry.npmjs.org/marked
npm http 304 https://registry.npmjs.org/protagonist
npm http 304 https://registry.npmjs.org/gavel
npm WARN engine uri-template@0.4.1: wanted: {"node":"~0.10.4"} (current: {"node":"v0.11.12","npm":"1.4.3"})
npm http GET https://registry.npmjs.org/pct-encode
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/minimist
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/eyes
npm http GET https://registry.npmjs.org/pkginfo
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/stack-trace
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/cycle
npm http 304 https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/minimist
npm http 304 https://registry.npmjs.org/pct-encode
npm http 304 https://registry.npmjs.org/eyes
npm http 304 https://registry.npmjs.org/colors
npm http 304 https://registry.npmjs.org/stack-trace
npm http 304 https://registry.npmjs.org/pkginfo
npm http 304 https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/async/0.2.9
npm http GET https://registry.npmjs.org/commander/2.0.0
npm http GET https://registry.npmjs.org/curl-trace-parser/0.0.7

npm http GET https://registry.npmjs.org/http-string-parser/0.0.4
npm http GET https://registry.npmjs.org/googlediff/0.1.0
npm http GET https://registry.npmjs.org/json-pointer/0.0.4
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/commander/2.0.0
npm http 304 https://registry.npmjs.org/curl-trace-parser/0.0.7
npm http 304 https://registry.npmjs.org/googlediff/0.1.0
npm http 304 https://registry.npmjs.org/async/0.2.9
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/http-string-parser/0.0.4
npm http 304 https://registry.npmjs.org/json-pointer/0.0.4
npm http 304 https://registry.npmjs.org/cycle
npm http GET https://registry.npmjs.org/form-data
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/hawk
npm http GET https://registry.npmjs.org/node-uuid
npm http GET https://registry.npmjs.org/cookie-jar
npm http GET https://registry.npmjs.org/aws-sign
npm http GET https://registry.npmjs.org/oauth-sign
npm http GET https://registry.npmjs.org/forever-agent
npm http GET https://registry.npmjs.org/tunnel-agent
npm http GET https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/qs
npm http 304 https://registry.npmjs.org/form-data
npm http 304 https://registry.npmjs.org/hawk
npm http 304 https://registry.npmjs.org/node-uuid
npm http 304 https://registry.npmjs.org/cookie-jar
npm http 304 https://registry.npmjs.org/tunnel-agent
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/json-stringify-safe
npm http 304 https://registry.npmjs.org/forever-agent
npm http 304 https://registry.npmjs.org/oauth-sign
npm http 304 https://registry.npmjs.org/aws-sign
npm http 304 https://registry.npmjs.org/qs
npm WARN engine hawk@0.10.2: wanted: {"node":"0.8.x"} (current: {"node":"v0.11.12","npm":"1.4.3"})
npm http GET https://registry.npmjs.org/combined-stream
npm http GET https://registry.npmjs.org/hoek
npm http GET https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/cryptiles
npm http GET https://registry.npmjs.org/sntp
npm http 304 https://registry.npmjs.org/boom
npm http 304 https://registry.npmjs.org/combined-stream
npm http 304 https://registry.npmjs.org/sntp
npm http 304 https://registry.npmjs.org/cryptiles
npm http 304 https://registry.npmjs.org/hoek
npm WARN engine boom@0.3.8: wanted: {"node":"0.8.x"} (current: {"node":"v0.11.12","npm":"1.4.3"})
npm WARN engine sntp@0.1.4: wanted: {"node":"0.8.x"} (current: {"node":"v0.11.12","npm":"1.4.3"})
npm WARN engine cryptiles@0.1.3: wanted: {"node":"0.8.x"} (current: {"node":"v0.11.12","npm":"1.4.3"})
npm WARN engine hoek@0.7.6: wanted: {"node":"0.8.x"} (current: {"node":"v0.11.12","npm":"1.4.3"})
npm http GET https://registry.npmjs.org/foreach
npm http GET https://registry.npmjs.org/commander/1.2.0
npm http GET https://registry.npmjs.org/delayed-stream/0.0.5

> protagonist@0.8.0 install /data/jenkins/tools/nodejs/lib/node_modules/dredd/node_modules/protagonist
> node-gyp rebuild

make: Entering directory `/data/jenkins/tools/nodejs/lib/node_modules/dredd/node_modules/protagonist/build'
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/HTTP.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/MarkdownBlock.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/MarkdownParser.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/Parser.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/ParserCore.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/Serialize.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/SerializeJSON.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/SerializeYAML.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/snowcrash.o
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/posix/RegexMatch.o
  AR(target) Release/obj.target/snowcrash/snowcrash.a
  COPY Release/snowcrash.a
  CC(target) Release/obj.target/sundown/snowcrash/sundown/src/autolink.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/src/buffer.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/html/houdini_href_e.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/html/houdini_html_e.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/html/html.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/html/html_smartypants.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/src/markdown.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/src/stack.o
  CC(target) Release/obj.target/sundown/snowcrash/sundown/src/src_map.o
  AR(target) Release/obj.target/snowcrash/sundown.a
  COPY Release/sundown.a
  CXX(target) Release/obj.target/protagonist/src/annotation.o
In file included from ../src/annotation.cc:1:0:
../src/protagonist.h:12:47: error: expected class-name before '{' token
../src/protagonist.h:27:48: error: 'Arguments' in namespace 'v8' does not name a type
../src/protagonist.h:27:63: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
../src/protagonist.h:34:54: error: expected class-name before '{' token
../src/protagonist.h:46:48: error: 'Arguments' in namespace 'v8' does not name a type
../src/protagonist.h:46:63: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
../src/protagonist.h:53:44: error: expected class-name before '{' token
../src/protagonist.h:67:48: error: 'Arguments' in namespace 'v8' does not name a type
../src/protagonist.h:67:63: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
../src/protagonist.h:74:46: error: 'Arguments' in namespace 'v8' does not name a type
../src/protagonist.h:74:61: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h: In static member function 'static void protagonist::SourceAnnotation::Init(v8::Handle<v8::Object>)':
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:768:13: error: 'v8::HandleScope::HandleScope()' is private
../src/annotation.cc:19:17: error: within this context
../src/annotation.cc:21:58: error: invalid conversion from 'v8::Handle<v8::Value> (*)(const int&)' to 'v8::FunctionCallback {aka void (*)(const v8::FunctionCallbackInfo<v8::Value>&)}' [-fpermissive]
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:3346:34: error:   initialising argument 1 of 'static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)' [-fpermissive]
../src/annotation.cc:25:61: error: no matching function for call to 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >::New(v8::Local<v8::Function>)'
../src/annotation.cc:25:61: note: candidate is:
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:5591:4: note: static T* v8::Persistent<T, M>::New(v8::Isolate*, T*) [with T = v8::Function, M = v8::NonCopyablePersistentTraits<v8::Function>]
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:5591:4: note:   candidate expects 2 arguments, 1 provided
../src/annotation.cc:26:68: error: no matching function for call to 'v8::Object::Set(v8::Local<v8::String>, v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >&)'
../src/annotation.cc:26:68: note: candidates are:
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:2057:8: note: bool v8::Object::Set(v8::Handle<v8::Value>, v8::Handle<v8::Value>, v8::PropertyAttribute)
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:2057:8: note:   no known conversion for argument 2 from 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >' to 'v8::Handle<v8::Value>'
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:2061:8: note: bool v8::Object::Set(uint32_t, v8::Handle<v8::Value>)
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:2061:8: note:   no known conversion for argument 1 from 'v8::Local<v8::String>' to 'uint32_t {aka unsigned int}'
../src/annotation.cc: At global scope:
../src/annotation.cc:29:43: error: 'Arguments' does not name a type
../src/annotation.cc:29:54: error: ISO C++ forbids declaration of 'args' with no type [-fpermissive]
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h: In static member function 'static v8::Handle<v8::Value> protagonist::SourceAnnotation::New(const int&)':
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:768:13: error: 'v8::HandleScope::HandleScope()' is private
../src/annotation.cc:31:17: error: within this context
../src/annotation.cc:33:17: error: 'class protagonist::SourceAnnotation' has no member named 'Wrap'
../src/annotation.cc:33:27: error: request for member 'This' in 'args', which is of non-class type 'const int'
../src/annotation.cc:34:29: error: request for member 'This' in 'args', which is of non-class type 'const int'
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h: In static member function 'static v8::Handle<v8::Value> protagonist::SourceAnnotation::NewInstance()':
/home/jboss/.node-gyp/0.11.12/deps/v8/include/v8.h:768:13: error: 'v8::HandleScope::HandleScope()' is private
../src/annotation.cc:39:17: error: within this context
../src/annotation.cc:40:41: error: base operand of '->' has non-pointer type 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >'
../src/annotation.cc: In static member function 'static v8::Local<v8::Object> protagonist::SourceAnnotation::WrapSourceAnnotation(const snowcrash::SourceAnnotation&)':
../src/annotation.cc:55:47: error: base operand of '->' has non-pointer type 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >'
../src/annotation.cc: In static member function 'static v8::Handle<v8::Value> protagonist::SourceAnnotation::New(const int&)':
../src/annotation.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [Release/obj.target/protagonist/src/annotation.o] Error 1
make: Leaving directory `/data/jenkins/tools/nodejs/lib/node_modules/dredd/node_modules/protagonist/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/data/jenkins/tools/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:107:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1045:12)
gyp ERR! System Linux 3.5.0-47-generic
gyp ERR! command "node" "/data/jenkins/tools/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /data/jenkins/tools/nodejs/lib/node_modules/dredd/node_modules/protagonist
gyp ERR! node -v v0.11.12
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm http 304 https://registry.npmjs.org/foreach
npm http 304 https://registry.npmjs.org/commander/1.2.0
npm http GET https://registry.npmjs.org/keypress
npm http 304 https://registry.npmjs.org/delayed-stream/0.0.5
npm http 304 https://registry.npmjs.org/keypress
npm ERR! protagonist@0.8.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the protagonist@0.8.0 install script.
npm ERR! This is most likely a problem with the protagonist package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls protagonist
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.5.0-47-generic
npm ERR! command "/data/jenkins/tools/nodejs/bin/node" "/data/jenkins/tools/nodejs/bin/npm" "install" "-g" "dredd"
npm ERR! cwd /home/jboss/apache-tomcat-7.0.37/apache-tomcat-7.0.37/bin
npm ERR! node -v v0.11.12
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/jboss/apache-tomcat-7.0.37/apache-tomcat-7.0.37/bin/npm-debug.log
npm ERR! not ok code 0
[workspace] $ /bin/sh -xe /home/jboss/tomcat/temp/hudson2769499651973706313.sh
+ echo /usr/lib/jvm/java-1.7.0-openjdk-i386/bin:/data/jenkins/tools/nodejs/bin:/usr/lib/jvm/java-1.7.0-openjdk-i386/bin:/home/jboss/glassfish/glassfish3/bin:/home/jboss/apache-maven-3.0.4/bin:/home/jboss/sonar-runner-2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
/usr/lib/jvm/java-1.7.0-openjdk-i386/bin:/data/jenkins/tools/nodejs/bin:/usr/lib/jvm/java-1.7.0-openjdk-i386/bin:/home/jboss/glassfish/glassfish3/bin:/home/jboss/apache-maven-3.0.4/bin:/home/jboss/sonar-runner-2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ node --version
v0.11.12
+ dredd --version
/home/jboss/tomcat/temp/hudson2769499651973706313.sh: 4: /home/jboss/tomcat/temp/hudson2769499651973706313.sh: dredd: not found
Build step 'Execute shell' marked build as failure
Sending e-mails to: xx
Finished: FAILURE

gcc -v output:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

A: Looks like there is an API change in node.js v0.11.x. I can reproduce this on Ubuntu Precise / GCC4.6 with node v0.11.12.
Node v0.10.21 seems to work fine. Can you confirm?
Note I have created an issue which you can track at https://github.com/apiaryio/protagonist/issues/16


text:
Q: Bootstrap button group - overriding active/focus states I'm using a Bootstrap button group and having an issue overriding some CSS states. I believe the state is :active:focus that is adding a dark blue background to the button while it is in the act of being clicked, which I've tried overriding with no success.
I've provided a Fiddle replicating the issue I'm experiencing.
Attempting to override this style with:
.btn-group label.btn-primary:active:focus {
    background-color: #ffffff;
}

Any suggestions?

A: You cant chain those states together like that:
do them separately:
.btn-group label.btn-primary:active {
    background-color: #ffffff;
}

.btn-group label.btn-focus{
    background-color: #ffffff;
}

(btw i think you might want transparent and not #ffffff
https://jsfiddle.net/jer8k6ex/4/

redpajama_set_name: RedPajamaStackExchange


text:
Q: Modify CSS parameters of Breadcrumb leaf with ngClass in Angular I am developing a Breadcrumb component in Angular which will show the complete address about the routing. Helping the user to go back to any step it was before. To get the actual url I am using ActivatedRoute. It works fine.
My question is about set different class to the last element using this example style of Breadcrumb. (Bootstrap 4) Which shows different style on the last element of the routing. (Data using active and aria-current="page")

Home

Library

Data

To get the last element of the list and set different CSS class I am using this example:

{{item.path}}

But I can not achieve the objective of enable class="active" and aria-current="page" using the css file which looks like:
.last{
  // I do not know how to enable from here active and arria-current
}

A: Finally I achieved. It is not necessary to use active class.
Using pointer-event you can disable the option to click the link using CSS class.

HTML

{{item.path}}

CSS

.last a{
    color: grey;
    pointer-events: none;
}


text:
Q: Java sum of 2 arrays In my app I have 2 arrays
Integer[] array1= {1, 2, 3, 8, 6, 4, 10};
Integer[] array2= {200, 100, 50, 20, 10, 5, 1};

Now I want to multiply every element from the first array with every element from the second array and finally to sum, for example:
200x1 = 200; 100x2 = 200; 50x3 = 150; 20x8 = 160; 10x6 = 60; 5x4 = 20; 1x10 = 10;

and then to sum 200+200+150+160+60+20+10 = 800

A: You can even use streams:
Integer[] array1 = {1, 2, 3, 8, 6, 4, 10};
Integer[] array2 = {200, 100, 50, 20, 10, 5, 1};

public void test() {
    System.out.println(
            // Each index of the arrays.
            IntStream.range(0, Math.min(array1.length, array2.length))
            // Multiply the two array entries.
            .mapToLong(n -> array1[n] * array2[n])
            // Add them up.
            .sum());
}

A: Integer[] array1= {1, 2, 3, 8, 6, 4, 10};
Integer[] array2= {200, 100, 50, 20, 10, 5, 1};
int resultOfSum = 0;

for (int i = 0; i < array1.length;i++){
    resultOfSum += array1[i]*array2[i];
}

Hope this helps :)

A: use this
int total = 0;
for(int i = 0; i < array1.length; i++){
total += array2[i] * array1[i];
}

A: Here, try this :
int s=0;
for(int i=0;i<array1.length;i++)
  s+=array1[i]*array2[i];
System.out.println(s);


text:
Q: nsis script fails to build in electron-builder I need to make some installation steps only if for certain versions of windows - say only if not 10. The script is used in the context of electron builder (19.55.1)
How do I change my nsh script to achieve this? The code that was picked from  nsis wiki to get the version is not helping. Need help in identifying what is wrong with the below piece of script.
Better still, is there a simpler/more readable way of doing this? Looks like winver.nsh is not upto it when it comes to windows 10 (at least the nsis documentation does not claim it)
Below is my current script that simply fails to compile in electron builder.
!include LogicLib.nsh
!include x64.nsh

Function GetWindowsVersion

Push $R0
Push $R1

; check if Windows 10 family (CurrentMajorVersionNumber is new introduced in Windows 10)
ReadRegStr $R0 HKLM \
  "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentMajorVersionNumber

StrCmp $R0 '' 0 lbl_winnt

ClearErrors

; check if Windows NT family
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion

IfErrors 0 lbl_winnt

; we are not NT
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber

StrCpy $R1 $R0 1
StrCmp $R1 '4' 0 lbl_error

StrCpy $R1 $R0 3

StrCmp $R1 '4.0' lbl_win32_95
StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98

lbl_win32_95:
  StrCpy $R0 '95'
Goto lbl_done

lbl_win32_98:
  StrCpy $R0 '98'
Goto lbl_done

lbl_win32_ME:
  StrCpy $R0 'ME'
Goto lbl_done

lbl_winnt:

StrCpy $R1 $R0 1

StrCmp $R1 '3' lbl_winnt_x
StrCmp $R1 '4' lbl_winnt_x

StrCpy $R1 $R0 3

StrCmp $R1 '5.0' lbl_winnt_2000
StrCmp $R1 '5.1' lbl_winnt_XP
StrCmp $R1 '5.2' lbl_winnt_2003
StrCmp $R1 '6.0' lbl_winnt_vista
StrCmp $R1 '6.1' lbl_winnt_7
StrCmp $R1 '6.2' lbl_winnt_8
StrCmp $R1 '6.3' lbl_winnt_81
;StrCmp $R1 '10' lbl_winnt_10_2016

StrCpy $R1 $R0 4

StrCmp $R1 '10.0' lbl_winnt_10
Goto lbl_error

lbl_winnt_x:
  StrCpy $R0 "NT $R0" 6
Goto lbl_done

lbl_winnt_2000:
  Strcpy $R0 '2000'
Goto lbl_done

lbl_winnt_XP:
  Strcpy $R0 'XP'
Goto lbl_done

lbl_winnt_2003:
  Strcpy $R0 '2003'
Goto lbl_done

lbl_winnt_vista:
  Strcpy $R0 'Vista'
Goto lbl_done

lbl_winnt_7:
  Strcpy $R0 '7'
Goto lbl_done

lbl_winnt_8:
  Strcpy $R0 '8'
Goto lbl_done

lbl_winnt_81:
  Strcpy $R0 '8.1'
Goto lbl_done

lbl_winnt_10:
  Strcpy $R0 '10.0'
Goto lbl_done

lbl_error:
  Strcpy $R0 ''
lbl_done:

Pop $R1
Exch $R0
FunctionEnd

!macro customInstall
${GetWindowsVersion} $R0
${IfNot} $R0 == 10
${If} ${RunningX64}
; Do something
${Else}
; Do something
${EndIf}
${EndIf}
!macroend

A: I'm assuming you commented out the ;StrCmp $R1 '10' lbl_winnt_10_2016 line? Try adding the line back but change lbl_winnt_10_2016 to lbl_winnt_10.
To debug things you can add a MessageBox mb_ok "R0=$R0,R1=$R1" call in various places in that code and look at the values after StrCpy and see if they make sense when they are compared in StrCmp.
WinVer.nsh got Windows 10 support in NSIS v3.0b2 (2015).


text:
Q: Passing values by pointer 29: error: expected declaration specifiers or '...' before '*' token
29: error: conflicting types for 'kill'
/usr/include/signal.h:126: note: previous declaration of 'kill' was here

In function 'kill':
32: error: too many arguments to function 'kill'
36: error: too many arguments to function 'kill'

I am new to C, and having difficulties passing values from my main function to the kill functions below. This code is intended to be ran in a linux environment. The purpose is to open a pid file, grab the pid number, and pass the pid number to the kill functions to be tested if still valid. The code "was" running, but the value was not being passed to kill and was only successfully when an invalid argument (bad pid file name) was passed to the if statement. I attempted to use a pointer to pass the value, but cant seem to get it working. Any advice is appreciated.
tl;dr?
I cannot pass a value by pointer to a function.
#include <stdio.h>    //Needed for standard I/O
#include <stdlib.h>   //Needed for exit
#include <signal.h>   //Needed for kill function

int main(int argc, char *argv[])
{
    FILE *pf;
    char pidvar;
    char *pidnum;

    pidnum = &pidvar;

    pf = fopen(argv[1], "r");

    if (pf == NULL){
        printf("Pid file doesn't exist\n");
        return 2;
    }
    else {
        do  {*pidnum = getc(pf);         /* get one character from the file */
            }while (*pidnum != EOF);     /* repeat until EOF (end of file) */
            fclose(pf);                 /* Close pidfile */
         }
}

    char *pidnum;

pid_t kill(*pidnum, int sig)         /* function declaration */
{

    if ((kill (*pidnum, 0)) == -1){
         printf("The pid %s is no longer valid", *pidnum);
         return 2;
    }
    else if ((kill (*pidnum, 0)) == 0){
         printf("The pid %s is valid", *pidnum);
         return 0;
    }
}                                                                1,1           Top

A:
note: previous declaration of 'kill' was here

This is the compiler telling you that the function you wrote called "kill" is identically named with the function the system provides.  Note that your function calls kill also, and if there were no compiler error (if the system function had a different name) your function would just recurse on itself.
Give your function a new name.


text:
Q: Is there any way to declaratively pass code-behind property values to server controls? Can anyone explain why you can't use inline code blocks within server control declarations in ASP.Net?
The following is a simple example...
....
<form id="form1" runat="server">
    <asp:Label ID="Label1" runat="server" Text="<%= SomeProperty %>"></asp:Label>
</form>
....

The code block is rendered literally to the page...
<%= SomeProperty %>

My initial thoughts are it has to do with the order that these things are processed in the page life-cycle. The <%=...%> blocks are, as I understand it, equivalent to a Response.Write(...) in code-behind. And since the server control is not actually rendered as declared in the markup, I suppose it may not be possible to process an embedded code block before this rendering takes place.
I would be very grateful of anyone could explain that a little better.
However, the data binding code block <%#...%> is obviously different in the way it behaves, but can anyone tell me why it is possible to embed these within a server control...
....
<asp:Repeater id=Repeater1 runat="server">
    ....
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("SomeProperty") %>'></asp:Label>
    </ItemTemplate>
    ....
</asp:Repeater>
....

This works fine.

A: You're mostly right about the <%=...%> syntax.
Here is an example of what happens under the hood:

<form id="form1" runat="server">
    <%= SomeProperty %>

        <asp:Label ID="Label1" runat="server" Text="<%= SomeProperty %>"></asp:Label>

</form>

This is parsed and the following C# code is created (I've simplified it a bit):
private Label @__BuildControlLabel1()
{
    Label @__ctrl = new Label();

    this.Label1 = @__ctrl;
    @__ctrl.ApplyStyleSheetSkin(this);
    @__ctrl.ID = "Label1";
    @__ctrl.Text = "<%= SomeProperty %>";
    return @__ctrl;
}

private void @__Renderform1(HtmlTextWriter @__w, Control parameterContainer)
{
    @__w.Write( SomeProperty );
    @__w.Write("\r\n
\r\n        ");
    parameterContainer.Controls[0].RenderControl(@__w);
    @__w.Write("\r\n
\r\n    ");
}

Here is an example of what happens under the hood for the <%#...%> syntax:

<form id="form1" runat="server">

        <asp:Label ID="Label1" runat="server" Text="<%# SomeProperty %>"></asp:Label>

</form>

Generates this code:
private Label @__BuildControlLabel1()
{
    Label @__ctrl = new Label();

    this.Label1 = @__ctrl;
    @__ctrl.ApplyStyleSheetSkin(this);
    @__ctrl.ID = "Label1";
    @__ctrl.DataBinding += new System.EventHandler(this.@__DataBindingLabel1);
    return @__ctrl;
}

public void @__DataBindingLabel1(object sender, EventArgs e)
{
    Label dataBindingExpressionBuilderTarget = ((Label)(sender));
    Page Container = ((Page)(dataBindingExpressionBuilderTarget.BindingContainer));

    dataBindingExpressionBuilderTarget.Text = System.Convert.ToString( SomeProperty , System.Globalization.CultureInfo.CurrentCulture);
}

As you can see the <%=...%> syntax can be used outside of a server control's properties to directly render the returned value.  On the other hand the <%#...%> syntax generates a event handler for the DataBinding event of the label.  This event sets the value of the label's property to the value of SomeProperty.  The DataBinding event fires whenever the DataBind method is called which is why I added that call to the Page_Load event.
Hopefully this will help you understand the difference between them.

A: You could create a custom ExpressionBuilder so you use something like <%$ Code: SomeProperty  %>

A: You can create a custom databound control, e.g.
namespace FooBar.WebControls
{
    public class DataBoundPlaceHolder:PlaceHolder
    {
        private bool hasDataBound = false;
        protected override void CreateChildControls()
        {
            if (!hasDataBound)
            {
                this.DataBind();
                hasDataBound = true;
            }
            base.CreateChildControls();
        }
    }
}

Then wrap your code in this new control, and use the <%# %> syntax, e.g.
<%@ Register TagPrefix="WebControls" Namespace="FooBar.WebControls" Assembly="FooBar" %>

<form id="form1" runat="server">
    <WebControls:DataBoundPlaceHolder runat="server">
        <asp:Label ID="Label1" runat="server" Text='<%# SomeProperty %>'></asp:Label>
    </WebControls:DataBoundPlaceHolder>
</form>


text:
Q: What is a proper way to align content using Bootstrap Grid? So there is a question that's been worrying me a considerable period of time. It would sound like, "What is a correct way to align content inside Bootstrap column?"
When I'm using Bootstrap Grid I normally divide the screen width into col-md-* blocks that form columns and which don't result in conflicts when resizing the window. But I'm not exactly certain about how to align what's inside these blocks.
The main bootstrap documentation page only mentions about how to float elements to the right or to the left using

..

or

...

classes. However, what would I need to do in case when I want to align elements to the bottom right corner? What is the most common way to do it following bootstrap markup?

A: Inside a col-md-* div, you can either create a new row with other col-md-* div in it, or you can just use some helper class:

content

Or

content

But if want to fix your content in the bottom of a container, you should set the container's position as "relative" and the content's position to "absolute", and then "bottom:0"
This should work :

            content

A: you mean inside in your column just use align:(directions), but with inner container suppose

some text

for using float use pull-right and pull-left

A: you can simply use the

some text

for more detail you can refer
Refer


text:
Q: How much needs to be changed in an iphone app to make in ipad compatible? What needs to be changed to make an iphone app compatible on the ipad?
I know the icons etc must be different etc. but in terms of code?

A: What needs to be changed to make an iphone app compatible on the ipad?
You need to provide iPad sized views.
Code level changes greatly depend on the app and how you want to design the iPad app.  In the simplest case you would need to simply provide some new xib files for iPad specific views.  Barring that you would have the same controllers with different xib files, plus some branching code in your controllers to manage some iPad specific features and layouts.  Or you may decide you need more types of differences and need to write new controllers as well.
But from the point of view of the developer, the iPad is simply a giant iPhone.  Providing views to match the larger screen is the technical issue, and that is easy.  But from a usability standpoint your app might end up much different since designing interfaces for a 3.5 inch screen is much different than for a 10 inch screen.
So if you new UI for iPad is a direct one to one mapping to an iPhone app then this is easy and you simply load an iPad xib for all your existing controllers.  If you design to take advantage of the larger screen in ways that diverge from the iPhone app, then code level changes will be required to handle the differences between the 2 UI's.

A: I would suggest reading the iPad Programming Guide over at the developer site.

A: Just adjust the layout in interface builder, then copy the code from the iPhone project, paste it into your iPad project, and connect the actions and outlets in interface builder.


text:
Q: TailwindCSS nesting not working with postCSS config I am trying to scope tailwind styles and I am using this postcss config from Tailwind docs:
module.exports = {
plugins: {
  'postcss-import': {},
  'tailwindcss/nesting': {},
  tailwindcss: {},
  autoprefixer: {},
 }
}

and here is my css
.app-wrapper {
  @tailwind base;
  @tailwind components;
  @tailwind utilities;

 }

with this config the nesting is working fine but not all the tailwindCSS classes working as expected.
but when I change the config to the following
 module.exports = {
 plugins: [
     require('postcss-import'),
     require('tailwindcss/nesting'),
     require('tailwindcss'),
    require('autoprefixer'),
 ]
};

the classes works fine but the nesting throw the following error

Nested @tailwind rules were detected, but are not supported.

any idea how I can get the tailwind to work as expected with the nesting enabled?

A: If you wish to add parent selector for every compiled utility, add important: '.app-wrapper', into your tailwind config and do not wrap @tailwind directives
// postcss.config.js

module.exports = {
  plugins: {
    'postcss-import': {},
    'tailwindcss/nesting': {},
    tailwindcss: {},
    autoprefixer: {},
  }
}

@tailwind base;
@tailwind components;
@tailwind utilities;

// tailwind.config.js

module.exports = {
    important: '.app-wrapper',
    // ...
};

This called selector strategy. This way text-red-500 utility will be compiled as
.app-wrapper .text-red-500 {
    --tw-text-opacity: 1;
    color: rgb(239 68 68 / var(--tw-text-opacity));
}

Please note: if you set darkMode as class strategy in your config
module.exports = {
    darkMode: 'class',
    important: '.app-wrapper',
    // ...
};

utility dark:text-white (and every other dark utility) will be compiled as
.app-wrapper .dark .dark\:text-white {
    --tw-text-opacity: 1;
    color: rgb(255 255 255 / var(--tw-text-opacity));
}

So if both dark and app-wrapper classes will be placed on the SAME element (e.g. html or body) dark mode would not work. That may explain why some classes are not working when using nesting


text:
Q: compare 2 dates in a slick query seems hard helllo
I can't adapt this example of code : https://github.com/pedrofurla/slick-demo/blob/master/src/main/scala/slickdemo/domain/Person.scala.
it deals with the capacity of comparing dates in a slick query. The difficulty is you can't access to the date field(to extract for example the year, the month and the day) because the query uses Column types.
I searched and found the example above, but I can't adapt it.
here is my code:
the Table:
class Personnes( tag : Tag ) extends Table[ Rdv ]( tag, "RDV" ) {

     def id = column[ Int ]( "ID", O.PrimaryKey, O.AutoInc )
     def nom = column[ String ]( "NOM", O.NotNull )
     def prénom = column[ String ]( "PRENOM" )
     def sexe = column[ Int ]( "SEXE" )
     def télPortable = column[ String ]( "TELPOR" )
     def télBureau = column[ String ]( "TELBUR" )
     def télPrivé = column[ String ]( "TELPRI" )
     def siteRDV = column[ String ]( "SITE" )
     def typeRDV = column[ String ]( "TYPE" )
     def libelléRDV = column[ String ]( "LIBELLE" )
     def numRDV = column[ String ]( "NUMRDV" )
     def étape = column[ String ]( "ETAPE" )
     def dateRDV = column[ java.sql.Date ]( "DATE" )
     def heureRDVString = column[ String ]( "HEURE" )
     def statut = column[ String ]( "STATUT" )
     def orderId = column[ String ]( "ORDERID" )

     def * = ( id.?, nom, prénom, sexe, télPortable, télBureau, télPrivé,
        siteRDV, typeRDV, libelléRDV, numRDV, étape, dateRDV, heureRDVString,
        statut, orderId ) <> ( Rdv.tupled, Rdv.unapply _ )

  }

and the method:
def sqlite_findBetween( début : java.util.Date, fin : java.util.Date ) : List[ Rdv ]=  db_sqlite.withSession { implicit db : Session =>

   def débutTime:org.joda.time.DateTime = new DateTime(début)
   def finTime=new DateTime(fin)

     val query = for {
        p <- personnes
        if  (p.dateRDV > débutTime && finTime < p.dateRDV)
     } yield p
     query.list

  }

thanks!
ps : I forgot the error : near the date comparison, I get :
Cannot perform option-mapped operation with type: (java.sql.Date, org.joda.time.DateTime) => R for base type: (java.sql.Date, java.sql.Date) => Boolean

ps2 : here is the utility file : I have obviously added it in the classpath : https://github.com/pedrofurla/slick-demo/blob/master/src/main/scala/slickdemo/dal/JodaTimeSupport.scala, with this :
import models.JodaTimeSupport

package models {

    trait sqlite extends JodaTimeSupport {...

A: Aside from creating your own implicit MappedColumnType from java.sql.Date to org.joda.time.DateTime, you can try the popular slick-joda-mapper found here on Github.


text:
Q: Michael Hartl Rails Tutorial - CSS not rendering properly I already finished the tutorial but I'm having a slight issue with the CSS rendering since section 7 where you make the signup form. This is what I'm getting:

And this is what it's supposed to look like:

And this is the relevant CSS:
@mixin box_sizing {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

input, textarea, select, .uneditable-input {
  border: 1px solid #bbb;
  width: 100%;
  padding: 10px;
  height: auto;
  margin-bottom: 15px;
  @include box_sizing;
}

Was wondering if anyone else had the same issue?

A: The difference is probably with the default height of an input in Chrome vs FireFox (Hartl's browser).
The CSS declaration height:auto; lets the browser calculate the default height.

A: I had the same issue with Chrome, and although I don't know if it's a good solution, I got the expected results by getting rid of the @include box_sizing; comment:
input, textarea, select, .uneditable-input {
  border: 1px solid #bbb;
  width: 100%;
  padding: 10px;
  height: auto;
  margin-bottom: 15px;
  // @include box_sizing;
}

A: Based upon the Handy Sass Mixins by Jake Bresnehan at http://web-design-weekly.com/blog/2013/05/12/handy-sass-mixins and the section on Box Sizing, I was able to change the mixin block and the "include" line and get things working with the following situations:
@mixin box_sizing {
  -moz-box-sizing: $box-model;
  -webkit-box-sizing: $box-model;
  box-sizing: $box-model;
}

.debug_dump {
  clear: both;
  float: left;
  width: 100%;
  margin-top: 45px;
  @include box_sizing(border-box);
}

input, textarea, select, .uneditable-input {
  border: 1px solid #bbb;
  width: 100%;
  margin-bottom: 15px;
  @include box_sizing(border-box);
}

input {
  height: auto !important;
}

which is also referencing the Michael Hartl, Ruby on Rails Tutorial, Ch. 7 at http://ruby.railstutorial.org/chapters/sign-up#top


text:
Q: Fontspec cannot find OpenType features And I'm back with more fontspec trouble. Recently, I asked a question about how to access a particular character variant using fontspec (here). Ulrike Fischer's solution — to put a newer version of the font in my local texmf tree then call mktexlsr and luaotfload-tool -u -f — worked wonderfully for a time, and then broke later the same day.  Now I am unable to load any OpenType features, not even small caps. Here's a minimal example:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Junicode}

\addfontfeatures{
    Script={Latin},
    Numbers={OldStyleOff, Proportional},
}

\begin{document}
    1. a/b \addfontfeatures{StylisticSet={10},Numbers={Lowercase,Proportional}}
    2. a/b
    3. \textsc{a/b}
\end{document}

When I ask for the same features with another software (I think MS Word generates its own small caps, so I'm using Publisher), everything is fine:

Similar problems persist even with system fonts e.g. Cambria or Candara.
I don't know whether it's useful information or not, but just in case, the log file flags up the following warnings,
luaotfload | cache : Lookup cache loaded from C:/Users/MyName/AppData/Local/
MiKTeX/2.9/luatex-cache/generic/names/luaotfload-lookup-cache.luc.
luaotfload | aux : no font with id -1
luaotfload | aux : no font with id -1
luaotfload | aux : no font with id -1
luaotfload | aux : no font with id -1

Package fontspec Info: Font family 'Junicode(0)' created for font 'Junicode'
(fontspec)             with options [Ligatures=TeX].
(fontspec)
(fontspec)              This font family consists of the following NFSS
(fontspec)             series/shapes:
(fontspec)
(fontspec)             - 'normal' (m/n) with NFSS spec.:
(fontspec)             <->"Junicode:mode=node;script=latn;language=DFLT;+tlig;"
(fontspec)             - 'small caps'  (m/sc) with NFSS spec.:
(fontspec)             - 'bold' (bx/n) with NFSS spec.:
(fontspec)             <->"Junicode/B:mode=node;script=latn;language=DFLT;+tlig;
"
(fontspec)             - 'bold small caps'  (bx/sc) with NFSS spec.:
(fontspec)             - 'italic' (m/it) with NFSS spec.:
(fontspec)             <->"Junicode/I:mode=node;script=latn;language=DFLT;+tlig;
"
(fontspec)             - 'italic small caps'  (m/itsc) with NFSS spec.:
(fontspec)             - 'bold italic' (bx/it) with NFSS spec.:
(fontspec)             <->"Junicode/BI:mode=node;script=latn;language=DFLT;+tlig
;"
(fontspec)             - 'bold italic small caps'  (bx/itsc) with NFSS spec.:

LaTeX Info: Redefining \rmfamily on input line 37.
luaotfload | aux : no font with id -1

Package fontspec Warning: Font "Junicode" does not contain requested Script
(fontspec)                "Latin".

Package fontspec Warning: OpenType feature 'Numbers=LowercaseOff' (onum) not
(fontspec)                available for font 'Junicode' with script '' and
(fontspec)                language 'Default'

as well as a further number of the type below.
Package fontspec Warning: OpenType feature 'Variant=10' (ss10) not available
(fontspec)                for font 'Junicode' with script 'CustomDefault' and
(fontspec)                language 'Default'.

I'm really baffled here, especially since the problem appears to be restricted to my machine. Does anyone know what could be going on?
Edit: This is a known issue with luatex 1.10.1 in MiKTeX. See this tex.sx post and this GitHub issue.


text:
Q: Diagonalization of Block Matrices Let $n>1$ and $A_1,A_2,A_3 \in M_n(F)$. Let $A$=\begin{bmatrix}A_{1}&A_{2}\\0_{n}&A_{3}\\\end{bmatrix} Prove the following.   1.) If $A_1$ and $A_3$ are diagonalizable, then $A$ is diagonalizable.(Does the converse of this is true?)
2.) If $\lambda$ is an eigenvalue of $A_1$ and of $A_3$, then $\lambda$ is an eigenvalue of $A_1 + A_3$.
Any and all help would be appreciated, please help. Thank you.

A: Part (1) is wrong
$$
\left(
\begin{array}{rrrr}
0&1&1&0 \\
-1&0&0&1 \\
0&0&0&1 \\
0&0&-1&0
\end{array}
\right)
$$
The characteristic polynomial and the minimal polynomial are both $(x^2+1)^2$
Or, all real characteristic values:
$$
\left(
\begin{array}{rrrr}
1&0&1&0 \\
0&3&0&1 \\
0&0&1&0 \\
0&0&0&3
\end{array}
\right)
$$
The characteristic polynomial and the minimal polynomial are both $(x-1)^2 (x-3)^2$

A: Both your statements are false!

*

*Take $A_1=A_3=0_n$ and $A_2$ to be any non-zero matrix.

*Take $A_1=\begin{pmatrix} 1 & 0 \\ 0 & -1\end{pmatrix}$ and $A_3=-A_2$. Then 1 is an eigenvalue of $A_1$ and $A_3$ but $A_1+A_3=0_2$.


text:
Q: load data infile mysql- won't run I am trying to load a text file with fields separated by commas and lines by a newline. The data is out of order from my table, and i am trying to pass my column names out of order. Is this the correct way to go about this?
LOAD DATA INFILE 'project_file.txt'
    INTO TABLE COURSES
    (course_id,section_tag,course_num,section,days_taught,classroom,
     time_offered,current_teacher)
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '\n';

A: Please be sure to review the mysql manual next time before posting. Column assignment goes at the end of the query like so:
LOAD DATA INFILE 'project_file.txt'
INTO TABLE COURSES
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(course_id,section_tag,course_num,section,days_taught,classroom,
time_offered,current_teacher);


text:
Q: Augment an interface to remove the indexer In @types/node the NodeJS.ProcessEnv interface is declared with an indexer:
interface ProcessEnv {
    [key: string]: string | undefined;
}

And I'm augmenting it with my defined properties:
declare module NodeJS {
    interface ProcessEnv {
        NODE_ENV: 'development' | 'production';
    }
}

It successfully type-checks the value of process.env.NODE_ENV, but it still allows any property. If I use the wrong property name (e.g. MODE_ENB), it doesn't produce an error, because of the indexer.
Is there a way to apply module augmentation to an interface that effectively removes an indexer?

Failed Attempts:
        [key: string]: never;
        NODE_ENV: 'development' | 'production';

Error: Property 'NODE_ENV' of type '"development" | "production"' is not assignable to string index type 'never'.ts(2411)
        [key: Exclude<string, 'NODE_ENV'>]: never;
        NODE_ENV: 'development' | 'production';

Error: An index signature parameter type cannot be a type alias. Consider writing '[key: string]: never' instead.ts(1336)

A: A partial solution is to use:
        [key: string]: unknown;

Which will prevent other properties from being assigned to known types:
const env: string = process.env.NODE_ENVtypo;
// Type 'unknown' is not assignable to type 'string'. ts(2322)

But will still preserve the type of your defined properties:
const env: string = process.env.NODE_ENV;

But it won't catch when comparing values:
if (process.env.NODE_ENVZZZ === 'production') { // no error appears


text:
Q: Calling Command Line From Blue Prism I am trying to use Nitro PDF Reader from the command line.
This was working correctly, but I am now getting an error Internal : Could not execute code stage: Ambiguous match found.
Passing null values also produces this error.
Code:
timedOut = False
Dim startTime as Date = Date.Now

Dim info as New ProcessStartInfo(appn)
If args <> "" Then  info.Arguments = args
If dir <> "" Then info.WorkingDirectory = dir

Using proc As Process = Process.Start(info)
timedOut = Not proc.WaitForExit( _
 CInt(timeout.TotalMilliseconds))
End Using

A: Issue looked to be caused by another action with similar code. There was an action called Run Process until Ended. I then duplicated to have a second which was called Run Process.
This was causing the error.


text:
Q: Silent while loop in bash I am looking to create a bash script that keeps checking a file in directory and perform certain operation on it. I am using while loop, if file does not exists I want that while loop stays quite and keeps on checking condition. Here is what i created but it keeps throwing error that file not found, if file is not there.
while [ ! -f /home/master/applications/tmp/mydata.txt ]

do

cat mydata.txt;
rm mydata.txt;

sleep 1; done

A: There are two issue in your implementation:

*

*You should use the same (absolute or relative) path in your while loop test statement [ ! -f $file ] and in your cat and rm commands.

The cat command is looking for the file in the current working directory (pwd) and your while statement might be looking somewhere else and hence, your implementation is buggy and won't work as expected if your pwd isn't /home/master/applications/tmp.

*You need to move your cat command and rm command after the while block. It doesn't make sense to cat a file if a file doesn't exist. I think your misplaced those commands.

Try this:
file="/home/master/applications/tmp/mydata.txt"
while [ ! -f "$file" ]
do
sleep 1
done

cat $file
rm $file

EDIT
As per suggestion from @Ivan, you could use until instead of while as it suits more to your requirements.
file="/home/master/applications/tmp/mydata.txt"
until [ -f "$file" ]; do sleep 1; done

cat $file
rm $file

A: Making a different assumption than abhiarora, I'll guess maybe you meant for the file to reappear, and you want it shown each time.
file=/home/master/applications/tmp/mydata.txt
while :
do if [[ -f "$file" ]]
   then echo "$(<"$file")"
        rm "$file"
   fi
   sleep 1
done

This creates an infinite loop. If that's NOT what you wanted, use abhiarora's solution.


text:
Q: Ansible json_query is adding extra characters to dictionary values I am encountering a strange problem with ansible, and I'm sure its just due to my lack of experience as I am relatively new to ansible (I've only been working with it for a couple weeks)
So, in short what I am trying to do is use the command module to run AWS CLI commands to list AWS access keys for a user then delete them from that user. The reason I am using CLI instead of iam module is because I believe there to be a bug with the IAM module in regard to removing access keys. Even when I specified state update and the access keys to remove and access key state remove it still would not remove access keys, or make them inactive when i set access key state to inactive.
The first task lists access keys for a given user and registers the output:
- name: List the access keys (if any) of the user(s) we just created
  vars:
    use_key: "{{ enable_access_keys }}"
  command: "aws iam list-access-keys --user-name {{ item }}"
  with_items:
    - "{{ iam_user_name_list }}"
  when: not use_key
  register: list_key_output

^Keep in mind that iam_user_name_list only contains 1 user at the moment, which is why i access results the way I do. I know this needs to be changed in the future.
Since the stdout from list_key_output looks like this
    "stdout": "{\n    \"AccessKeyMetadata\": [\n        {\n            \"UserName\": \"other-guy\", \n            \"Status\": \"Active\", \n            \"CreateDate\": \"2017-06-29T18:45:04Z\", \n            \"AccessKeyId\": \"removed\"\n        }\n    ]\n}",

I debug msg the stdout and register that to a variable test to give it proper json format without the slashes and newlines so I can use json_query to get the key from the stdout. I am using json query because AccessKeyId is not recognized as a key for the AccessKeyMetadata dictionary for whatever reason.
- name: list keys stdout
  debug:
    msg: "{{ list_key_output.results[0].stdout }}"
  register: test

- name: test variable output
  debug:
    msg: "{{ test.msg.AccessKeyMetadata | json_query('[].AccessKeyId') }}"

At this point, I am successfully getting the access key from the stdout
ok: [127.0.0.1] => {
    "changed": false,
    "msg": [
        "correct access key here"
    ]
}

Now, I feed the access key to the delete CLI command like so
- name: Remove any access keys our new console user might have
  vars:
    use_key: "{{ enable_access_keys }}"
  command: "aws iam delete-access-key --access-key {{ test.msg.AccessKeyMetadata | json_query('[].AccessKeyId') }} --user-name other-guy"
  when: not use_key
  register: delete_key_output

This task fails due to an invalid access key being provided.
fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": ["aws", "iam", "delete-access-key", "--access-key", "[u********************]", "--user-name", "other-guy"], "delta": "0:00:00.388902", "end": "2017-06-29 18:59:13.308230", "failed": true, "rc": 255, "start": "2017-06-29 18:59:12.919328", "stderr": "\nAn error occurred (ValidationError) when calling the DeleteAccessKey operation: The specified value for accessKeyId is invalid. It must contain only alphanumeric characters.", "stderr_lines": ["", "An error occurred (ValidationError) when calling the DeleteAccessKey operation: The specified value for accessKeyId is invalid. It must contain only alphanumeric characters."], "stdout": "", "stdout_lines": []}

As you can see, when I pass the access key to the command, [u is prepended to the front of the access key and ] is appended to the back of it.
Why is this happening? How can I achieve my goal without having the 3 characters added to the access key making it invalid? I don't understand why this happens because when I debug msg the access key the same way i provide it to the command, it only shows the access key without [u in front and ] behind.
Sorry for the long post but I felt I really had to describe the situation to be able to get help here. Thanks in advance for any answers!

A: To answer your exact question:
ok: [127.0.0.1] => {
    "changed": false,
    "msg": [
        "correct access key here"
    ]
}

Note the [ and ] in the msg – this means that you print a list, that contain one element – correct access key here string.
When you try to convert list into string, you get it's Python interpretation [u'correct access key here'].
You need to get first element of a list:
{{ test.msg.AccessKeyMetadata | json_query('[].AccessKeyId') | first }}

P.S. but from my point of view, you are going in a wrong way. try to fix your issues with iam module.


text: Q: How to delete a specific item from a database when custom popup confirmation button will be cliked using react and tailwind I'm created app where user can edit and delete items. Now i want that when user will clik the delete button a popup will be shown an user can either cancel or delete by confirming. How to do this?


text:
Q: UVC Extension Unit transfert only one byte of data? I am using UVC extension Unit between Windows7 / Windows xp and Custom device.
To access the custom device I am using the following COM interface :
KSP_NODE  s;
s.Property.Set = Guid_KSPROPSETID;
s.Property.Id = PropID;
s.Property.Flags = KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY;
s.NodeId = dwExtensionNode;
hr = pIKsControl->KsProperty( (PKSPROPERTY) &s, sizeof(s), pbPropertyValue, ulSize, &ulBytesReturned);

It works fine, but at the Windows UVC side I can't transfert more than one byte instead of the complete buffer pbPropertyValue of ulSize size. Someone know why? And how to fix it?
One more question, I am trying to find how to access the UVC_GET_MIN, UVC_GET_MAX, UVC_GET_INFO, UVC_GET_DEF and UVC_GET_RES with Extension unit? With the standard property I am using pVideoProcAmp->GetRange Method. But I didn't find the equivalent for the extension unit.

A: Finally, the problem was coming from the UVC_GEN_LEN return value.
The length need to be = 0x02;
And the data back needed to be equal to the len of the ulSize..


text:
Q: Get the key of selected data in DC js I want to know if it's possible to get key or id of selected data in DC js.
I have a pie chart representing town, and I want to retrieve the id every time my chart is filtered
Here is the structure of my data:
{
    "id":101,
    "sup":20.57,
    "town":"Abercorn",
    "soilType":"Argile limoneuse",
    "renting":"Non",
    "rentCost":0.0,
    "drain":"Oui",
    "lastASOL":2015

}

A: Also, the chart.filterPrinter() function returns a function that returns a string version of the selected filters. The following code segment would return the string version of the currently selected filters for a chart.
chart.filterPrinter()(chart.filters())

As mentioned by Gordon above, you can define 'filtered' function that receives the chart as the first argument, and current filter selection/unselection as the second argument
chart.on('filtered', function(chart, filter) {
    var sel = chart.filterPrinter()(chart.filters());
    console.log('Selected Filters are: ' + sel);
});


text:
Q: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send' Basically, I want to do a report command
Here's the code:
@bot.command()
async def report(a,reason,user:discord.Member=None):
    await a.send(f'Reported {user.mention} for {reason}')
    guild = bot.get_guild(1011957350434885682)
    channel = guild.get_channel(1014549224165232761)
    mbed=discord.Embed(
        title = 'Reported'
    )
    mbed.add_field(name='User', value=user.mention)
    mbed.add_field(name='Reason', value=reason)
    await channel.send(embed=mbed)

And I got this error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'


text:
Q: C# action to an integer thank you every body i finished my prodgram with Daniel Hilgarth help
i dont know how explain what i want to ask so i will try to show you that,
i want a to be a number, lets say 5.
b to be a number , 3 for example , and M to be an action
and i want to write something like that:
if(c == 6)
{
    M = " * ";
}
if(c == 7)
{
    M = "/";
}
if( a M b == 15)
{
    lable1.Text = " Hi";
}

the program says if c = 6
M will be the multipacation action and a M b will be 5 * 3 = 15
please help me how to write it because i have no clue
let me explain my self, i want to have a command line like if(a M b N c K d == 25) { lable1.Text = "hi"; } and a b c d are numbers that changes with 'for' and M N K are strings of Mathematical operation that also change with 'for' and every time the program checks if a M b N c K d == 25...

A:     Func<int, int, int> M/* = null; ??*/;
    switch (c)
    {
        case 6:
            M = (i,j) => i*j;
            break;
        case 7:
            M = (i,j) => i/j;
            break;
    }

    int a = 5;
    int b = 3;

    if (15 == M(a,b))
                  lable1.Text = " Hi";

You need a default initialisation for the action, I'll leave that to your imagination

A: You would do it like this:
Func<int, int, int> M = null;
if(c == 6)
{
    M = (x, y) => x * y;
}
if(c == 7)
{
    M = (x, y) => x / y;
}
if(M != null && M(a, b) == 15)
{
    lable1.Text = " Hi";
}

After your update, it get's a bit more complicated:
Func<int, int, int> M = null;
Func<int, int, int> N = null;
Func<int, int, int> K = null;
if(c == 6)
{
    M = (x, y) => x * y;
}
if(c == 7)
{
    M = (x, y) => x / y;
}
// Similar initialization if N and K

if(M == null || N == null || K == null)
    return;

if(K(N(M(a, b), c), d) == 25)
{
    lable1.Text = " Hi";
}

But this is getting ridiculous...
I think it would be better to use a mathematical parser.

A: What about that?
int result;
if(c == 6)
  { result=a*b; }
else if(c == 7)
  { result = a/b}

if( result == 15) { lable1.Text = "Hi"; }

A: What about this.
var calc = 0;
if(c == 6)
{
    calc = a * c;
}
else
{
    if(c == 7)
    {
        calc = a / c;
    }
}
if( calc == 15 )
{
    lable1.Text = " Hi";
}

Hope this helps.

A: yet another way:
Dictionaty<int,Func<int,int,int>> operations = new Dictionaty<int,Func<int,int,int>>();
operations.Add(6, (x,y) => x*y);
operations.Add(7, (x,y) => x/y);
...
var result = operations[c](a,b);

you can define the dictionary in a [static] constructor for example
-edit-
after reading your edit it sounds like you're really looking for a constraint solver, a program that given a number of variables and a number of constraints, finds a solution. perhaps you should check out Z3 or SolverFoundation or another SMT solver :)

A: If you're looking for having syntax to write an infix operator like a M b that is impossible in C#.
It's not possible to define new operators known at compile time, let alone variable operators.  You'll need to look into code generation or essentially string parsing.  I think maybe Haskell or some functional languages may allow you to do create that syntax (Maybe F#?), but I'm pretty sure what you're asking is not possible in C#


text:
Q: Does changing the private member of a class through an overloaded subscript operator break encapsulation? I have always been taught that in order to in-keep with encapsulation objects should be responsible for performing calculations on their own data.
So in this case here is this breaking rules of encapsulation and considered bad practice?
#include <iostream>
using namespace std;
const int SIZE = 10;

class safearay {
private:
    int arr[SIZE];
public:
    safearay() {
        register int i;
        for (i = 0; i < SIZE; i++) {
            arr[i] = i;
        }
    }

    int &operator[](int i) {
        if (i > SIZE) {
            cout << "Index out of bounds" << endl;
            // return first element.
            return arr[0];
        }
        return arr[i];
    }
};

int main() {
    safearay A;

    cout << "Value of A[2] : " << A[2] << endl;
    cout << "Value of A[5] : " << A[5] << endl;
    cout << "Value of A[12] : " << A[12] << endl;
    A[5] = 2; // Does this break Encapsulation??
    cout << "Value of A[5] : " << A[5] << endl;
    return 0;
}

A: The goal of encapsulation is to prevent arbitrary modifications of data. The most common way of achieving this in C++ is putting the data in the private section of a class and only putting a limited set of methods that may modify that data in the public section. Each public method tells the user what may be done to the data. The implementations of those methods have the responsibility of preserving the valid state of the data.
In your class, the operator[] allows any element of the array to be modified. If the user should be allowed to do this, then it's fine. It is your decision what the user is allowed to do. You even provide a safeguard to make sure that the index the user provides is within bounds. This is a good thing. This kind of checking is similar to the std::vector::at() method.
Some methods are harder to justify:
class Foo
{
    private:
        int x;
    public:
        int& my_x() { return x; }
}

With this class, the existence of the my_x() method is exactly the same as making int x public. This almost always represents broken encapsulation. It may be necessary, sometimes. The std::shared_ptr::get() method comes to mind, which exposes the pointer the shared_ptr is guarding. Sometimes, however, the user legitimately needs this kind of access. This is why the universal answer to all engineering questions is "It depends."
The problems with your class are inadequate safeguards in the array index checking. The user is not notified when the index i is negative. Also, printing to cout is not a strong enough warning to the user. Furthermore, returning a random element of the array when the index is out of bounds is user-hostile behavior. I say random because arr[0] is not the data the user asked for. Throwing an exception would be a better action to force the user to check their own code to get the right index.

A: You are breaking encapsulation in a bad way.
By returning a reference to an array element, you have lost control over that array element forever. I call
int* p = &A [5];

and now I can forever and at any time change the value of your private variable arr[5] (and actually the other elements as well, by writing p [-5] = p [4] = 0.
If you want to expose the array, expose the array. But you tried to hide it, and you didn't.


text:
Q: U-boot Splashscreen through SPI I am trying to configure a splashscreen in u-boot on an orange pi zero plus using Armbian.
The screen is connected through spi1 using the ST7789v chip of the LCD.
I already have used systemd to display a splashscreen however I find it slow to display something. It display something only after ~12 sec. I could probably reduce that time a bit by loading the service earlier but it would never start in 5 sec.
It seems that u-boot doesn't take in charge spi as a video output. I can see LCD, HDMI, DVI, VGA,... but no SPI. Is it possible to configure the SPI as LCD? Or to send framebuffer to the SPI to display the splashscreen?

A: As @KamilCuk mentioned there is no ST7789V driver in U-Boot yet. But you could write your own.
In Linux there is a frame buffer driver drivers/staging/fbtft/fb_st7789v.c which could serve as a template.
On the U-Boot side you can use drivers/video/lg4573.c as a template for a SPI  framebuffer driver.
Additionally to the driver you will a device tree overlay describing the SPI device. See Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml of the Linux kernel.
Please, send your patches upstream.


text:
Q: Persisting JSON data (validated with yang model) I need to persist some configuration data in a database/store. JSON data can be validated with an existing Yang model. One of the requirements is to keep track of each leaf and leaf-list item and quickly rollback to a previous version. Do you think converting to XML and storing in a XML database makes sense? Or should I convert it to key-value store? Any specific database suggestion to make that process easy to marshall/unmarshall between raw data to JSON leveraging the Yang model?

A: Persistence and validation must be separated here.
Some databases (like MySQL 5.7) allows to store JSON values and validate JSON objects before insert (but without validation on Yang model, so you just have to validate it in your code before you store the data). And also, any sql-database can support version or timestamp column to help you show the versions and use the proper one.
Sometimes databases can not do all the business logic of your app, and it requires to write code.


text:
Q: i'm trying to load a text file into an array. in vb this is what i have so far
the array size is (199,2)
the file holds lines that look like this: Canada,34026478,12938494
                                          USA,3377786,5345678
Sub LoadFromFile(filename As String)

    Dim Reader As StreamReader = File.OpenText(filename)
    Dim Currentline As String
    Dim lineArray() As String

    Do While Reader.EndOfStream = False
        Currentline = Reader.ReadLine
        lineArray = Currentline.Split(","c)
    Loop

    Using sr As StreamReader = New StreamReader(filename)
        Do While sr.Peek() >= 0
            For Each c As Char In sr.ReadLine.Split
                Try
                    ValuesFromFile(y, x) = CStr(Integer.Parse(c))
                Catch ex As Exception 'i assume this is the only possible error, but we could be out of bounds due to assuming the actual size of the file/line... catch specific exceptions as necessary'
                End Try
                y += 1
            Next
            x += 1
            y = 0
        Loop
    End Using

    Reader.Close()
End Sub


text:
Q: sql server not in operation in linq to entities IEnumerable<VPN_TASK> vpnTaskQuery = from p in dbContext.VPN_TASK
                                     where !p.TASK_STATUS.contains("I_SUSPENDED" "I_TERMINATED", "Cancelled", "Rejected")
                                     select p;

I need to remove task those taskstatus contains ("I_SUSPENDED" "I_TERMINATED", "Cancelled", "Rejected")

A: You need to reverse Contains:
IEnumerable<VPN_TASK> vpnTaskQuery = from p in dbContext.VPN_TASK
                                     where !(new [] {"I_SUSPENDED" "I_TERMINATED", "Cancelled", "Rejected"}).Contains(p.TASK_STATUS)
                                     select p;

A: var status = new[] { "I_SUSPENDED" "I_TERMINATED", "Cancelled", "Rejected" };

IEnumerable vpnTaskQuery = from p in dbContext.VPN_TASK where !status.Contains(p.TASK_STATUS) select p;


text:
Q: Why am I getting a 302 redirect? I'm taking over a PHP project (devlopped by colleagues who left the company) and I'm facing a redirection problem on our validation environment.
On my Localhost there is no problem (I'm using Wamp), but on our validation environment (using IIS) I have a 302 redirect problem :

The user should be redirected to "interface_mapage.php", but he is systematically redirected to "admin_mapage.php"
I took a look at the code and especially for header location but nothing shocked me ... Any suggestion ?

A: Ok, I juste solved it.
The problem was coming from a header location :
<button type="submit" value="admin" id="bouton" name="admin" onclick=
                <?php header('Location : admin_mapage.php')?> >

Does anyone know why this code redirect to another page with IIS but not with Wamp ?


text:
Q: jenkins \ force project to run on specific slave with input parameter? If I have job that invokes series of jobs in jenkins can I give them all parameter to tie them up to a specific server?
I talk about the "Restrict where this project can be run" that currently I need to specifiy in the project level (can I give it as input parameter?)

A: Use this plugin:
https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin
You can provide a parameter to the job via either the ParameterizedTrigger or using the API and providing the node name (or label).

A: You should be a able to create a string input parameter and then use that in the "Restrict where this project can be run" box. So if your string parameter was called TAG you would put ${TAG} in the box.
You could then use the Parameterized Trigger Plugin to pass this to downstream jobs, essentially tying all of them to the same node.


text:
Q: Set default version of Python in ArcGIS to 64-bit? This is the output from Python terminal within ArcMap 10.6.1 for Windows 10:
>>> import sys, numpy, matplotlib
>>> print(sys.version, numpy.__version__, matplotlib.__version__)
('2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]', '1.9.3', '1.5.2')

How can I set the default Python version to 64-bit? I don't want to change the System Environment Variables as it would probably mess up with the other Python 3.6 from Anaconda3 64-bit installed on the same PC.
Here is my Python27 folder structure


text:
Q: jdbc.SQLServerException: The "variant" data type is not supported I use pyspark 2.4.4 when I am getting the data from SQL Server I get com.microsoft.sqlserver.jdbc.SQLServerException: The "variant" data type is not supported.
What is needed to do? to fix this problem. I read this. But, I do not understand.
EDIT:
The following is the code I use to create the error message:
for i in df['name']: mssql_df = spark.read.format("jdbc") \
.option("url", "jdbc:sqlserver://SERVERNAME:1433;databaseName=DB;integratedSecurity=true") \
.option("dbtable", "[" + i + "]") \
.option("driver", 'com.microsoft.sqlserver.jdbc.SQLServerDriver').load()

A: This answer comes a bit late but might be of help to future searches for solution of that error.
I simply upgraded my connector from version 6.1.0.jre8 to 8.1.0.jre8-preview and the error was resolved.
You can check for latest version in Maven Repository.

A: https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
mssql-jdbc from version 6.3.x up to current all support "variant" data type. You just update dependency to resolve your problem.


text:
Q: Specify the order of a multiindex in python pandas I have a panda's data frame with a multiindex (that will be eventually written to a formatted Excel file), similar to the following:
first  second
one    bar      -0.292975
       baz      -0.176312
       foo      -0.458917
       qux       0.966987
two    bar       1.615486
       baz       0.875479
       foo      -3.092365
       qux      -2.348825

I would like to specify the order of the second index (note baz is always at the bottom), like so:
first  second
one    bar      -0.292975
       foo      -0.458917
       qux       0.966987
       baz      -0.176312
two    bar       1.615486
       foo      -3.092365
       qux      -2.348825
       baz       0.875479

I tried to slice the data frame like this, but it does not change the output:
myDF.loc[(slice(None),['bar','foo', 'qux', 'baz']),:]
I tried to change the index itself
myDF.index.levels[1] = pd.Index(['bar','foo', 'qux', 'baz'])
but error out with:

TypeError: 'FrozenList' does not support mutable operations.

Any suggestions are appreciated.

A: You can reindex your data (frame/Series) like so:
new_index = ['bar','foo', 'qux', 'baz']
v.reindex(new_index, level=1)

#first  second
#one    bar      -0.292975
#       foo      -0.458917
#       qux       0.966987
#       baz      -0.176312
#two    bar       1.615486
#       foo      -3.092365
#       qux      -2.348825
#       baz       0.875479
#Name: value, dtype: float64


text:
Q: tshark capture traffic - Channel Hopping I'm trying to capture the Wifi trafic from every AP. However when using tshark -i wlan0mon -w capture -F pcap and running a channel hopping script on the interface wlan0mon.
for ((  i = 1 ;  i <= 11;  i++  )) # channels range
do
iwconfig wlan0mon channel $i
tput cup 0 40          # row 0 and column 40 is used to show channel
echo -n "channel set to" $i " "      # put channel on screen
sleep 0.2 # stay on the channel for 1/10 seconds just like kismet
if [ $i -eq 11 ]
then
i=1
fi
done

I can't see any HTTP/TCP traffic when opening the written file on Wireshark.
I tried setting the interface wlan0mon channel with airmon-ng start wlan0mon X and I can now see the HTTP/TCP traffic.
Is it possible to capture HTTP/TCP traffic with channel hopping?


text:
Q: To initialize a 2D array a nested loop is not necessary. To initialize a 2D array a nested loop is not necessary? A nested for loop in an array is needed to  to access all elements in the two-dimensional array?

A: No, it's not necessary:
int[][] int2dArray = new int[][] {{1, 2, 3}, {4, 5}};
String[][] string2dArray = new String[][]{{"00", "01"}, {"10", "11"}};
BigInteger[][] bigint2dArray = new BigInteger[][] {
    { new BigInteger("1") },
    { new BigInteger("2"), new BigInteger("3") }
};

A: Not really, you can simulate increasing of two indexes in a single loop.
m X n - size of your array
int i = 0;
int j = 0;
for (int k = 0; k < m*n; ++k) {
//Access your array
if (i < m)
++i;
else {
i = 0;
++j;
}
}

Something like this should work.
The condition inside the loop can also look like
i < m-1 && j < n-1

A: If you would like to access all of the elements in a two-dimensional array, that is, to traverse the array, using nested for loops is one way of accomplishing this task.
For example, imagine that you initialized a two dimensional array like so:
int[][] array2D = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

for (int i = 0; i < array2D.length; i++) {

    for (int j = 0; j < array2D[i].length; j++) {

        //Do something with each element in the two-dimensional array.
        //For example:
        System.out.println(array2D[i][j]);

    }

}

The code segment above would loop through each element in the two-dimensional array, printing each one out. At each iteration of the inner for loop, array2D[i][j] represents the current element in the two-dimensional array.


text:
Q: Rendering html in PLAY using jQuery I am newly struggling with PLAY using play-1.2.5 version. I have the knowledge that render() will display a page with the name same as of the method where it is called. (Please correct if wrong)
So, As the callback is optional for $.get() method, I wrote following code in jQuery on a html page,:
 $(document).ready(function(){
            $("#next").click(function(){
                $.get("/nextpage");
            });
        });

having my route file set, it should hit my Firstpage method which is as follows:
 public static void Firstpage(){
        Logger.info("Reached first page");
        render();
    }

What I think is my Firstpage.html (which is a pure html, nothing of templates do I know) should load on screen once I execute it. jQuery is all fine and my Log of this method is also printed on console.
So where am I wrong. Can't pure html be loaded this way and I will have to go for learning templates and all.
Please have a say.


text:
Q: Why was the Triwizard cup portkey in Goblet of Fire two-way? At the end of the scene in the cemetery in GoF, the spirits who emerged from Voldemort's wand tell Harry to go grab the trophy (which, of course, was a portkey that took Harry and Cedric from the maze to the cemetery), and that the trophy portkey would take Harry back to Hogwarts.
Why would the portkey do that?
Are all the portkeys 2-way?
If possible, I would prefer as much of the answer based on canon (or JKR) as feasible

A: Possibly so that after Voldemort's return, he and a few Death Eaters could port back to Hogwarts and initiate an immediate attack.

A: The portkey was "magicked" to bring the winner to the beginning of the maze once someone had touched it (an easy way to figure out who won). My guess is Crouch Jr. only modified the spell so that the portkey took a small detour once someone had touched it so that a second touch would do what the portkey had originally been intended to do.

A: I always took this was a side effect of the reverse spell effect Harry has encountered.  While Harry didn't cast a spell to create or activate the portkey, it's possible that the portkey was set up to activate only if someone with a wand touches it, so that any mindless monster wandering in the maze wouldn't be able to set it off.
Note how it's the echo image of Cedric Lily that recommends Harry to touch the portkey the second time.  Maybe this image was knowledgable about what the portkey will do because both that second use of the portkey and the echo image was created by the same effect.
Update: I misremembered, it was the image of Lily who told Harry to use the Portkey a second time, and she also said 'When the connection is broken, we will longer for only moments …' which is even more strange: how did she know about the Portkey setup at all?
However, I guess @DVK is right and this answer is probably not correct, as the portkey was probably not set up by that wand.

A: During the Quidditch World Cup, they collected "used" port keys; this makes me believe that they are a 1-time-use-per-enchantment item.
I have no source, just what the book lead me to believe: that the Portus charms were layered onto the Triwizard Cup like an onion.
The innermost layer was the Portus charm to bring the winner back to the start of the maze. (cast first, either by the Ministry or Dumbledore).
The outermost layer was the Portus charm cast by Barty Crouch Jr. to bring Harry to the graveyard.
Once the outermost layer was used, then the innermost layer charm was active, which brought Harry back to the maze start.

A: Why do you think Crouch didn't just turn a textbook of something into a portkey? Its because the ministry could monitor all of the portkeys, and it wasn't so easy, but they already authorized the cup to be a portkey to instantly transport the winner back to the maze and Crouch just added the graveyard as a destination between the maze and its original destination. (and the portkey Dumbledore made from the ministry he only activated, but it was always a portkey for emergency exits from the ministry. Either that or, come on, he's Dumbledore)

A: Most of the answers here seem to assume that the cup would have been a portkey anyway, as part of the tournament. However, I believe this is absolutely incorrect. There does not appear to be a shred of evidence in the book that the cup was intended to be a portkey to transport the winner back to the edge of the maze. In fact there is quite a bit of evidence against this idea.
The most obvious line of evidence is that no one ever mentions that the cup is supposed to be a portkey. Bagman didn't mention it when he was telling the champions about the task a month in advance, nor did he mention it when the task was actually taking place.
Furthermore, it is explicitly confirmed that the champions had not been told that the cup was a portkey. From Chapter Thirty-Two:

Cedric looked down at the Triwizard Cup and then up at Harry.
"Did anyone tell you the cup was a Portkey?" he asked.
"Nope," said Harry.

Surely the champions would have been told that cup was a portkey if that had been planned as part of the tournament.
Additionally, Voldemort and Barty Crouch Jr. talk about the portkey in a fashion that very much seems to imply that it was not supposed to be a portkey if not for their meddling. From Chapter Thirty-Three (my emphasis):

"Why... by using Bertha Jorkins's information, of course. Use my one faithful Death Eater, stationed at Hogwarts, to ensure that the boy's name was entered into the Goblet of Fire. Use my Death Eater to ensure that the boy won the tournament — that he touched the Triwizard Cup first — the cup which my Death Eater had turned into a Portkey, which would bring him here, beyond the reach of Dumbledore's help and protection, and into my waiting arms. And here he is... the boy you all believed had been my downfall...."

From Chapter Thirty-Five (my emphasis):

"He asked me whether I was ready to risk everything for him. I was ready. It was my dream, my greatest ambition, to serve him, to prove myself to him. He told me he needed to place a faithful servant at Hogwarts. A servant who would guide Harry Potter through the Triwizard Tournament without appearing to do so. A servant who would watch over Harry Potter. Ensure he reached the Triwizard Cup. Turn the cup into a Portkey, which would take the first person to touch it to my master. But first —"

"I offered to carry the Triwizard Cup into the maze before dinner," whispered Barty Crouch. "Turned it into a Portkey. My master's plan worked. He is returned to power and I will be honored by him beyond the dreams of wizards."

Additionally, when Harry tells what happened, the first thing he says is that the cup was a portkey, as if that was something novel. From Chapter Thirty-Five:

"What happened. Harry?" the man asked at last as he lifted Harry up the stone steps. Clunk. Clunk. Clunk. It was Mad-Eye Moody. "Cup was a Portkey," said Harry as they crossed the entrance hall. "Took me and Cedric to a graveyard... and Voldemort was there... Lord Voldemort..."

And finally, when Harry landed outside the maze it seems obvious from the reaction of the crowd that they were not expecting a portkey. From Chapter Thirty-Five:

A torrent of sound deafened and confused him; there were voices everywhere, footsteps, screams.... He remained where he was, his face screwed up against the noise, as though it were a nightmare that would pass....

(This was before they knew that Cedric was dead (which is only made known several paragraphs later), so the reaction was to the mere fact that Harry and Cedric had portkeyed to that location.)
From the above evidence I think it seems pretty clear that the cup was not intended to be a portkey at all. So now we need a different reason for why it brought Harry back.
This seems to be the only example of a two-way portkey in the books, so we don't have that much information to work with. In any case, we can assume that there are two types of portkeys: ones that take you to a destination, and ones that take you to a destination and back (or to an additional destination).
The portkey in this case was clearly a multiple-use portkey, which simply means that someone enchanted it to travel to more than one destination. Being that Barty Crouch Jr. is the one who turned the cup into a portkey, we have two options: Either he intended for the cup to bring Harry back, or he unintentionally made the cup bring Harry back. For the latter option we would have to assume that he wasn't paying so much attention when he made the portkey and accidentally set it as a two-way portkey instead of a one-way portkey. This is somewhat difficult to suggest, because the cup did not return Harry to his starting point; it returned him to the edge of the maze. If it was a simple mistake of making it a two-way portkey we would expect it to bring Harry back to the middle of the maze where he started from. The fact that it brought him somewhere else would seem to indicate that that location was specifically programmed. However, we can perhaps mitigate this difficulty by surmising that portkey destinations are not set precisely to the exact  square milometer. Perhaps they simply bring you to a more general area like Stoatshead Hill, or the maze.
If the portkey was intentionally programmed to bring Harry back, we need to come up with a reason why this would have been desirable. Another answer here suggested that the goal was for Voldemort and the Death Eaters to be able to go straight to Hogwarts and attack after killing Harry. However, there does not appear to be any evidence that there was ever such a plan, and from the continuation of the story it seems that Voldemort had planned on keeping his return a secret. From Chapter Five of Order of the Phoenix:

"You weren't supposed to survive!" said Sirius.
  "Nobody apart from his Death Eaters was supposed to
  know he'd come back. But you survived to bear
  witness."
"And the very last person he wanted alerted to his
  return the moment he got back was Dumbledore,"
  said Lupin. "And you made sure Dumbledore knew at
  once."

(Granted, this information is coming from the Order of the Phoenix so we can't say for certain that it's reliable vis-a-vis Voldemort's actual intentions.)
Therefore, there should be a different reason why Harry's return was planned. Here are two possibilities:

*

*Harry's return would decrease the suspicion.
If Harry had simply disappeared and not returned everyone would have been extremely suspicious about what happened. When he failed to show up and he wasn't inside the maze everyone's top priority would have been to find him. It is possible that such an influx of activity relating to Harry's disappearance would have led to finding some clues about what happened. On the other hand, if Harry returns back to Hogwarts the immediate priority is very different. No one is missing so there is no need for all resources to be immediately diverted towards an investigation. Instead, the priority would be to deal with the appearance of a dead student and all that that entails. Of course, there would likely be an investigation into his death eventually, but it would probably be less intense and less immediate than if he was still missing. Thus, Crouch Jr. may have brought Harry back to give himself this advantage (however much it would actually be worth).

*Harry's return would serve as confirmation that the plan had succeeded.
If Harry returns to Hogwarts dead, Crouch Jr. has his confirmation that everything went according to plan. Harry's body would not have returned if Voldemort had not successfully come back and killed Harry. Throughout the series it seems that wizards have very few good ways of immediate communication; this would be a simple way to let Crouch Jr. know that everything had worked out. While he would have felt the Dark Mark burning, it seems from his initial conversation with Harry that he wasn't entirely certain that Voldemort had truly come back: From Chapter Thirty-Five:

"What happened. Harry?" the man asked at last as he lifted Harry up the stone steps. Clunk. Clunk. Clunk. It was Mad-Eye Moody.
"Cup was a Portkey," said Harry as they crossed the entrance hall. "Took me and Cedric to a graveyard... and Voldemort was there... Lord Voldemort..."
Clunk. Clunk. Clunk. Up the marble stairs...
"The Dark Lord was there? What happened then?"
"Killed Cedric... they killed Cedric...."
"And then?"
Clunk. Clunk. Clunk. Along the corridor...
"Made a potion... got his body back...."
"The Dark Lord got his body back? He's returned?"
"And the Death Eaters came... and then we dueled...."
"You dueled with the Dark Lord?"
"Got away... my wand... did something funny.... I saw my mum and dad... they came out of his wand...."

Thus, the purpose of the portkey coming back to Hogwarts may have been to provide full confirmation of the plan's success.
Importantly, though, even using the answer that the cup was meant to be a portkey all along, we would still have to introduce the novel idea that a portkey can go to multiple destinations, plus we would still not know why Crouch Jr. allowed it to return to Hogwarts. Since we anyway have to grant the existence of a new type of portkey and come up with a reason for why Crouch Jr. wanted Harry to return, we don't gain anything by positing the additional novelty that the cup was intended to be a portkey all along.
And of course, there is always the possibility that the correct answer is as suggested in the two deleted answers — that this was a plot convenience, or that JK Rowling didn't think it through.

A: I think that it was an accidental magical reaction that a young wizard has. Remember that little kids usually do magic without knowing it. Whenever Harry felt a strong emotion (fear or anger for example), he would unknowingly do magic, such as with Dudley in the zoo, Marge at Privet Drive, or apparating to the school roof when being chased by Dudley's gang.
He was afraid for his life when he grabbed the cup, so perhaps he accidentally cast a Portkey spell (nonverbally), and grabbed the cup at the same time.


text:
Q: AFNetworking Issue: serialization.response Code=-1011 "Request failed: not found (404)" I'm currently setting up an iOS app using Django Rest framework for the backend API. I am getting a -1011, request not found error when the url I'm using clearly exists.
The console outputs:
Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: not found (404)"
UserInfo={com.alamofire.serialization.response.error.response<NSHTTPURLResponse:0x12d797940>

{ URL: https://myurl.com/users/login/ }
{ status code: 404, headers {
    Allow = "POST, OPTIONS";
    Connection = "keep-alive";
    "Content-Type" = "application/json";
    Date = "Thu, 06 Aug 2015 04:12:34 GMT";
    Server = "Apache/2.4.12 (Amazon) mod_wsgi/3.5 Python/2.7.9";
    "Transfer-Encoding" = Identity;
    Vary = "Accept,Cookie";
    "X-Frame-Options" = SAMEORIGIN;
} },

NSErrorFailingURLKey=https://myurl.com/users/login/,
com.alamofire.serialization.response.error.data=<7b226d73 67223a22 536f7272 792c2079 6f757220 75736572 6e616d65 2c656d61 696c206f 72207061 7373776f 72642069 7320696e 636f7272 6563742e 227d>, NSLocalizedDescription=Request failed: not found (404)}
2015-08-06 00:12:35.070 Tumvi[10963:3903454] Failed To Login

I've tested the endpoint using Rest client extension on chrome and as I mention before, the exact same code on the simulator IOS8.4 and another non-ios9 phone ran without any issues.
Honestly, I can't seem to figure out what might be the issue. Appreciate your help!

A: i hope it help you.
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];  //AFHTTPResponseSerializer serializer
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];


text:
Q: d3.select.style not working on firefox I just spent an embarrassing amount of time resolving this error and want to document the answer.
The following bit of code has the desired result on Chrome but not on Firefox:
svg=d3.select('svg').style({height : 100,width : 200})

Why?

A: The answer
svg=d3.select('svg').style({height : 100 + "px", width : 200 + "px"})

Looks like Chrome decides to default to"px" while Firefox want you to be explicit.
Hope this helps anyone having the same issue.


text:
Q: fsl.sh cannot be sourced I need to install FSL and Freesurfer as part of running Connectome Mapper. Freesurfer required changing the shell to tcsh in order to configure its folders. Now for FSL, I have to add to .profile the line bash /etc/fls/5.0/fls.sh, but this line does nothing in fact so when I log in to the console and send echo $FLSDIR I get in fact nothing. How can I use this sh script in the tcsh console?
The fsl.sh file is given by:
# FSL configuration file
#  - to be sourced by the user, typically in .bashrc or equivalent
#  - note that the user should set
# Written by Mark Jenkinson, FMRIB Analysis Group, University of Oxford
# Modified for Debian by Michael Hanke <michael.hanke@gmail.com>

# clean out previous fsl PATH components: DO NOT EDIT THE NEXT TWO LINES
PATH=$( echo $PATH | tr ":" "\n" | grep  -v "/usr/lib/fsl/" | tr -s "\n" ":" | sed  's/:$//')
LD_LIBRARY_PATH=$( echo $LD_LIBRARY_PATH | tr ":" "\n" | grep  -v "/usr/lib/fsl/" |  tr -s "\n" ":" | sed 's/:$//')

#### Set up standard FSL user environment variables ####

# Debian has a fixed FSLDIR
FSLDIR=/usr/share/fsl/5.0

# Possum is installed in the same directory
POSSUMDIR=$FSLDIR

# add the fsl binary path to the search path
PATH=$PATH:/usr/lib/fsl/5.0

# The following variable selects the default output image type
# Legal values are:
# NIFTI, NIFTI_PAIR, NIFTI_GZ, NIFTI_PAIR_GZ
# This would typically be overwritten in ${HOME}/.fsl/fsl.sh if the user
# wished to write files with a different format
FSLOUTPUTTYPE=NIFTI_GZ

# Comment out the definition of FSLMULTIFILEQUIT to enable
#  FSL programs to soldier on after detecting multiple image
#  files with the same basename ( e.g. epi.hdr and epi.nii )
FSLMULTIFILEQUIT=TRUE

# The following variables specify paths for programs and can be changed
# or replaced by different programs, by default set sensible Debian-defaults
FSLTCLSH=/usr/bin/tclsh
FSLWISH=/usr/bin/wish
FSLBROWSER=/etc/alternatives/x-www-browser

# The following variables are used for running code in parallel across
#  several machines ( i.e. for FDT )
# for a cluster engine setup see below
FSLLOCKDIR=
FSLMACHINELIST=
FSLREMOTECALL=

# If set, tell FSL to use Sun Gridengine to submit jobs instead of running them
# directly on the machine. If unset, no attempt will be made to utilize
# gridengine, even if it is running. By default SGE is not utilized.
#FSLPARALLEL=1

# Mail setup for gridengine jobs. See man qsub (-m option) for all possible
# settings. By default no email is sent.
FSLCLUSTER_MAILOPTS="n"

# default queue for job submissions
#FSLCLUSTER_DEFAULT_QUEUE="all.q"

###################################################
####    DO NOT ADD ANYTHING BELOW THIS LINE    ####
###################################################

export FSLDIR POSSUMDIR PATH FSLMULTIFILEQUIT FSLOUTPUTTYPE FSLTCLSH \
       FSLWISH FSLBROWSER FSLLOCKDIR FSLMACHINELIST FSLREMOTECALL

# Configure the linker search path for Debian FSLs internal shared libraries
LD_LIBRARY_PATH=/usr/lib/fsl/5.0${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH

# load user configuration
if [ -f "${HOME}/.fslconf/fsl.sh" ] ; then
"${HOME}/.fslconf/fsl.sh" ;
fi

A: You don't know how to source a file (script). The right way is to use one of the following commands:
source /etc/fls/5.0/fls.sh

or
. /etc/fls/5.0/fls.sh

See also:

*

*What is the difference between "source x", ". x" and "./x" in Bash?


text:
Q: JSoup - Extracting the title and price only I am trying to extract a listing's name and price off eBay sold listings. However, my code below does not seem to work:
   public static void main(String[] args) throws IOException {
        Document document = Jsoup.connect("https://www.ebay.com/sch/i.html?_from=R40&_nkw=PSA+10+silver+prizm+rookies&_sacat=0&LH_TitleDesc=0&rt=nc&LH_Sold=1&LH_Complete=1").get();
            String index = "li#srp-river-results-listing1";
            Elements listings = document.select(index); // Each box contains the deal info
            //System.out.println(listings);
            String listingName = listings.select("h3.s-item__title s-item__title--has-tags").text();
            //for (int j = 0; j < listingName.length() - 1; j++) {
                //if(listingName.charAt(j) == '?') {
                    //System.out.println("This listing is wrong.");
                //}
            }
            System.out.println(listingName);
        }

I am able to print the listings, but the the listingName. I suspect that I select the name wrong - but I don't know how to fix it. If I replace
String listingName = listings.select("h3.s-item__title s-item__title--has-tags").text();

with
String listingName = listings.text();

It will give me every text within the li element, which I don't need - I only need the listings' name and sold price.

A: I just try the css selector and realized that, instead of "li#srp-river-results-listing1", I should have select "a.s-item__link > h3".