text:
Q: Typescript - Create our own StringType utility types Is there a way to define our own StringType utility types such as Kebabcase<StringType>, Camelcase<StringType>, Snakecase<StringType>, Pascalcase<StringType>, ...
Like Uppercase<StringType> or Capitalize<StringType> ?
I have checked this page in the Typescript doc to see how these native utility types are defined. However it doesn't seem possible to reuse the same logic as there come built-in to the compiler.
I still ask the question in case something similar exists.

A: Foreword
I've found a library called type-fest which has utility types for all your cases (and more). You can inspects its source to see how they do it. It's written by a person who has put much more thought in all the possible cases to handle. I'll leave my original answer because the theory still stands, the demo is an interesting naive implementation and the listed further reading is insightful.

Theory
It it possible to combine type inference and string manipulation recursively to achieve this. The general pattern* is:
type CaseManipulation<T extends string> =
//                    ^^^^^^^^^^^^^^^^
//                  Constrain to strings
  T extends `${infer Head} ${infer Tail}` ?
//           ^^^^^^^^^^^^^
// Infer the characters
// before the first space
//                          ^^^^^^^^^^^^
//               Infer all the following characters
    `${Lowercase<Head>}-${CaseManipulation<Tail>}` : Lowercase<T>;
// Apply any manipulations to returned result and recursively apply to the tail. The example here is with kebab case.

Demo
Here's a demo with a with all the cases you've listed*:
type foo = "foo";
type fooBar = "foo bar";
type fooBarBaz = "foo bar baz";
type fooBarBazQux = "foo bar baz qux";

type CamelCase<T extends string> = T extends `${infer Head} ${infer Tail}` ? `${Uncapitalize<Head>}${CamelCase<Capitalize<Tail>>}` : Lowercase<T>;

type cameled0 = CamelCase<foo>;
type cameled1 = CamelCase<fooBar>;
type cameled2 = CamelCase<fooBarBaz>;
type cameled3 = CamelCase<fooBarBazQux>;

type PascalCase<T extends string> = T extends `${infer Head} ${infer Tail}` ? `${Capitalize<Head>}${PascalCase<Tail>}` : Capitalize<T>;

type pascaled0 = PascalCase<foo>;
type pascaled1 = PascalCase<fooBar>;
type pascaled2 = PascalCase<fooBarBaz>;
type pascaled3 = PascalCase<fooBarBazQux>;

type KebabCase<T extends string> = T extends `${infer Head} ${infer Tail}` ? `${Lowercase<Head>}-${KebabCase<Tail>}` : Lowercase<T>;

type kebabed0 = KebabCase<foo>;
type kebabed1 = KebabCase<fooBar>;
type kebabed2 = KebabCase<fooBarBaz>;
type kebabed3 = KebabCase<fooBarBazQux>;

type SnakeCase<T extends string> = T extends `${infer Head} ${infer Tail}` ? `${Lowercase<Head>}_${SnakeCase<Tail>}` : Lowercase<T>;

type snaked0 = SnakeCase<foo>;
type snaked1 = SnakeCase<fooBar>;
type snaked2 = SnakeCase<fooBarBaz>;
type snaked3 = SnakeCase<fooBarBazQux>;

* caveat I haven't tried to be comprehensive with the possible inputs/outputs but it should give a general idea of a solution

Further reading

*

*TypeScript documentation on type inference

*TypeScript documentation on template literal types and string manipulations


text:
Q: Are .htaccess redirects secure/reliable (website maintenance)? Our website will be going down for around an hour or so for maintenance. All users need to be redirected to a page indicating that the website is receiving an update and/or under maintenance.
Will using the following .htaccess rules reliably prevent all users access from the website and reliably redirect all traffic that doesn't match my IP to the maintenance page? i.e. there is no way for anyone to bypass these redirect/rewrite rules?
RewriteCond %{REQUEST_URI} !/maintenance.php$
RewriteCond %{REMOTE_ADDR} !^192\.192\.192\.192$
RewriteRule $ /maintenance.php [R=302,L]

A: I suppose it depends on how much of your site/server you are taking down and whether you have other/conflicting .htaccess files elsewhere on your filesystem? But otherwise, if .htaccess and mod_rewrite is still available then your temporary redirect should work OK. There is no way for a user to bypass those rules unless they somehow hack your server.
Bear in mind that mod_rewrite directives in parent directories can be completely overridden by child directives, further down the filesystem path. For example, if you have a directory /foo with its own .htaccess file that uses mod_rewrite (ie. /foo/.htaccess) then should someone request /foo/bar your parent mod_rewrite directives will be overridden and the redirect will not occur. For this reason, these directives would be better in the server config - in a vhost or server context - so they cannot be overridden. Or use mod_authz_core/host and customise the response.
However, if this is an existing site that is already indexed by search engines then you should consider sending a 503 Service Unavailable response together with a Retry-After HTTP response header (indicating the hour of maintenance) - instead of a redirect. This is the preferred response in order to preserve SEO.
See my answer to the following question on the Webmasters stack for more on the 503 response:

*

*Website is under maintenance - how to restrict access?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Setting Up Intern for Javascript Project I know there are a couple of similar questions already answered (Testing custom JavaScript (not Node module) with Intern and Can't get Intern to run Node.js Module), but even after reading those answers, I've still been unable to get some simple tests to run using Intern. I feel like there is just one small piece that I am overlooking or missing.
I am trying to evaluate Intern for use with an existing Javascript project. It's not a Node project, just plain Javascript. If it matters, I am trying to perform this evaluation on a Windows machine.

*

*My project hierarchy looks like this:
APEFIntern/
    apeform/
        test/
            intern.js      - Intern configuration
            spec_inwf.js   - Tests for inwf
        inwf.js            - Code to test
    intern/

*Intern configuration file:
// ...

// Configuration options for the module loader; any AMD configuration options supported by the Dojo loader can be
// used here
loader: {
    // Packages that should be registered with the loader in each testing environment
    //packages: [ 'apeform' ]
},

// Non-functional test suite(s) to run in each browser
suites: [ 'apeform/test/spec_inwf' ],

// ...

I'm pretty new to Node and AMD, but I believe that since my project is not a node project, I do not need to use the loader.packages configuration?

*Test file spec_inwf.js
define([
'intern!bdd',
'intern!chai!expect',
'apeform/inwf.js'
], function (bdd, expect) {
    with (bdd) {
        describe("inwf suite", function () {
            // Tests
        });
    }
});

*I execute the following command to try and run the tests:
node client.js config=apeform/test/intern

The only output I receive from the command is:
Defaulting to "console" reporter

If I set the suites array to be empty in the Intern configuration, I get the message "0/0 tests passed" when I execute the command in #4. I believe this is the correct output. But whenever I try to connect to a test suite, the tests aren't run. I'm not sure what else I'm missing from this equation. Any help would be appreciated.

A: It looks like you have a small syntax issue in your spec_inwf.js test file:
'intern!chai!expect',

should be
'intern/chai!expect',

Everything else looks fine with your setup.
Note: your statement about not needing to use the loader.packages config if your project isn't a Node project is not really accurate. You don't need to use it in this particular case with the file structure you provided, however. The amdjs packages documentation may be worth a read for a better understanding of this configuration option, as it is AMD-specific, not Intern specific. Hope this helps.


text:
Q: Debugging a Ruby segfault How do I determine if a segfault is due to inconsistent libraries, or a bug in some gem I'm using?
$ uname -a
Linux [redacted] 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ ruby1.9.1 --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ CPUPROFILE_OBJECTS=1 CPUPROFILE=/tmp/my_app_profile_objects RUBYOPT="-r`gem1.9.1 which perftools | tail -1`" ruby1.9.1 -e '[].map'
-e:1: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC  :map
c:0003 p:0010 s:0006 b:0006 l:0011f8 d:0002f8 EVAL   -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0011f8 d:0011f8 TOP

-- Ruby level backtrace information ----------------------------------------
-e:1:in `<main>'
-e:1:in `map'

-- C level backtrace information -------------------------------------------
/usr/lib/libruby-1.9.1.so.1.9(+0x155b29) [0x7fd39f1dab29] ../sysdeps/x86_64/multiarch/strcpy-ssse3.S:1638
/usr/lib/libruby-1.9.1.so.1.9(+0x57709) [0x7fd39f0dc709] vfscanf.c:1777
/usr/lib/libruby-1.9.1.so.1.9(rb_bug+0xb7) [0x7fd39f0dd137] vfscanf.c:1796
/usr/lib/libruby-1.9.1.so.1.9(+0xf604f) [0x7fd39f17b04f] wcfuncs.c:49
/lib/x86_64-linux-gnu/libc.so.6(+0x364c0) [0x7fd39ecfe4c0] ../sysdeps/posix/killpg.c:38
/usr/lib/libruby-1.9.1.so.1.9(rb_check_type+0xd8) [0x7fd39f0de7e8] vfscanf.c:1963
/usr/lib/libruby-1.9.1.so.1.9(rb_data_typed_object_alloc+0xad) [0x7fd39f0f340d] iofdopen.c:51
/usr/lib/libruby-1.9.1.so.1.9(+0x54f9f) [0x7fd39f0d9f9f] vfscanf.c:2014
/usr/lib/libruby-1.9.1.so.1.9(rb_enumeratorize+0x33) [0x7fd39f0dae33] vfscanf.c:2373
/usr/lib/libruby-1.9.1.so.1.9(+0x14e9a1) [0x7fd39f1d39a1] ../sysdeps/x86_64/multiarch/../strcmp.S:293
/usr/lib/libruby-1.9.1.so.1.9(+0x145912) [0x7fd39f1ca912] ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:2001
/usr/lib/libruby-1.9.1.so.1.9(+0x14b31d) [0x7fd39f1d031d] ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:2032
/usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval_main+0xaf) [0x7fd39f1d769f] ../sysdeps/x86_64/multiarch/../strcmp.S:1811
/usr/lib/libruby-1.9.1.so.1.9(+0x5b172) [0x7fd39f0e0172] vfscanf.c:1471
/usr/lib/libruby-1.9.1.so.1.9(ruby_exec_node+0x1d) [0x7fd39f0e0c5d] vfscanf.c:2288
/usr/lib/libruby-1.9.1.so.1.9(ruby_run_node+0x1e) [0x7fd39f0e280e] psiginfo.c:209
ruby1.9.1() [0x4007db]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7fd39ece976d] libc-start.c:226
ruby1.9.1() [0x400809]

-- Other runtime information -----------------------------------------------

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
    2 /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
    3 /usr/lib/ruby/1.9.1/rubygems/defaults.rb
    4 /usr/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb
    5 /usr/lib/ruby/1.9.1/rubygems/deprecate.rb
    6 /usr/lib/ruby/1.9.1/rubygems/exceptions.rb
    7 /usr/lib/ruby/1.9.1/rubygems/custom_require.rb
    8 /usr/lib/ruby/1.9.1/rubygems.rb
    9 /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so

* Process memory map:

00400000-00401000 r-xp 00000000 08:07 704429                             /usr/bin/ruby1.9.1
00600000-00601000 r--p 00000000 08:07 704429                             /usr/bin/ruby1.9.1
00601000-00602000 rw-p 00001000 08:07 704429                             /usr/bin/ruby1.9.1
01464000-016e4000 rw-p 00000000 00:00 0                                  [heap]
7fd39c3e1000-7fd39cf53000 rw-p 00000000 00:00 0
7fd39cf53000-7fd39cf68000 r-xp 00000000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39cf68000-7fd39d167000 ---p 00015000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39d167000-7fd39d168000 r--p 00014000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39d168000-7fd39d169000 rw-p 00015000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39d169000-7fd39d24b000 r-xp 00000000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d24b000-7fd39d44a000 ---p 000e2000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d44a000-7fd39d452000 r--p 000e1000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d452000-7fd39d454000 rw-p 000e9000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d454000-7fd39d469000 rw-p 00000000 00:00 0
7fd39d469000-7fd39d47d000 r-xp 00000000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d47d000-7fd39d67c000 ---p 00014000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d67c000-7fd39d67d000 r--p 00013000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d67d000-7fd39d67e000 rw-p 00014000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d67e000-7fd39d682000 rw-p 00000000 00:00 0
7fd39d682000-7fd39d684000 r-xp 00000000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d684000-7fd39d884000 ---p 00002000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d884000-7fd39d885000 r--p 00002000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d885000-7fd39d886000 rw-p 00003000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d886000-7fd39d888000 r-xp 00000000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39d888000-7fd39da87000 ---p 00002000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39da87000-7fd39da88000 r--p 00001000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39da88000-7fd39da89000 rw-p 00002000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39da89000-7fd39e16c000 r--p 00000000 08:07 134744                     /usr/lib/locale/locale-archive
7fd39e16c000-7fd39e265000 r-xp 00000000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e265000-7fd39e464000 ---p 000f9000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e464000-7fd39e465000 r--p 000f8000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e465000-7fd39e466000 rw-p 000f9000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e466000-7fd39e46f000 r-xp 00000000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e46f000-7fd39e66f000 ---p 00009000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e66f000-7fd39e670000 r--p 00009000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e670000-7fd39e671000 rw-p 0000a000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e671000-7fd39e69f000 rw-p 00000000 00:00 0
7fd39e69f000-7fd39e6a1000 r-xp 00000000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e6a1000-7fd39e8a1000 ---p 00002000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e8a1000-7fd39e8a2000 r--p 00002000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e8a2000-7fd39e8a3000 rw-p 00003000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e8a3000-7fd39e8aa000 r-xp 00000000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39e8aa000-7fd39eaa9000 ---p 00007000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39eaa9000-7fd39eaaa000 r--p 00006000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39eaaa000-7fd39eaab000 rw-p 00007000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39eaab000-7fd39eac3000 r-xp 00000000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39eac3000-7fd39ecc2000 ---p 00018000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39ecc2000-7fd39ecc3000 r--p 00017000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39ecc3000-7fd39ecc4000 rw-p 00018000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39ecc4000-7fd39ecc8000 rw-p 00000000 00:00 0
7fd39ecc8000-7fd39ee7b000 r-xp 00000000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39ee7b000-7fd39f07a000 ---p 001b3000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39f07a000-7fd39f07e000 r--p 001b2000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39f07e000-7fd39f080000 rw-p 001b6000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39f080000-7fd39f085000 rw-p 00000000 00:00 0
7fd39f085000-7fd39f0f0000 r-xp 00000000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f0f0000-7fd39f0f3000 rwxp 0006b000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f0f3000-7fd39f275000 r-xp 0006e000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f275000-7fd39f474000 ---p 001f0000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f474000-7fd39f479000 r--p 001ef000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f479000-7fd39f47d000 rw-p 001f4000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f47d000-7fd39f499000 rw-p 00000000 00:00 0
7fd39f499000-7fd39f4bb000 r-xp 00000000 08:06 5402                       /lib/x86_64-linux-gnu/ld-2.15.so
7fd39f59b000-7fd39f6a1000 rw-p 00000000 00:00 0
7fd39f6b4000-7fd39f6b5000 rw-p 00000000 00:00 0
7fd39f6b5000-7fd39f6b6000 ---p 00000000 00:00 0
7fd39f6b6000-7fd39f6bb000 rw-p 00000000 00:00 0
7fd39f6bb000-7fd39f6bc000 r--p 00022000 08:06 5402                       /lib/x86_64-linux-gnu/ld-2.15.so
7fd39f6bc000-7fd39f6be000 rw-p 00023000 08:06 5402                       /lib/x86_64-linux-gnu/ld-2.15.so
7fff507f8000-7fff50819000 rw-p 00000000 00:00 0                          [stack]
7fff50941000-7fff50942000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)

A: You can find out which part of the software caused a segmentation fault by - and this is probably not a surprise to you - debugging!. As you can see...
Aborted (core dumped)

...there is a core dump.
Just fire up gdb on your executable and the core dump and find out what the parameters to that strcpy (see the first line of your backtrace) were. Then walk backwards trough the stack traces and the code. It seems like debugging symbols have been compiled in, so you are lucky and you can see which function is actually called and what parameters are supplied - at least if the bug did not corrupt the stack.
However, If you are not too familiar with debugging C or assembly code, you probably want to wait for the developers of perftools to debug this issue.

A: That looks like Ruby itself is crashing, so chances are, it's a bug.  Ruby 1.9.3 is the latest, so you might try that to see if the bug is fixed.


text:
Q: deleting hibernate image after failed hibernation after trying
sudo pm-hibernate
my w520 can't start anymore.
only when adding a 'noresume' to the kernel parameters I can start with grup.
what are the steps to remove all the hibernate disaster?
formating swap partition?
what about fstab?

A: I would also try removing (unmounting), formatting and readding (as swap) the linux-hibernate partition using gparted. Performing this possibly makes editing a config file (/etc/fstab) necessary. You will have to re-add the partition to this list to have it auto-mounted at boot again. If you need more help (e.g. exact syntax needed in fstab or about use of gparted), please leave a quick comment at my answer.


text:
Q: Intentando mapear valores en C# Me gustaría mapear los valores de giro de un giroscopio a un valor
entre -1 y 1;
    _________________
    | -1  | 0   | 1 |
    |---------------|
    | 365 | 180 | 0 |
    +---------------+

Lo intento con esta operación
  Mathf.Lerp(-1f, 1f, ValorGiroscopio);

Pero no lo consigo, ¿alguna idea?
Con Arduino se logra muy fácilmente y me gustaría saber si existe
una función parecida
map();

A: Para crear un método que normalice valores en un rango a otro, podemos fijarnos en la formula de esta respuesta:

Si trasladamos esto a un método, nos queda algo similar a esto:
static public float Map(float value, float istart, float istop, float ostart, float ostop)
{
    return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
}

Modo de llamarlo:
var normalizado = Map(165, 0, 365, 1, -1);

donde:
value - valor a normalizar
istart - valor minimo posible de entrada
istop - valor máximo de entrada
ostart - valor minimo posible de salida
ostop - valor máximo de salida

El método está copiado tal cual del método map de Processing


text:
Q: my listview can't show all elements in database I've an application to store name and image in database.Then I print name of images on listview.But just Im able to see first three elements from database..It shows me Window is full error.No problem on database,I checked database via sqlitebrowser and all elements are exist there.Probably there's problem on my arrayadapter.What's problem?Also images are small 30kb.
Error when I try to see all images on ListView

Error
W/CursorWindow: Window is full: requested allocation 5397663 bytes, free space 1143664 bytes, window size 2097152 bytes
W/CursorWindow: Window is full: requested allocation 5397663 bytes, free space 2023760 bytes, window size 2097152 bytes
Window is full: requested allocation 5397663 bytes, free space 2096700 bytes, window size 2097152 bytes
E/SQLiteCursor: onMove() return false. RequiredPos: 3 WindowStartPos: 3 WindowRowCount: 0(original count of query: 6)

OnCreate Method
 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ListView listView = (ListView) findViewById(R.id.listView);

        final ArrayList<String> artName = new ArrayList<String>();
        artImage = new ArrayList<Bitmap>();

        ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,artName);
        listView.setAdapter(arrayAdapter);

        try {

            Main2Activity.database = this.openOrCreateDatabase("Arts", MODE_PRIVATE, null);
            Main2Activity.database.execSQL("CREATE TABLE IF NOT EXISTS arts (name VARCHAR, image BLOB)");

            Cursor cursor = Main2Activity.database.rawQuery("SELECT * FROM arts", null);//cursor is for data recieving

            int nameIx = cursor.getColumnIndex("name");
            int imageIx = cursor.getColumnIndex("image");

            cursor.moveToFirst();

            while (cursor != null) {

                artName.add(cursor.getString(nameIx));
                //adding bitmap into artImage
                byte[] byteArray = cursor.getBlob(imageIx);
                //decoding bitmaps
                Bitmap image = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);
                artImage.add(image);

                cursor.moveToNext();

                arrayAdapter.notifyDataSetChanged();//data degistiyse arrayadapter'a haber veriyor ve guncelleyip kullaniciya gosterir

            }

        } catch (Exception e) {
            e.printStackTrace();
        }

         //selecting saved images
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
                intent.putExtra("info", "old");
                intent.putExtra("name", artName.get(position));
                intent.putExtra("position", position);

                startActivity(intent);

            }
        });

    }
}

ListView from xml
 <ListView
        android:id="@+id/listView"
        android:layout_width="368dp"
        android:layout_height="495dp"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp" />

A: A Cursor window has a limitation of 2MB, a row must fit into a Cursor Window, it cannot be split across multiple Cursor Windows and hence your 5Mb image cannot be retrieved via a Cursor (the CursorWindow is effectively a buffer for the Cursor).
The best way of handling such images is to store the image(s) as files and to store the path to the image in the database. This answer shows an example of storing the image path (and also the image when the image size is below a certain size (100k)) and also includes some underlying detail on the subject.
A clumsy way of storing large images, albeit NOT RECOMMENDED, is described at How to use images in Android SQLite that are larger than the limitations of a CursorWindow?


text:
Q: Prove that no matter what integer k you choose, the number $7k+3$ will not be a perfect square.
Prove that no matter what integer k you choose, the number $7k+3$ will
  not be a perfect square.

My thought when attempting this problem is to use a proof by contradiction, and suppose that there is some k where $7k = a^2 - 3$ but im unsure on how to prove it after this, maybe it has something to do with modulo which we just learned about briefly on Friday?

A: Any integer $n$ is of the form $7k+j$ for a unique integer $k$ and a unique $j \in \{ 0,1,\dots,6 \}$. This $k$ is the quotient when $n$ is divided by $7$, this $j$ is the remainder.
Now show that the remainder when $(7k+j)^2$ is divided by $7$ is the same as the remainder when $j^2$ is divided by $7$. So you reduce the problem to computing a few remainders.
Choosing to take $j \in \{ -3,-2,\dots,3 \}$ will also work, and will make the arithmetic a little bit easier to do by hand.

A: Any square has remainder $0,1,2$ or $4$ when divided by $7$.

Since any integer modulo $7$ is equivalent to $0,1,2,3,4,5$ or $6$. Any square is equivalent to $0^2,1^2,2^2,3^2,4^2,5^2$ or $6^2$ modulo $7$.


text:
Q: Visual C#: Cannot use the Convert method in winforms anymore Maybe I am missing something entirely simple here, but in any new windows form I create, I can no longer use the Convert method. I am pretty sure all my using directives are there and I am using no extensions. I have done nothing to change VS since the last time I used it, when everything worked.
Could it be a hiccup of VS 2011 Beta or just a simple error on my part?
Here is my code along with the error displayed:

'System.Windows.Forms.Button' does not contain a definition for
  'ToInt32'
and no extension method 'ToInt32' accepting a first argument of type
'System.Windows.Forms.Button' could be found
(are you missing a using directive or an assembly reference?)

Here's the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TempConvert
{
    public partial class Form1 : Form
    {
        int degreesEntered;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void Convert_Click(object sender, EventArgs e)
        {
            degreesEntered = Convert.ToInt32(Degrees.Text);
        }
    }
}

A: I believe the problem is you have a button named Convert which is hiding the static class - you can try using the full namespace to reference it, or doing an int.Parse
System.Convert.ToInt32(Degrees.Text);

A: Use Int32.Parse() when parsing text into integers.

A: Your button Convert should be renamed as it has the same name of the class Convert and you might be using this class in several other parts of the application

A: Use fully qualified name as System.Convert


text:
Q: Change hyperlink style I'm trying to change a word in a hyperlink text.
Let's say the hyperlink is "foofoofoo". How to change the middle foo to italics?
I've tried this:

foo
foo
foo

However, my IDE states underlines the div as error and the whole hyperlink style gets messed up.
Am I doing it wrong?
Thank you for the help!

A: You shouldn't be using a block element for this. You really should use an inline element like span.

foofoofoo

Here is a great write-up on the differences: What is the difference between display: inline and display: inline-block?

A: Wrap the middle foo in the italic  tag instead of a division.
foofoofoo


text:
Q: Automatically run functions in a specific order I want to know if there is a way to run all my functions in f.e. the "functions-Class" by putting a certain line in my main method. the idea behind this is, to save some pace and time, writing out every single function and making a terribly long main method.
I'm thinking of sth. like(just to demonstrate what I'm looking for):
namespace ConsoleApp1
{
    class Functions
    {
        public void Function1()
        {
            do.Something();
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            RunAllFunctionsInFunctionsInAlphabeticalOrder();
        }
    }
}

Thanks in advance!

A: Despite all the comments about proper OOP in this case (which, I think, are valid), here is a little reflection-based example:
class F
{
    public void F1()
    {
        Console.WriteLine("Hello F1");
    }
}

class MainClass
{
    public static void Main(string[] args)
    {
        var f = new F();

        foreach (var method in
          // get the Type object, that will allow you to browse methods,
          // properties etc. It's the main entry point for reflection
          f.GetType()
             // GetMethods allows you to get MethodInfo objects
             // You may choose which methods do you want -
             // private, public, static, etc. We use proper BindingFlags for that
            .GetMethods(

              // this flags says, that we don't want methods from "object" type,
              // only the ones that are declared here
              BindingFlags.DeclaredOnly

              // we want instance methods (use "Static" otherwise)
            | BindingFlags.Instance

              // only public methods (add "NonPublic" to get also private methods)
            | BindingFlags.Public)

         // lastly, order them by name
         .OrderBy(x => x.Name))
        {
            //invoke the method on object "f", with no parameters (empty array)
            method.Invoke(f, new object[] { });
        }
    }
}

This will, effectively, get all public instance method from type F, order them by name, and execute with no parameters.
In this particular case, it will display:

Hello F1

But in general running "all methods", and, even worse, depend on their alphabetical order, is to be strongly discouraged.
Welcome to StackOverflow!

A: Use the Func method
        static void Main(string[] args)
        {

            List<Func<string, string>> methods = new List<Func< string, string>>(){
                methodA, methodB, methodC, methodD
            };

            foreach (Func<string,string> method in methods)
            {
                string result = method("a");

            }

        }
        static string methodA(string a)
        {
            return a;
        }
        static string methodB(string b)
        {
            return b;
        }
        static string methodC(string c)
        {
            return c;
        }
        static string methodD(string d)
        {
            return d;
        }


text:
Q: Linking users to chrome flags page I've created a site that utilizes the new Web Midi Api, native in Chrome Canary.
Since web midi isn't enabled by default, I would like to simply direct my users to chrome://flags/#enable-web-midi where they can enable midi.
I discovered that using an anchor tag isn't allowed, nor is window.open("chrome://flags"). I'm wondering if there is a Chrome expert out there who could steer me in the right direction.
I want to make this enabling step as easy as possible for my users.

A: chrome.tabs.create({url: "chrome://flags#enable-web-midi"});

This does not require any permission. (This assumes you are developing a Chrome app, if you are making a normal site, then I don't think it's possible.)
Details on chrome.tabs.create.


text:
Q: How to distinguish BIM 360 vs ACC/unified projects? (Update: There may or may not be any such thing as a "unified project". But there is definitely a button on my Account Admin->Projects screen that says "Go to unified projects", hence my confusion. It just takes me to a list of all projects.)
Since some API endpoints are not compatible between the two types of projects, (see https://forge.autodesk.com/en/docs/acc/v1/overview/bim-360-compatibility/compatibility-table/), it would be nice to know, programmatically, which type of project you are dealing with.
The response from  https://developer.api.autodesk.com/hq/v1/accounts/:hub_id/projects lists, for example, the exact same details regardless. Is there another call that would give more info?
I know that the BIM 360 projects start with "b.", but not in the above list.
Just poking around, the BIM 360 API endpoint https://developer.api.autodesk.com/hq/v1/accounts/:account_id/projects apparently returns only(?) BIM 360 projects, complete with "b.". But if I want ALL projects, and simply need to know the difference? I could make both calls and parse the differences; but one call with the correct info would be great, if it exists.

A: The endpoint I meant is: https://forge.autodesk.com/en/docs/data/v2/reference/http/hubs-hub_id-projects-GET/. It is for project information in the general context. The one you pointed out is for getting project information in the context of BIM360.
Data Management is a general API. e.g. you manage your (as a web application) manage models and data in your own buckets (on Forge), this goes with Data Management.  BIM360 or ACC or Fusion360 etc is the platform that manages model or data for end users, in a format of more user-orientated structure like hub>>project>>folder>>item>>version etc.  These fall into Data Management.  BIM 360 API  will be more specific in the context of BIM360. e.g. Admin API (like what you are using), Issue API, RFI API, Cost API , Model Coordination API etc.
As to united project, it means the project list managed within Autodesk Construction Cloud (ACC), which includes BIM360 projects and ACC projects. In another word, a united portal to access the two types of projects. To distinguish the two types, the attribute I mentioned in the last email is the indicator.  Hope it explains.


text:
Q: Prove that $a$ commutes with each of its conjugates in $G$ if and only if a belongs to an abelian normal subgroup of $G$. Let $a$ be an element of a group $G$. Prove that $a$ commutes with each of its conjugates in $G$ if and only if a belongs to an abelian normal subgroup of $G$.
My attempt: Firstly, suppose that $N$ is an abelian normal subgroup of $G$.
Since, $a$ belongs to $N$ and $N$ is a normal subgroup. This implies, $gag^{-1}\in N$, for all $g \in G$.
Now, $a \in N$, and  $gag^{-1}\in N$, this implies $(a)(gag^{-1})=(gag^{-1})(a)$ (because, $N$ is a normal subgroup of $G$).
This shows that $a$ commute with all of each conjugates of $a$.
Converse:Let $a$ commute with all of its conjugate. i.e $(a)(gag^{-1})=(gag^{-1})(a)$ for all $g \in G$.
Let $N=<gag^{-1}| \forall g \in G>$.
Clearly, $N$ is a normal subgroup of $G$.
Abelian: Let $gag^{-1},hah^{-1} \in N$, then
$(gag^{-1})(hah^{-1})=ga(g^{-1}hah^{-1}g)g^{-1}=g(g^{-1}hah^{-1}g)ag^{-1}=(hah^{-1})(gag^{-1})$.
This implies $N$ is a normal abelian subgroup of $G$.
Is my proof correct?

A: Your proof is essentially correct, as other commenters have pointed out. Mathematically, everything checks out, although there are a few places where you could improve your exposition (or where you need to fix your justification). Read on for my nit-picking!
First, as halrankard says, you reference the object $a$ before you define it. In your starting sentence "Firstly, suppose that $N$ is an Abelian normal subgroup of $G$," you should add something letting the reader know what $a$ is. For example, you might write "Suppose that $N$ is an Abelian normal subgroup of $G$ and let $a\in N.$" It's rude to start talking about your characters before you introduce them!
Second, as Koro pointed out, your reasoning "Now, $a\in N$, and $gag^{-1}\in N,$ this implies $(a)(gag^{-1}) = (gag^{-1})(a)$ (because, $N$ is a normal subgroup of $G$)." is flawed. This equality holds because the subgroup $N$ is Abelian, not because it is normal. (Normality is what implies that $gag^{-1}\in N$ in the first place.)
For the converse, your argument is again correct. However, you might consider elaborating on why $N$ is normal. This is not hard to show, but it's not good practice to claim things are "clear" or "obvious." (Have you read any texts where the author has claimed this about something you thought wasn't? It can be very frustrating and demoralizing!) If it is so obvious, you should be able to justify it quickly.
You might also include a word or two about why to show that $N$ is Abelian it suffices to show that two elements of the form $gag^{-1}$ commute. Again, this is simple to show, but depending on how clear and rigorous you want to be, it might be a helpful detail.
Whether or not you add something like the above depends largely on what the purpose of writing this proof is and who will be reading it. If your reader is supposed to be someone who is new to normal subgroups, this is going to be more important to spell out. If you're writing this as homework for a class, it might be good to include it so that the grader sees all the details and can't complain about anything. If you're writing this for someone who's more familiar with these things or for yourself, it isn't as big of an issue. The larger point is that you should be mindful of your audience and purpose when writing!
Additionally, I would include an extra step in your commutation computation for clarity:
\begin{align*}
(gag^{-1})(hah^{-1})&=ga(g^{-1}hah^{-1}g)g^{-1}\\
&= ga\left((g^{-1}h)a(g^{-1}h)^{-1}\right)g^{-1}\\
&= g\left((g^{-1}h)a(g^{-1}h)^{-1}\right)ag^{-1}\\
&=g(g^{-1}hah^{-1}g)ag^{-1}\\
&=(hah^{-1})(gag^{-1}).
\end{align*}
Finally, you might try to write your proof as a few short paragraphs rather than disjointed sentences/sentence fragments each on their own line. This will help the flow and presentation of your solution. However, mathematically, you're good to go!


text:
Q: How to assign order to elements in a column in R? In the following dataset:
Day   Place   Name
 22     X      A
 22     X      A
 22     X      B
 22     X      A
 22     Y      C
 22     Y      C
 22     Y      D
 23     X      B
 23     X      A

How can I assign numbering to the variable Name in following order using R:
Day   Place   Name  Number
 22     X      A     1
 22     X      A     1
 22     X      B     2
 22     X      A     1
 22     Y      C     1
 22     Y      C     1
 22     Y      D     2
 23     X      B     1
 23     X      A     2

In a nutshell, I need to number the names according to their order to occurrence on a certain day and at a certain place.

A: In base R using tapply:
dat$Number <-
unlist(tapply(dat$Name,paste(dat$Day,dat$Place),
       FUN=function(x){
         y <- as.character(x)
         as.integer(factor(y,levels=unique(y)))
}))

#    Day Place Name Number
# 1  22     X    A      1
# 2  22     X    A      1
# 3  22     X    B      2
# 4  22     Y    C      1
# 5  22     Y    C      1
# 6  22     Y    D      2
# 7  23     X    B      1
# 8  23     X    A      2

idea

*

*Group by Day and Place using tapply

*For each group, create a coerce the Name to the factor conserving the same order of levels.

*Coerce the created factor to integer to get the final result.

using data.table(sugar syntax) :
library(data.table)
setDT(dat)[,Number := {
  y <- as.character(Name)
  as.integer(factor(y,levels=unique(y)))
                   },"Day,Place"]

   Day Place Name Number
1:  22     X    A      1
2:  22     X    A      1
3:  22     X    B      2
4:  22     Y    C      1
5:  22     Y    C      1
6:  22     Y    D      2
7:  23     X    B      1
8:  23     X    A      2

A: idx <- function(x) cumsum(c(TRUE, tail(x, -1) != head(x, -1)))
transform(dat, Number = ave(idx(Name), Day, Place, FUN = idx))

#   Day Place Name Number
# 1  22     X    A      1
# 2  22     X    A      1
# 3  22     X    B      2
# 4  22     Y    C      1
# 5  22     Y    C      1
# 6  22     Y    D      2
# 7  23     X    B      1
# 8  23     X    A      2

A: Use ddply from plyr.
dfr <- read.table(header = TRUE, text = "Day   Place   Name
 22     X      A
 22     X      A
 22     X      B
 22     X      A
 22     Y      C
 22     Y      C
 22     Y      D
 23     X      B
 23     X      A")

library(plyr)
ddply(
  dfr,
  .(Day, Place),
  mutate,
  Number = as.integer(factor(Name, levels = unique(Name)))
)

Or use dplyr, in a variant of beginneR's deleted answer.
library(dplyr)
dfr %>%
  group_by(Day, Place) %>%
  mutate(Number = as.integer(factor(Name, levels = unique(Name))))


text:
Q: TypeError: fn.bind is not a function with Discord.js Guild Member Update Event I am trying to make logs for The GuildMemberUpdate event but whenever I run the code I keep getting. The error is here, I also provided the code within the event. I have updated my node and npm version to the latest but still the same error. I updated my package.json and package-lock.json file aswell but it still give the same error.
TypeError: fn.bind is not a function

A: In version 12, find take a function.
Change
newMember.roles.cache.find('id', value.id)

to
newMember.roles.cache.find(value => value.id == "id")


text:
Q: UITableView begins to execute animation but jumps back to original position I'm writing my first iOS app in objective-c, and I've been scratching my head at this for a few days now. I live on an island off the coast of Maine, and the app I'm designing will allow users (or quite possibly just me) to select an island, select a departure date, and see the corresponding ferry schedule of boats leaving the mainland.
Here's the issue:
In order to display the correct ferry schedule, users have to be able to select the date they want to  depart on and the island they are departing from/headed to. Following the advice given in response to this question, I chose to implement this using a four-row table view positioned just below the nav bar. At all times at least two of those rows are displayed: the dateCell (in row 0) displays which date is currently selected, and the islandCell (in row 2) which displays the currently-selected island. If a user selects the dateCell, row 1 (which contains an inline UIDatePicker) is revealed, allowing them to change the date. Selecting the dateCell again hides the date picker. If a user selects the island cell, row 3 (which contains an inline UIPickerView with a list of all of the available islands) appears, allowing them to change the island. Everything about this process works just fine.
My challenges arose when I decided I wanted that table to remain fixed (not scroll) when a user scrolls down through the schedule displayed below it. I accomplished this by having two table views embedded in the UIView: one for the island/date cells and their pickers, and one for the schedule. Both tables work fine.
The problem is, when the pickers are not being displayed, I would like the schedule table view to cover-up/conceal the wasted real estate in the picker table view. In order to do so I added some animations that I thought would reposition the schedule table view's frame depending on whether the pickers were open or not. It seemed dead simple, however, the animations are not executing the way I expected. They begin to execute and the schedule table view starts to slide up or down accordingly, but the animations always stop abruptly and the schedule jumps back to it's original position. From playing around with the duration of the animations, I believe that it jumps back to its original  position as soon as the animations that reveal the picker views are completed. My problem is that I don't call the picker view animations (they are executed automatically) so I don't know how to access them in order to determine if there is some sort of interference going on.
Here's the method that is hiding and displaying the pickers:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    CGFloat heightForRow = self.pickerTableView.rowHeight;

    if (tableView == self.pickerTableView) {

        // if the index path row is the row of the datePicker (1) or the islandPicker (3), and the    date picker should be shown, return the height for the picker. If it should be hidden, return 0.0
        if (indexPath.row == 1) {

            heightForRow = (self.isDatePickerShown) ? self.pickerCellRowHeight : 0.0;
            return heightForRow;

         } else if (indexPath.row == 3) {

            heightForRow = (self.isIslandPickerShown) ? self.islandPickerCellRowHeight : 0.0;
            return heightForRow;

        } else {

            // else, return the default height for a picker table row
            return heightForRow;
        }

    } else { // the table view must be the schedule table view

        // return the default height for a schedule table row
        return heightForRow;
    }

}

And here's the first part of the method that the schedule table view animations live in:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    // if the selected cell is a date cell
    if (cell.reuseIdentifier == kDateCellID)
    {

        // log the datePicker's indexPath
        NSInteger rowToReveal = indexPath.row + 1;
        self.datePickerIndexPath = [NSIndexPath indexPathForRow:rowToReveal inSection:0];

        // move and animate schedule table view accordingly
        if (self.datePickerIsShown == NO && self.islandPickerIsShown == NO)
        {

            // drop the schedule table view down to accomodate change in picker table view
            CGRect newFrame = self.scheduleTableView.frame;
            newFrame.origin.y += self.pickerCellRowHeight;    // shift down by the height of the date Picker Cell

            [UIView animateWithDuration:0.3
                             animations:^{
                                 self.scheduleTableView.frame = newFrame;
                             }];

            // toggle the date picker to display it
            self.datePickerIsShown = ! self.datePickerIsShown;

        } else if (self.datePickerIsShown == NO && self.islandPickerIsShown == YES){

            // toggle the island picker to hide it
            self.islandPickerIsShown = ! self.islandPickerIsShown;

            // toggle the date picker to display it
            self.datePickerIsShown = ! self.datePickerIsShown;

        } else {

            // the date picker is being retracted, so raise the schedule table view up to conceal bottom of picker table view
            CGRect newFrame = self.scheduleTableView.frame;
            newFrame.origin.y -= self.pickerCellRowHeight;    // shift up by the height of the date Picker Cell

            [UIView animateWithDuration:0.3
                             animations:^{
                                 self.scheduleTableView.frame = newFrame;
                             }];

            // toggle the date picker to hide it
            self.datePickerIsShown = ! self.datePickerIsShown;
        }

        // update pickerTableView
        [tableView beginUpdates];
        [tableView endUpdates];

Has anyone experienced this issue before? Does anyone know what animation is getting called when the UIPickerViews or UIDatePickers are revealed? How do I determine if this is in fact what's causing the schedule table to revert back to it's original position?
I've been banging my head against my desk for three days now. All I want for Christmas is for these animations to do what they're supposed to!
Thanks in advance.
-Nathaniel


text:
Q: Pick color from a pixel in Photoshop cc 2017 How can I pick a color from a pixel in Photoshop cc 2017?
Here is my program view:

A: Eyedropper tool on the left works fine in the situation.
Though note that the eyedropper has sample size, averaging options at the top - so you want Point Sample, rather than a matrix sample.


text:
Q: MS Project Server 2016: create new assignemnt by user using Client Side Object Model (CSOM) Our users (resources) can assign themselves to existing tasks via a custom frontend.
In Project Server 2010 we used the PSI that is no longer supported in the current version.
StatusingClient sc = new StatusingClient(httpBinding, endpointAddress);
sc.CreateNewAssignmentWithWork(parameters);

This assignment-request could then be approved by a projectleader with planning permissions.
We could not find an equivalent method within the CSOM.
Using the CSOM we can only create new assignments as a user with planning permissions (but of course not all users should have those rights).
        DraftProject projectDraft = pubProject.CheckOut();
        projContext.Load(projectDraft.Tasks);
        projContext.ExecuteQuery();

        var task = projectDraft.Tasks.Where(t => t.Id == taskUid).FirstOrDefault();

        if (task != null)
        {
            AssignmentCreationInformation assignment = new AssignmentCreationInformation();

            assignment.Id = Guid.NewGuid();
            assignment.TaskId = task.Id;
            assignment.ResourceId = userRes.Id;
            task.Assignments.Add(assignment);
            projectDraft.Assignments.Add(assignment);
            projectDraft.Update();
        }

        projContext.ExecuteQuery();

        projectDraft.Publish(true);
        projectDraft.CheckIn(true);

        projContext.ExecuteQuery();

Any hints how to solve this task?

A: Contrary to the official documentation, the statusing functionality of the deprecated PSI is still working in 2016. So for us the solution is using the PSI and its StatusingClient as before in 2010 and 2013.
Going the CSOM way, the user who creates a new assignment, has to have edit privileges for the project, since the project has to be checked out and modified.


text:
Q: How to set cookies to switch style sheets when a link is clicked and set it till another particular link is clicked? I have a very old site.
Now I want to make it responsive without changing the theme an it's style sheet.
Requirements:

*

*Can not change the theme.

*Can not create child theme.

*By default, the site should be loaded as non responsive when we
visit.

*When a 'switcher link` is clicked whole site should be responsive.

*When another 'switcher link` is clicked site should be loaded as
default (Non-responsive)

So I have decided to

*

*enqueue a separate style sheet when a switcher link is clicked.
: Link to make the site responsive

*enqueue the default style sheet when another switcher link is
clicked. : Link to switch back to default non-responsive site.

Then I've put following two links into my header.php

I put follwoing code into my functions.php
$site=$_GET['site'];

if ($site == 'mobile'){
    function responsive_css(){
        wp_enqueue_style(
            'wpa_custom',
            get_template_directory_uri() . '/css/responsive.css'
        );
    }
    add_action( 'wp_enqueue_scripts', 'responsive_css', 999 );
}

if ($site == 'desktop'){
    function default_css(){
        wp_enqueue_style(
            'default_css',
            get_template_directory_uri() . '/style.css'
        );
    }
    add_action( 'wp_enqueue_scripts', 'default_css', 999 );
}

and I added a folder called css into my template directory which contains responsive.css.
and then

*

*when I click the mobile link (class=mobile_site) the whole site
becomes responsive. The site link becomes www.mysite.com/?site=mobile

*when I click the desktop link (class=desktop_site) the whole
site becomes non-responsive (default site is loaded with it's default
style.css). The site link becomes www.mysite.com/?site=desktop
VOILA....!!!!
BUT THE ISSUE IS:
After I clicked the mobile link if I visit to other pages / posts the whole site becomes Non-responsive. It is responsive if I am in home page only (After I clicked the mobile link)
For other pages and post I have to click the mobile link AGAIN to make it responsive.
In summary, users have to click the mobile link every time when they visit to a (new) posts / pages if they want the responsive site.
I've realized the issue is I did not set a cookie when the mobile link or desktop link is clicked.
I referred PHP cookies and some other tutorials but could not get it work.
Now the requirements are (with the above mentioned 5 ) :

*the site should be remained responsive after the mobile link (class="mobile_site") is clicked till the desktop link(class="desktop_site") is clicked again.

*cookies need to be deleted when the tab/browser is closed.

How can I do it using PHP?
* PLEASE do not just **down vote and say it's more related to PHP and ask in stack overflow . It's mixed and I ask it here. Rather than just down vote do suggestions please.

A: You can use init action to set  cookie, and other init action to read it. However due its a cookie... you will need also to check GET variable.
add_action('init', 'is_it_mobile_or_desktop', 1);

function is_it_mobile_or_desktop(){
    if (isset($_GET['site']) && in_array($_GET['site'], array('mobile', 'desktop')) ) {
        setcookie( 'site', $_GET['site'], time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
    }
}

add_action('init', 'who_am_i', 2);
function who_am_i(){

    $site = isset($_GET['site']) && in_array($_GET['site'], array('mobile', 'desktop')) ?  $_GET['site']
            : (isset($_COOKIE['site']) && in_array($_COOKIE['site'], array('mobile', 'desktop'))  ? $_COOKIE['site'] : 'default_case');

    if ($site == 'mobile'){
        function responsive_css(){
            wp_enqueue_style(
                'wpa_custom',
                get_template_directory_uri() . '/css/responsive.css'
            );
        }
        add_action( 'wp_enqueue_scripts', 'responsive_css', 999 );
    } else {
        function default_css(){
            wp_enqueue_style(
                'default_css',
                get_template_directory_uri() . '/style.css'
            );
        }
        add_action( 'wp_enqueue_scripts', 'default_css', 999 );
    }
}


text:
Q: Is it possible to edit public google sheet in node.js using google sheet url? I want to edit google sheet in node.js.
But I have only google sheet url.
in this case it is possible to edit google sheet in node.js ?

A: Sure, if you have the right permissions, There is an api for this and even KIT : https://github.com/theoephraim/node-google-spreadsheet


text:
Q: ember relationship as promises I have two related models:
//models/school.js
import DS from 'ember-data';
import { belongsTo } from 'ember-data/relationships';
import { hasMany } from 'ember-data/relationships';

export default DS.Model.extend({
    name: DS.attr('string'),
    zipCode: DS.attr('string'),

    kids: hasMany('kid',{inverse: 'schoolId',async:true}),
    district: belongsTo('district',{inverse:'schools',async:true}),
    grades: hasMany('grade',{inverse: 'schools'}),
});

//models/district.js
import DS from 'ember-data';
import { hasMany } from 'ember-data/relationships';

export default DS.Model.extend({

      name: DS.attr('string'),
      zipCode: DS.attr('string'),
      schools: hasMany('school',{inverse: 'district',async:true}),
});

Accordind to the documentation https://guides.emberjs.com/v2.2.0/models/relationships/#toc_relationships-as-promises , when I try to get the district by the school, sometimes the district returns null like the school werent related to any district, but all schools are related to the district. I don't understand this.
//routes/kid-info.js

import Ember from 'ember';

export default Ember.Route.extend({

setupController(controller,model){ //the model is kid
    this._super(controller,model);
    controller.set('districts',this.store.findAll('district'));
    controller.set('schools',this.store.findAll('school'));
    controller.set('grades',this.store.findAll('grade'));
    var schoolId=model.get('schoolId.id');
    controller.set('selectedSchool',model.get('schoolId'));
    let school=this.store.peekRecord('school',schoolId);
    if(school){
        school.get('district').then((district)=>{
            controller.set('selectedDistrict',district); //the district is sometimes null
        });
      }

},

UPDATE
Following @Thernys suggestions I have changed the route like this:
import Ember from 'ember';

export default Ember.Route.extend({

setupController(controller,model){
    this._super(controller,model);

    controller.set('districts',this.store.peekAll('district'));
    controller.set('schools',this.store.peekAll('school'));
    controller.set('grades',this.store.peekAll('grade'));

    controller.set('selectedSchool',model.get('schoolId'));

    model.get('schoolId.district').then(function(district) {
     controller.set('selectedDistrict',district);
    });

},

but I'm still having the same result. It's like the school isn't correctly related to the district. JIC I'm loading the schools and districts before the setup controller call.

A: This end up resolving my problem:
model.get('schoolId').then(function(school) {
        controller.set('selectedDistrict',that.store.peekRecord('district',school.get('district_id')));
    });


text:
Q: git HEAD detached *from* vs detached *at* I am NOT new to git. I know what a detached HEAD is and that I can just checkout a new branch to move forward. But today I saw a detached from message instead of a detached at message. While trying to abort a merge in a repo with 2 submodules, one of my submodules got stuck in this state:
so_is_my_nacho_cheese$ git status

HEAD detached from 9733eeb0
nothing to commit, working tree clean

Question 1:
The from part is throwing me off. I am used to seeing at. What does this commit refer to? Is this the last place the HEAD was before being moved to a branchless commit? In my case, that commit is in the submodule reflog, but it's 7 layers down at HEAD@{7}. That doesn't seem like the last place the HEAD was. But because this was result of an aborted merge in the parent module, maybe the tracing of the HEAD's movement is inscrutable for that reason. What does this detached from commit usually refer to?
Question 2:
To add to my confusion, according to git log, my HEAD is pointing at a branch in the submodule:
so_is_my_nacho_cheese$ git log --graph --oneline -n 5

* ba737d3b (HEAD, xdhmoore_pascal) Just to record pascal run
* 5b69ce96 Fix fine_tune_checkpoint_loading
* 21dc78b2 Just docker changes applied to base
* 9733eeb0 (xdhmoore_base) Updating center_net_mobilenet_v2_fpn_feature_extractor to support classification finetuning.
* 63ec7359 Adding float feature to dataset_util

Why does git status tell me my HEAD is detached (from 9733eeb0, though not at what commit) while git log says it's pointed at ba737d3b?

A: When the detached HEAD points at the commit from which it was first checked out, git status says detached at <the_base_commit>. If then you make new commits or use git reset to move HEAD to another commit, for example to its parent, git status says detached from <the_base_commit>. And if then you reset HEAD back to the base commit, git status says detached at <the_base_commit> again.
The base commit is recorded in HEAD's reflog, in .git/logs/HEAD. If you remove .git/logs/HEAD, git status says Not currently on any branch because it cannot find the base commit now.

A: A key item I was missing in my understanding is that you can still have a detached HEAD while pointing to a commit with a branch on it. If you are not detached, the log will show HEAD ->  with an arrow:
detached:
so_is_my_nacho_cheese$ git log -n 1 --oneline --graph

* ba737d3b (HEAD, xdhmoore_pascal) Just to record pascal run

not detached:
so_is_my_nacho_cheese$ git log -n 1 --oneline --graph

* ba737d3b (HEAD -> xdhmoore_pascal) Just to record pascal run


text:
Q: Keystore in PKCS12 format seems empty to keytool, but is read by Firefox? I have a problem with a keystore in pkcs12 format, which contains a private key I need to use to authenticate myself (using mutual authentication) to a remote SSL server.  The keystore file can be read perfectly fine by Firefox, and when used, I can access the remote server without problems.
However, my Java program does not work with the keystore file. And if I use keytool to list keys inside the file, it seems empty -- while it is clearly not!
How can I get Java/keytool to see the private key inside the keystore?

A: Java can only understand JKS format which stands for Java KeyStore.
Here is a good article to generate the .jks from pkcs12
http://blog.asyd.net/2009/07/how-to-convert-a-pkcs12-to-jks/


text:
Q: Filter + - values and plot R I have a dataframe that I have done the following on:
PC2_filter <-samples %>%
  select(predicted, PC2) %>%
  filter(predicted == 'EUR') %>%
  summarise(mean = mean(PC2), sd=sd(PC2), sd2=2*sd(PC2), sd3=3*sd(PC2))

This is to get both 2 standard deviations and 3 standard deviations from the mean. I have also done this for another variable (PC1):
PC1_filter <-samples %>%
  select(predicted, PC2) %>%
  filter(predicted == 'EUR') %>%
  summarise(mean = mean(PC1), sd=sd(PC1), sd2=2*sd(PC1), sd3=3*sd(PC1))

So the resulting table will look something like this:
mean   sd     sd2     sd3
9.24  1.73    3.47   5.21

I want to then use these dataframes to select values that are within this range from my main data. For example if sd3 = 3 and the mean was 0, I would like to select values that are within the range -3 to +3.
I hope that makes sense. An example data set is below:
sample_id   predicted   PC1   PC2
A           EUR         2     3
B           EUR         5     7
C           EUR         4     6
D           USA         -3     4
E           EUR         12     3
F           EUR         2     -10
G           EUR         -2     5
H           EUR         4     2

I have tried the following but it seems to not be selecting all the samples that fall into the desired range:
selected <- filter(samples, !PC1 >= (PC1_filter$mean +- PC1_filter$sd3) & !PC2 >= (PC2_filter$mean +- PC2_filter$sd3))

Any help would be greatly appreciated as I am relatively new to R.
Let me know if you need better examples. Thanks

A: +- is not proper R syntax, not for what you want it to be.
Perhaps something like:
samples %>%
  filter(
    between(PC1, PC1_filter$mean - PC1_filter$sd3, PC1_filter$mean + PC1_filter$sd3),
    between(PC2, PC2_filter$mean - PC2_filter$sd3, PC2_filter$mean + PC2_filter$sd3)
  )


text:
Q: Must an LCD panel meet specific requirements to support a higher refresh rate? Newer LCDs can refresh the screen at 120Hz or higher. The driver circuitry for the panel is responsible for pushing frames to the panel at a given rate, but are there any particulars of the LCD panel itself that factor into achieving the higher refresh rate? Are there, for instance, any special materials, construction, or circuitry of the panel needed to correctly respond to a higher refresh rate? In other words, is it theoretically possible to drive a panel over its specified refresh rate using another driver board, assuming all interfacing requirements are identical?

A:
The driver circuitry for the panel is responsible for pushing frames to the panel at a given rate, but are there any particulars of the LCD panel itself that factor into achieving the higher refresh rate?

Since the panels are big 2D arrays of pixels addressed similarly to a DRAM cell, the LCD itself must be able to clock at the pixel rate you're driving.  If its internal capacitances are too large or its transistors too slow, there won't be time for the pixel to update before the next value is driven into the array.
In addition, since the pixel array is essentially an optical digital to analog converter, there are also sampling rate concerns.  Driving the array at a higher pixel rate is equivalent to increasing the temporal sampling rate driving each pixel.  Increasing the update rate while keeping the analog impulse response of each pixel unchanged is equivalent to increasing the sampling rate of a DAC without also adjusting the analog bandwidth of the electronics it is driving.  Eventually your analog bandwidth falls far enough below the Nyquist (folding) frequency that although you are updating the pixels more frequently, no new information is actually being modulated onto the pixel output because it simply cannot respond faster (even if the array itself can physically sustain the pixel rate).
So yes, there are two factors.  The array must be able to shift values at the pixel rate you've selected and the pixels themselves must be fast enough (have sufficient bandwidth) that the faster refresh rate actually does something.

In other words, is it theoretically possible to drive a panel over its specified refresh rate using another driver board, assuming all interfacing requirements are identical?

Yes, and you do occasionally see manufacturers offering displays at refresh rates above the nominal spec value for the panel they are using.


text:
Q: Are These For Memory Leak Warnings In my log cat i see too much warnings like this;

05-11 23:21:44.225: D/dalvikvm(7578): GC_EXTERNAL_ALLOC freed 11K, 47%
  free 2881K/5379K, external 11655K/11801K, paused 39ms 05-11
  23:21:44.300: D/dalvikvm(7578): GC_EXTERNAL_ALLOC freed 2K, 47% free
  2880K/5379K, external 10083K/10303K, paused 22ms 05-11 23:21:44.360:
  D/dalvikvm(7578): GC_EXTERNAL_ALLOC freed 1K, 47% free 2880K/5379K,
  external 10083K/10303K, paused 22ms 05-11 23:21:44.415:
  D/dalvikvm(7578): GC_EXTERNAL_ALLOC freed <1K, 47% free 2879K/5379K,
  external 10083K/10303K, paused 23ms 05-11 23:21:44.480:
  D/dalvikvm(7578): GC_EXTERNAL_ALLOC freed <1K, 47% free 2880K/5379K,
  external 10009K/10262K, paused 23ms 05-11 23:21:44.555:
  D/dalvikvm(7578): GC_EXTERNAL_ALLOC freed 1K, 47% free 2879K/5379K,
  external 10681K/10938K, paused 22ms

are these warning about memory leak or just warning?
I tested my app at two different device. One of them give these debug warning (Samsung Galaxy Note) other one is (Samsung Galaxy Mini) doesnt. Is this difference between two device normal?

A: Here is an answer about Dalvik garbage collector messages.

I tested my app at two different device. One of them give these debug warning
   (Samsung Galaxy Note) other one is (Samsung Galaxy Mini) doesnt.
       Is this difference between two device normal?

I think it is normal because some handsets i work with gives theese logs too while some others dont

A: "GC_EXTERNAL_ALLOC freed" just means that the Garbage Collector has freed an external memory allocation. This has nothing to do with memory leaks :-)


text:
Q: How to scroll a fixed area only, not the whole page onClick? Basically, I have a fixed position div that I need to scroll on click but not the whole page. There is a div containing a list of items and up/down buttons to the right of it. The page itself does not scroll but the div of items can scroll (overflow-y: scroll) and I want to do that on a click. Is there a way to do this? Sorry if my question is not clear enough!
Edit:
Here is a link to a fiddle: https://jsfiddle.net/yjphLeg0/4/
When the 'up' button is clicked I want the div with and id of 'div' to scroll up and the same for the 'down' button and down.

A: function move_down() {
document.getElementById('mydiv').scrollTop += 10;
}

function move_up() {
document.getElementById('mydiv').scrollTop -= 10;
}

trigger functions with your up/down buttons.

A: function scrollWithin(wrapperElementId, innerElementId) {
  // get the inner element
  var innerElement = document.getElementById(innerElementId);
  // calculate the offset top to to wrapper element plus the element height
  var topPos = innerElement.offsetTop + (innerElement.offsetHeight / 2);
  // zoom the wrapper element to the inner element
  document.getElementById(wrapperElementId).scrollTop = topPos;
}

scrollWithin('scrollable', 'item3');

hope I got your point. Here is a fiddle to test: https://jsfiddle.net/ukhzxs59/


text:
Q: How to convert dataframe to trianing data for spacy? I have a data frame df which needs to be converted into spacy's training data format.
my dataframe df is
df = pd.DataFrame({'Names':['LSCS', 'SVD', 'URTI']})
df['start'] = 0
df['end'] = df['Names'].apply(lambda x: len(x))

I need to convert above df  to following list format which will be used to train spacy NER model.
TRAIN_DATA = [
    ("LSCS", {"entities": [(0, 4, "ENTITY")]}),
    ("SVD", {"entities": [(0, 3, "ENTITY")]}),
    ("URTI", {"entities": [(0, 4, "ENTITY")]}),]

I have tried the following code, but could not accomplish the required output
List =  []
for index, rows in df.iterrows():
    my_list = [rows.start, rows.end]
    List.append(my_list)
    my_list.append('entity')
print(List)

List_tuple  = [tuple(l) for l in List]

A: You can try with apply then series.tolist()
df['Names'].apply(lambda x: (x,{'entries':[(0,len(x),'ENTITY')]})).tolist()

[('LSCS', {'entries': [(0, 4, 'ENTITY')]}),
 ('SVD', {'entries': [(0, 3, 'ENTITY')]}),
 ('URTI', {'entries': [(0, 4, 'ENTITY')]})]


text:
Q: Login Button on Navbar going out of Place I made a navbar for my application and implemented login button for it but it is shifted towards the right and not displaying properly, i have already tried changing the padding and the margins but that did not help.
Navbar before login
Navbar after login
and i am hiding and showing the div on successful signin. How can i insert it properly, so that it shows up in a decent manner and does not escape out from the right. Also any suggestions on adding any color behind the navbar would be a great welcome.

/* GLOBAL STYLES
-------------------------------------------------- */
/* Padding below the footer and lighter body text */

body {
  color: #5a5a5a;
}

/* CUSTOMIZE THE NAVBAR
-------------------------------------------------- */

/* Special class on .container surrounding .navbar, used for positioning it into place. */
.navbar-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
}
.alignr{
  margin-right: 20px;
}

/* Flip around the padding for proper display in narrow viewports */
.navbar-wrapper .container {
  padding-left: 0;
  padding-right: 0;
}
.navbar-wrapper .navbar {
  padding-left: 15px;
  padding-right: 15px;
}

/* CUSTOMIZE THE CAROUSEL
-------------------------------------------------- */

/* Carousel base class */
#mainCarousel .carousel {
  height: 450px;
  interval: 1000;
}
/* Since positioning the image, we need to help out the caption */
#mainCarousel  .carousel-caption {
  z-index: 10;
}

/* Declare heights because of positioning of img element */
#mainCarousel  .carousel .item {
  height: 450px;
  background-color: #777;
}
#mainCarousel  .carousel-inner > .item > img {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  height: 450px;
}

/* MARKETING CONTENT
-------------------------------------------------- */
#firebaseui-auth-container{
  padding: 0 auto;
  margin-top: 0;
  margin-bottom: 0;
  max-height: 15px;

}

.dropdown-toggle{
  padding: 0 auto;
  margin-top: 0;
  margin-bottom: 0;
  max-height: 15px;
}

/* Pad the edges of the mobile views a bit */
.marketing {
  padding-left: 15px;
  padding-right: 15px;
}

/* Center align the text within the three columns below the carousel */
.marketing .col-lg-4 {
  text-align: center;
  margin-bottom: 20px;
}
.marketing h2 {
  font-weight: normal;
}
.marketing .col-lg-4 p {
  margin-left: 10px;
  margin-right: 10px;
}

/* Featurettes
------------------------- */

.featurette-divider {
  margin: 80px 0; /* Space out the Bootstrap
 more */
}

/* Thin out the marketing headings */
.featurette-heading {
  font-weight: 300;
  line-height: 1;
  letter-spacing: -1px;
}

/* Custom CSS =========================================== */
.navbar-inverse {background-color: #efefef; border-color: #FF5200;}
.navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:hover, .navbar-inverse .navbar-nav>.open>a:focus,
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:hover, .navbar-inverse .navbar-nav>.active>a:focus {color: #fff; background-color: #c83a3a;}
.navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus {background-color: #e4dcd2;}
.navbar-inverse .navbar-toggle {border-color: #c83a3a;}
.navbar-inverse .navbar-nav > li > a{color:#000}
.navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus{color:#C83A3A}
a{color:#fff}
a:hover{color:#eee}
.marketing img{max-width:100%}
.carousel-caption {color: #000000;}
.carousel-caption  h1{background-color: #eb4800;color: #fff;display:inline-block;padding:4px 18px; width: auto;-ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=80)';opacity: 0.8;}
.dsc {background-color: #757575;color: #fff;display: inline-block;padding: 4px 18px; width: auto;-ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=80)';opacity: 0.8;}
.highlightSection{padding:28px 0}
.highlightSection img{padding:0 0 28px 0}
.highlightSection .media{background-color: #efefef;border: 1px solid #efefef;color: #939393;padding: 10px;text-align: center;}
.introSection{background-color: #efefef; padding:28px 0}
.brandBtn{background-color: #7db641;}
.btn-default{color: #fff;background-color: #7db641;border-color: #7db641;border-radius:0}
.btn-default.active, .open .dropdown-toggle.btn-default, .btn-default:hover, .btn-default:focus, .btn-default:active {color: #fff;background-color: #c83a3a ;border-color: #c83a3a ;}
.text-primary-theme {color: #7db641;}
.text-danger-theme {color: #FF007A;}
.carousel-control.right, .carousel-control.left,
#myCarousel1 .carousel-control.right, #myCarousel1 .carousel-control.left,
#myCarousel2 .carousel-control.right, #myCarousel2 .carousel-control.left {background: none;color: #057C00;font-size: 3em; width: 6%;}
.itemsTitle{border-bottom: 1px solid #e7e7e7;padding: 8px 30px;font-size: 20px;text-transform: uppercase;position: relative;margin-bottom: 20px;text-align:center}
#myCarousel .container{padding:0}
#mainCarousel .carousel .item {height: 450px;background-color: #FFF;}
footer{padding:18px 0; background:#111; color:#fff;}
.marketing{padding:28px 0}
.pageTitle{padding:18px 0; border-top:1px solid #efefef; margin-top:92px; background:#efefef}
.pageTitle h2{padding:0; margin:0}
.bodyInner{padding:28px 0}
.carousel-caption {bottom: 61px;}
.mainTitle {padding: 4px 0;border-top: 1px solid #FF8500;background: #FAFAFA;color: #0C0C0C;text-align: center;box-shadow: 0 0 24px #D5D5D5;}
.cntr{text-align:center}

/* RESPONSIVE CSS
-------------------------------------------------- */

@media (min-width: 768px) {

  /* Remove the edge padding needed for mobile */
  .marketing {
    padding-left: 0;
    padding-right: 0;
  }
  /* Navbar positioning foo */
  .navbar-wrapper {
    margin-top: 20px;
  }
  .navbar-wrapper .container {
    padding-left:  15px;
    padding-right: 15px;
  }
  .navbar-wrapper .navbar {
    padding-left:  0;
    padding-right: 0;
  }

  /* The navbar becomes detached from the top, so we round the corners */
  .navbar-wrapper .navbar {
    border-radius: 4px;
  }

  /* Bump up size of carousel content */
  .carousel-caption p {
    margin-bottom: 20px;
    font-size: 21px;
    line-height: 1.4;
  }

  .featurette-heading {
    font-size: 50px;
  }

}

@media (min-width: 992px) {
  .featurette-heading {
    margin-top: 120px;
  }
}
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="themes/assets/ico/favicon.ico">
    <title>Bazinga</title>

    <link href="themes/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="themes/assets/css/carousel.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                Toggle navigation

              </button>
              Bazinga

Home

About Us

Contact

                  <button type="button" class="btn btn-primary" id="glogin" onclick="signIn();">Sign-In With Google</button>

My Orders

My Address

Signout

Edit 1: if you want more code then you can see a hosted copy here link
Edit 2: As suggested by Ash the following code centers it as in here but it is still off the edge and i also tried margin-right:90px but it did not help.
.navbar-right{
margin-right:45px;
line-height:48px;
}

A: Hope this will help
.navbar-right{
margin-right:45px;
line-height:48px;
}


text:
Q: Change pa$$word to pa\$\$word in Python I have a string pa$$word. I want to change this string to pa\$\$word. This must be changed to 2 or more such characters only and not for pa$word. The replacement must happen n number of times where n is the number of "$" symbols. For example, pa$$$$word becomes pa\$\$\$\$word and pa$$$word becomes pa\$\$\$word.
How can I do it?

A: I believe the regex you're after is:
[$]{2,}

which will match 2 or more of the character $

A: import re

def replacer(matchobj):
    mat = matchobj.group()
    return "".join(item for items in zip("\\" * len(mat), mat) for item in items)

print re.sub(r"((\$)\2+)", replacer, "pa$$$$word")
# pa\$\$\$\$word

print re.sub(r"((\$)\2+)", replacer, "pa$$$word")
# pa\$\$\$word

print re.sub(r"((\$)\2+)", replacer, "pa$$word")
# pa\$\$word

print re.sub(r"((\$)\2+)", replacer, "pa$word")
# pa$word

((\$)\2+) - We create two capturing groups here. First one is, the entire match as it is, which can be referred later as \1. The second capturing group is a nested one, which captures the string \$ and referred as \2. So, we first match $ once and make sure that it exists more than once, continuously by \2+.
So, when we find a string like that, we call replacer function with the matched string and the captured groups. In the replacer function, we get the entire matched string with matchobj.group() and then we simply interleave that matched string with \.

A: this should help
  import re

  result = re.sub("\$", "\\$", yourString)

or you can try
 str.replace("\$", "\\$")


text:
Q: How to make a javascript class array? I'm trying to start a class-type arerglo in javascrip so I can call on my vuejs components my code:
Class Person
export default class Person {

constructor(id, nombre, apellido) {
    this.id = id;
    this.nombre = nombre;
    this.apellido = apellido;
  }
}

PersonServicesClass:

import Person from '../model/person'

export default class PersonService {
person = new Array(Person)

constructor(
) {
    this.person = [];
}

add(id, nombre, apellido) {
    this.person.push(new Person(id, nombre, apellido));
    return this.person
  }
}

Import component vue:
 <script>
 import PersonService from "../../Services/personservice";
 export default {
   name: "RegistroComponent",
     data: () => ({}),

     getData() {
       this.PersonService.add(1,"Steven","Chacon");
        }
     };

Error:

I would be very helpful to help

A: Delete the line person = new Array(Person)

A: Person class in JS:
var Person = function (firstname, lastname, age) {
  this.firstName = firstname;
  this.lastName = lastname;
  this.age = age;

  this.setAge = function (age) {
    this.age = age;
  };

  this.toString = function () {
    return ["Hi ! I'm ", this.firstName, " ", this.lastName, " and I'm ", this.age, " year old."].join("");
  };
};

or using Object.prototype
var Person = function (firstname, lastname, age) {
  this.firstName = firstname;
  this.lastName = lastname;
  this.age = age;
};

// Prototypes are better for performances if you have many call of this method
Person.prototype.setAge = function (age) {
  this.age = age;
};

Person.prototype.toString = function () {
  return ["Hi ! I'm ", this.firstName, " ", this.lastName, " and I'm ", this.age, " year old."].join("");
};

Here is a working PEN: CodePen

A: In PersonServicesClass you have written
  person = new Array(Person)

Inside of constructor you wrote
  this.person = [];

These both are conflicted. so please delete
  person = new Array(Person)

Hopefully It will work perfectly.


text:
Q: Drupal 7 - fatal error passing a variable from custom module to a template I am porting a module from Drupal 6 to Drupal 7 and I am trying to pass a variable from my custom module to a template. I have something like this:
function my_callback_function(){

  ... //some unrelated code

  $page_params = array();
  $page_params['items_per_page'] = 25;
  $page_params['page'] = $_GET['page'] ? $_GET['page'] : 0;
  $page_params['total_items'] = $data_provider->getNumItems();
  $page_params['total_pages'] = $data_provider->getNumPages($page_params['items_per_page']);

  return theme('my_theme', $page_params);
}

function my_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_theme' => array(
      'variables' => array('page_params' => NULL),
      'template' => 'theme/my_template_file',
    ),
  );
}

And inside *my_template_file.tpl.php* I try to use $page_params:
<?php print $page_params['total_items']; ?>

All that make my site to throw the following error:

Fatal error: Unsupported operand types in
  C:...\includes\theme.inc on line 1075

Which corresponds with these lines of code in theme.inc:
// Merge in argument defaults.
  if (!empty($info['variables'])) {
    $variables += $info['variables']; // THIS IS THE VERY EXACT LINE
  }
  elseif (!empty($info['render element'])) {
    $variables += array($info['render element'] => array());
  }

If I leave the theme() call as it was in Drupal 6, the error doesn't appear but then my template doesn't recognize my $page_params variable:
  return theme('my_theme', array('page_params' => $page_params));

I have read half the API trying to figure out what I am doing wrong but as far as I have read, it seems that this is the proper way to pass variables from a custom module to a template.
Thus, any kind of help will be more than welcome.
Thanks in advance.

A: Finally, I figured out what I was doing wrong. In fact, they were a couple of things:
My theme() call was ok:
return theme('my_theme', $page_params);

But my hook_theme implementation wasn't. If $page_params is my array of variables, i cannot use the whole array as a variable, I have to explicitly specify which are my variables inside the array. Something like this:
function my_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_theme' => array(
          'variables' => array(
            'items_per_page' => NULL,
            'page' => NULL,
            'total_items' => NULL,
            'total_pages' => NULL,
          ),
    'template' => 'theme/my_template_file',
  );
}

And finally, inside my_template_file.tpl.php I will have to use the variable names directly instead of using them as a component of $page_params:
<?php print $total_items; ?>

It may seem obvious for experienced users but it took me a while until I realized this. I hope it can be useful for other beginners like me.

A: You can use drupal variable_set() and variable_get() to store data in drupal session and get data from session.
Thanks


text:
Q: i am learning python so wrote this small code to add 2 images with ROI but it is showing me error I have wrote a code which i copied from internet while learning open cv but when i run this code it is showing me some errors i don't know how to fix it
import cv2
import numpy as np

# Load two images
img1 = cv2.imread('car.png')
img2 = cv2.imread('coca cola.png')

# I want to put logo on top-left corner, So I create a ROI
rows,cols,channels = img2.shape
roi = img1[0:rows, 0:cols ]

# Now create a mask of logo and create its inverse mask also
img2gray = cv2.cvtColor(img2,cv2.COLOR_BGR2GRAY)
ret, mask = cv2.threshold(img2gray, 10, 255, cv2.THRESH_BINARY)
mask_inv = cv2.bitwise_not(mask)

# Now black-out the area of logo in ROI
img1_bg = cv2.bitwise_and(roi,roi,mask = mask_inv)

# Take only region of logo from logo image.
img2_fg = cv2.bitwise_and(img2,img2,mask = mask)

# Put logo in ROI and modify the main image
dst = cv2.add(img1_bg,img2_fg)
img1[0:rows, 0:cols ] = dst

cv2.imshow('res',img1)
cv2.waitKey(0)
cv2.destroyAllWindows()

it is showing me this error
> Traceback (most recent call last):   File "D:/Python codes/put one
> image on other.py", line 18, in <module>
>     img1_bg = cv2.bitwise_and(roi,roi,mask = mask_inv) cv2.error: OpenCV(3.4.3)
> C:\projects\opencv-python\opencv\modules\core\src\arithm.cpp:241:
> error: (-215:Assertion failed) (mtype == CV_8U || mtype == CV_8S) &&
> _mask.sameSize(*psrc1) in function 'cv::binary_op'


text:
Q: VS 2014 CTP doesn't recognize namespaces in mscorlib I installed vs 2014 ctp 3 in my windows 8.1 virtual machine. And try to create a vnext library.
As I add using statement in my codes:
using System.Diagnostics;
using System.Threading.Tasks;

public Task Log(LogLevel level, IFormatProvider formatProvider, string message, params object[] args)
{
    return Task.Run(() =>
    {
        if (IsLogLevelEnabled(level))
        {
            string category = Enum.GetName(typeof(LogLevel), level);
            string info = string.Format(message, args);
            Debugger.Log((int)level, category, info);
        }
    });
}

There did come the code intelligence by "Debugger.Log", which may mean that the vs find the references in mscorlib. And if I press "F12", vs will navigate to the codes of Debugger in mscorlib.dll. However, when I try to build the projects, it always throws:
The name "Debugger" doen't in the current context.
I tried to add reference in project.json, however, there is no "System.Diagnostics" for reference. If I wrote "System.Diagnostics": "" in project.json, there comes a warning in the references of project.
What should I do? Thank you in advance.

A: If you have the default project.json given by the CTP3 templates you have the k10 (CoreCLR) target framework defined, as well as good old net451. The Debugger class does not have that method (don't ask me why) in the k10 target framework, and thus will not build. Remove the k10 target from your project.json and it will build, but now only towards net451.
Your project always builds towards net451 though, VS14 does not give you a good way to see which target framework is failing. Hopefully they add this functionality soon.
This project.json builds:
{
    "dependencies": {
        "System.Diagnostics": "",
        "System.Threading": ""
    },

    "frameworks" : {
        "net451" : {
            "dependencies": {
            }
        }
    }
}

This does not build:
{
    "dependencies": {
        "System.Diagnostics": "",
        "System.Threading": ""
    },

    "frameworks" : {
        "net451" : {
            "dependencies": {
            }
        },
        "k10" : {
            "dependencies": {
                "System.Runtime": "4.0.20.0"
            }
        }
    }
}


text:
Q: Encoding all subtypes with prepopulated field with Circe I'd like to be able to add a field to certain case classes when they are encoded in JSON vis circe.
e.g.
trait OntologyType {
  val ontologyType: String = this.getClass.getSimpleName
}
case class Thing(i: Int) extends OntologyType

val thing = Thing(23)

println(t.toJson) // 1

case class Thingy(s: Srtring, i: Int) extends OntologyType
val thingy = Thingy("Hi there", 23)

println(t.toJson) // 2

I'd like to find a way for the above to return
{ "i": 23, "type": "Thing" } // 1
{ "s": "Hi there", "i": 23, "type": "Thingy" } // 2

The closest I have got is making all OntologyTypes render their type, but need to somehow mixin the standard case class encoding too:
implicit def encodeUser[T <: OntologyType]: Encoder[T] =
      Encoder.forProduct1("type")(u => (u.ontologyType))

A: Try
implicit def encodeUser[T <: OntologyType](implicit enc: DerivedObjectEncoder[T]): Encoder[T] =
  u => enc.encodeObject(u).add("type", u.ontologyType.asJson).asJson

Imports:
import io.circe._
import io.circe.generic.encoding.DerivedObjectEncoder
import io.circe.syntax._


text:
Q: How can I select a sqlite column with multiple lines in bash? I have a sqlite database table with three columns that is storing Name, Location, and Notes. It appears that everything is stored correctly, as when using the sqlite command line I see the correct number of columns and the data is grouped correctly.
The problem comes when using a bash script (this is a requirement) to access the data. The "Notes" column stores data that can potentially be multiple lines (with newlines and such). When I query this table, using something like the following:
stmt="Select name, location, notes from t1"
sqlite3 db "$stmt" | while read ROW;
do
  name=`echo $V_ROW | awk '{split($0,a,"|"); print a[1]}'`
  location=`echo $V_ROW | awk '{split($0,a,"|"); print a[2]}'`
  notes=`echo $V_ROW | awk '{split($0,a,"|"); print a[3]}'`
done

I end up with everything normal until the first newline character in the notes column.  After this, each note line is treated as a new row. What would be the correct way to handle this in bash?

A: Since the data is pipe separated, you can do this (untested): read each line into an array; check the size of the array

*

*if 3 fields, then you have a row from the db, but the notes field may be incomplete. Do something with the previous row, which by now has a complete notes field.

*if 1 field found, append the field value to the current notes field.

  sqlite3 db "$stmt" | {
    full_row=()
    while IFS='|' read -ra row; do
      if [[ ${#row[@]} -eq 3 ]]; then
        # this line contains all 3 fields
        if [[ ${#full_row[@]} -eq 0 ]]; then
           : # "row" is the first row to be seen, nothing to do here
        else
           name=${full_row[0]}
           location=${full_row[1]}
           notes=${full_row[2]}
           do_something_with "$name" "$location" "$notes"
           #
           # not necessary to use separate vars
           # do_something_with "${row[@]}"
        fi
        # then store the current row with incomplete notes
        full_row=( "${row[@]}" )
      else
        # only have notes.
        full_row[2]+=" "${row[0]}
      fi
    done
  }

You better takes steps to ensure the notes field does not contain your field separator (|)


text:
Q: return value of sizeof I have this XDR struct:
struct Response {
    bool_t error;
    float result;
};
typedef struct Response Response;

And in my main:
Response y;
y.result = 5.7;
y.error = 0;
fprintf(f,"y.error's size: %d bit\n",sizeof(y.error));

I obtain in my txt file:
y.error's size: 0 bit

MORE:
I have created an XDR struct (struct Response) with rpcgen. I send this struct to a client with a socket:
XDR xdrs_w;
Response y;

FILE *stream_socket_w = fdopen(s, "w"); /* s is socket's file descriptor */
xdrstdio_create(&xdrs_w, stream_socket_w, XDR_ENCODE);

y.result = 6.8;
y.error = 0; /* false */

if(!xdr_Response(&xdrs_w, &y)){
  printf("Error");
}

fflush(stream_socket_w);

The problem is with xdr_Response function. So I think that the mistake is in y.error = 0

A: #include <stdio.h>

typedef unsigned char bool_t;

struct Response {
  bool_t error;
  float result;
};
typedef struct Response Response;

int main(int argc, char *argv[]) {
  Response r;

  r.result = 5.7;
  r.error = 0;

  printf("y.error's size: %zu bytes\n", sizeof(r.error));

  return 0;
}

Works for me as expected. bool_t is not standard type so I typedef'd it. Also remember, on 64bit platform sizeof() returns unsigned long, so you need to use %ld in your fprintf function.


text:
Q: How to make ToC ignore a chapter? I am writing a report. There is a page with my abstract, which I don't want to appear in the ToC.
I start the abstract.tex file with the following command:
\chapter{Abstract}

In my main.tex file, I input it using the following command:
\begin{document}
...
\input{abstract}
\tableofcontents
\input{Chapter1}
...
\end{document}

All of my other chapters are added using the \input{} command.
The problem is that the abstract chapter is presented in my ToC, which I do not want it to. Any suggestions on how to fix this?
p.s. I am not that experienced with latex. I just gave the code that I think is relevant. If more pieces of code are needed, let me know.

A: The answer @PhelypeOleinik gave worked.
Just use:
\chapter*{Abstract}


text:
Q: Is it possible to set the axios header according to the base_url set in webpack.config.js I am new to using Axios configuration. So I am wondering if it is possible to set axios header dynamically, based on the baseUrl is calling in api
Takes an example of my current api calling
// this api is calling
export const getMath = async () => {
// it will expire every hour
  const accessToken = await instance.get('https://math-service.fuelcompany.net/access_token')
  const { access_token } = accessToken.data
  instance.defaults.headers.common['Authorization'] = `bear ${access_token}`

  const response = await instance.get(
    `/sas/`
  )
  return response.data
}

Right now, I have to call my token manually based on what domain I am calling, also with the fact that it will expire every hour
but I want to change the accessToken call be:
const accessToken = await instance.get('/access_token')

But there are two /access_token defined in webpack.config.js, how could i fix this
config.js
import axios from 'axios'

export const instance = axios.create()

webpack.config.js
module.exports = (env, { analyze }) => {
  const baseConfig = createBaseConfig({
    appEntries,
    aliases,
    node: { fs: 'empty' },
    assetsPath: false,
    port: 30087,
  })(env, { analyze })
  return {
    ...baseConfig,
    devServer: {
      ...baseConfig.devServer,
      allowedHosts: ['.mt-d1.sgc1.gkp.jpmchase.net'],
      host: '0.0.0.0',
      proxy: {
        // endpoint1 domain service
        '/sas/': {
          target: 'https://math-service.fuelcompany.net/',
          changeOrigin: true,
          secure: false,
        },
        // endpoint2 domain service
        '/jok': {
          target: 'https://security-service.fuelcompany.net/',
          changeOrigin: true,
          secure: false,
        },
        //access_token for endpoint1 domain
        '/access_token': {
          target: 'https://math-service.fuelcompany.net/',
          changeOrigin: true,
          secure: false,
        },
        //access_token for endpoint2 domain
        '/access_token': {
          target: 'https://security-service.fuelcompany.net/',
          changeOrigin: true,
          secure: false,
        },
      },
    },
    performance: createEnvUtils(env).ifProduction({
      hints: 'warning',
      maxEntrypointSize: 4096000,
      maxAssetSize: 2048000,
    }),
  }
}