text:
Q: Neither old or new registration id is canonical I have two registration ids in database one from the old version which used gcm.register() and the new one using instanceID.getToken
I sent a ghost notification to both of the registration ids which are of the same device. This is what I get.
Old registration id (before app update generated using gcm.register)
{
"multicast_id": 0000000,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
    {
    "message_id": "0:1f9fd7ecd"
    }]
}

New Registration id (After app update, generated using instanceID.getToken):
{
"multicast_id": 0000000,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
    {
    "message_id": "0:8ccf9fd7ecd"
    }]
}

How can I remove or update the old registration ID?
Please Help! Right now, I can't send notifications because of this. Since it will send double/duplicate notifications.
EDIT(2015-09-19): Google has acknowledged the issue and are working on it.
https://github.com/google/gcm/issues/94

A: You didn't receive any canonical IDs... instead you've received only a unique message_id.

If you try to send a message using an old registration token, GCM will process the request as usual, but it will include the canonical ID in the registration_id field of the response. Make sure to replace the registration token stored in your server with this canonical ID, as eventually the old registration token will stop working.

From: https://developers.google.com/cloud-messaging/registration#canonical-ids
The canonical_ids field indicates the amount of canonical ids in the results. The result array holds objects that indicate per registration_id what the message id is with an optional canonical id or if there has been an error.
You only have to update the registration id when in the corresponding result the registration_id field is included (this is the canonical id). The results are in the same order as the registration_ids in the request. That's how you map the result to the requested registration id(s).
Look at this documentation example, for instance:
{ "multicast_id": 216,
  "success": 3,
  "failure": 3,
  "canonical_ids": 1,
  "results": [
    { "message_id": "1:0408" },
    { "error": "Unavailable" },
    { "error": "InvalidRegistration" },
    { "message_id": "1:1516" },
    { "message_id": "1:2342", "registration_id": "32" },
    { "error": "NotRegistered"}
  ]
}

From: https://developers.google.com/cloud-messaging/http#example-responses

A: This was a bug in gcm which is now fixed.
Now if I send notification to old gcm id, it returns the new registration id as canoncial id.
Source: https://github.com/google/gcm/issues/94


text:
Q: alert followed by a Response.Redirect() doesn't shoot the alert msg I have an alert message and followed by a Response.Redirect block in Page_Init
The Response.Redirect works and redirects to a spectic page.
But the alert msg is not showing.
I need the user to click the OK button in the alert msg after that only the page should rediret..
Please help.
Sample code:
ScriptManager.RegisterCleintScriptBlock(this,this.GetType(),"alert('Success')",true);
Response.Redirect("index.aspx",false);

A: It will never work because the context is lost. The alert() should be done in index.aspx.cs.
Here is the possible implementation:
Response.Redirect("index.aspx?query=alert",false);

And in index.aspx.cs Page_Load:
if(Request["query"]=="alert")
{
    ScriptManager.RegisterClientScriptBlock(this.GetType(),"key","alert('Success')",true);
}

A: Why not do it in pure JavaScript?
<script>
    (function() {
        alert("Success");
        window.location = "/index.aspx";
    })();
</script>

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to determine if Git handles a file as binary or as text? I know that Git somehow automatically detects if a file is binary or text and that .gitattributes can be used to set this manually if needed. But is there also a way to ask Git how it treats a file?
So let's say I have a Git repository with two files in it: An ascii.dat file containing plain-text and a binary.dat file containing random binary stuff. Git handles the first .dat file as text and the secondary file as binary. Now I want to write a Git web front end which has a viewer for text files and a special viewer for binary files (displaying a hex dump for example). Sure, I could implement my own text/binary check but it would be more useful if the viewer relies on the information how Git handles these files.
So how can I ask Git if it treats a file as text or binary?

A: # considered binary (or with bare CR) file
git ls-files --eol | grep -E '^(i/-text)'

# files that do not have any line-ending characters (including empty files) - unlikely that this is a true binary file ?
git ls-files --eol | grep -E '^(i/none)'

#                                                        via experimentation
#                                                      ------------------------
#    "-text"        binary (or with bare CR) file     : not    auto-normalized
#    "none"         text file without any EOL         : not    auto-normalized
#    "lf"           text file with LF                 : is     auto-normalized when gitattributes text=auto
#    "crlf"         text file with CRLF               : is     auto-normalized when gitattributes text=auto
#    "mixed"        text file with mixed line endings : is     auto-normalized when gitattributes text=auto
#                   (LF or CRLF, but not bare CR)

Source: https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt---eol
https://github.com/git/git/commit/a7630bd4274a0dff7cff8b92de3d3f064e321359
Oh by the way: be careful with setting the .gitattributes text attribute e.g. *.abc  text. Because in that case all files with *.abc will be normalized, even if they are binary (internal CRLF found in the binary would be normalized to LF). This is different from the auto behaviour.

A: builtin_diff()1 calls diff_filespec_is_binary() which calls buffer_is_binary() which checks for any occurrence of a zero byte (NUL "character") in the first 8000 bytes (or the entire length if shorter).
I do not see that this "is it binary?" test is explicitly exposed in any command though.
git merge-file directly uses buffer_is_binary(), so you may be able to make use of it:
git merge-file /dev/null /dev/null file-to-test

It seems to produce the error message like error: Cannot merge binary files: file-to-test and yields an exit status of 255 when given a binary file. I am not sure I would want to rely on this behavior though.
Maybe git diff --numstat would be more reliable:
isBinary() {
    p=$(printf '%s\t-\t' -)
    t=$(git diff --no-index --numstat /dev/null "$1")
    case "$t" in "$p"*) return 0 ;; esac
    return 1
}
isBinary file-to-test && echo binary || echo not binary

For binary files, the --numstat output should start with - TAB - TAB, so we just test for that.

1
builtin_diff() has strings like Binary files %s and %s differ that should be familiar.

A: Use git check-attr --all.
This works regardless of if the file has been staged/committed or not.
Tested on git version 2.30.2.
Assuming you have this in .gitattributes.
package-lock.json binary

There is this output.
git check-attr --all package-lock.json
package-lock.json: binary: set
package-lock.json: diff: unset
package-lock.json: merge: unset
package-lock.json: text: unset

For normal files, there is no output.
git check-attr --all package.json

A: git grep -I --name-only --untracked -e . -- ascii.dat binary.dat ...

will return the names of files that git interprets as text files.
The trick here is in these two git grep parameters:

*

*-I: Don't match the pattern in binary files.

*-e .: Regular expression match any character in the file

You can use wildcards e.g.
git grep -I --name-only --untracked -e . -- *.ps1

A: @bonh gave a working answer in a comment

git diff --numstat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD -- | grep "^-" | cut -f 3

It shows all files which git interprets as binaries.

A: I don't like this answer, but you can parse the output of git-diff-tree to see if it is binary.  For example:
git diff-tree -p 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD -- MegaCli
diff --git a/megaraid/MegaCli b/megaraid/MegaCli
new file mode 100755
index 0000000..7f0e997
Binary files /dev/null and b/megaraid/MegaCli differ

as opposed to:
git diff-tree -p 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD -- megamgr
diff --git a/megaraid/megamgr b/megaraid/megamgr
new file mode 100755
index 0000000..50fd8a1
--- /dev/null
+++ b/megaraid/megamgr
@@ -0,0 +1,78 @@
+#!/bin/sh
[…]

Oh, and BTW, 4b825d… is a magic SHA which represents the empty tree (it is the SHA for an empty tree, but git is specially aware of this magic).

A: At the risk of getting slapped for poor code quality, I'm listing a C utility, is_binary, built around the original buffer_is_binary() routine in the Git source. Please see internal comments for how to build and run.  Easily modifyable:
/***********************************************************
 * is_binary.c
 *
 * Usage: is_binary <pathname>
 *   Returns a 1 if a binary; return a 0 if non-binary
 *
 * Thanks to Git and Stackoverflow developers for helping with these routines:
 * - the buffer_is_binary() routine from the xdiff-interface.c module
 *   in git source code.
 * - the read-a-filename-from-stdin route
 * - the read-a-file-into-memory (fill_buffer()) routine
 *
 * To build:
 *    % gcc is_binary.c -o is_binary
 *
 * To build debuggable (to push a few messages to stdout):
 *    % gcc -DDEBUG=1 ./is_binary.c -o is_binary
 *
 * BUGS:
 *  Doesn't work with piped input, like
 *    % cat foo.tar | is_binary
 *  Claims that zero input is binary. Actually,
 *  what should it be?
 *
 * Revision 1.4
 *
 * Tue Sep 12 09:01:33 EDT 2017
***********************************************************/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#define MAX_PATH_LENGTH 200
#define FIRST_FEW_BYTES 8000

/* global, unfortunately */
char *source_blob_buffer;

/* From: https://stackoverflow.com/questions/14002954/c-programming-how-to-read-the-whole-file-contents-into-a-buffer */

/* From: https://stackoverflow.com/questions/1563882/reading-a-file-name-from-piped-command */

/* From: https://stackoverflow.com/questions/6119956/how-to-determine-if-git-handles-a-file-as-binary-or-as-text
*/

/* The key routine in this function is from libc: void *memchr(const void *s, int c, size_t n); */
/* Checks for any occurrence of a zero byte (NUL character) in the first 8000 bytes (or the entire length if shorter). */

int buffer_is_binary(const char *ptr, unsigned long size)
{
  if (FIRST_FEW_BYTES < size)
    size = FIRST_FEW_BYTES;
    /* printf("buff = %s.\n", ptr); */
  return !!memchr(ptr, 0, size);
}
int fill_buffer(FILE * file_object_pointer) {
  fseek(file_object_pointer, 0, SEEK_END);
  long fsize = ftell(file_object_pointer);
  fseek(file_object_pointer, 0, SEEK_SET);  //same as rewind(f);
  source_blob_buffer = malloc(fsize + 1);
  fread(source_blob_buffer, fsize, 1, file_object_pointer);
  fclose(file_object_pointer);
  source_blob_buffer[fsize] = 0;
  return (fsize + 1);
}
int main(int argc, char *argv[]) {

  char pathname[MAX_PATH_LENGTH];
  FILE *file_object_pointer;

  if (argc == 1) {
    file_object_pointer = stdin;
  } else {
    strcpy(pathname,argv[1]);
#ifdef DEBUG
    printf("pathname=%s.\n", pathname);
#endif
    file_object_pointer = fopen (pathname, "rb");
    if (file_object_pointer == NULL) {
      printf ("I'm sorry, Dave, I can't do that--");
      printf ("open the file '%s', that is.\n", pathname);
      exit(3);
    }
  }
  if (!file_object_pointer) {
    printf("Not a file nor a pipe--sorry.\n");
    exit (4);
  }
  int fsize = fill_buffer(file_object_pointer);
  int result = buffer_is_binary(source_blob_buffer, fsize - 2);

#ifdef DEBUG
  if (result == 1) {
    printf ("%s %d\n", pathname, fsize - 1);
  }
  else {
    printf ("File '%s' is NON-BINARY; size is %d bytes.\n", pathname, fsize - 1);
  }
#endif
  exit(result);
  /* easy check -- 'echo $?' after running */
}

A:
So how can I ask Git if it treats a file as text or binary?

Not only git check-attr --all is a good option, but with Git 2.40 (Q1 2023), "git check-attr"(man) learned to take an optional tree-ish to read the .gitattributes file from.
That means you can Git if it treats a file as text or binary, for any commit, not just the current HEAD!
git check-attr --all --source=@~2 -- myFile

git check-attr --all --source=anotherBranch -- myFile

See commit 47cfc9b, commit c847e8c (14 Jan 2023) by Karthik Nayak (KarthikNayak).
(Merged by Junio C Hamano -- gitster -- in commit 577bff3, 23 Jan 2023)

attr: add flag --source to work with tree-ish
Signed-off-by: Karthik Nayak
Signed-off-by: Toon Claes
Co-authored-by: toon@iotcl.com

The contents of the .gitattributes files may evolve over time, but "git check-attr"(man) always checks attributes against them in the working tree and/or in the index.
It may be beneficial to optionally allow the users to check attributes taken from a commit other than HEAD against paths.
Add a new flag --source which will allow users to check the attributes against a commit (actually any tree-ish would do).
When the user uses this flag, we go through the stack of .gitattributes files but instead of checking the current working tree and/or in the index, we check the blobs from the provided tree-ish object.
This allows the command to also be used in bare repositories.
Since we use a tree-ish object, the user can pass "--source HEAD:subdirectory" and all the attributes will be looked up as if subdirectory was the root directory of the repository.
We cannot simply use the <rev>:<path> syntax without the --source flag, similar to how it is used in git show(man) because any non-flag parameter before -- is treated as an attribute and any parameter after -- is treated as a pathname.
The change involves creating a new function read_attr_from_blob, which given the path reads the blob for the path against the provided source and parses the attributes line by line.
This function is plugged into read_attr() function wherein we go through the stack of attributes files.

git check-attr now includes in its man page:

'git check-attr' [--source <tree-ish>] [-a | --all | <attr>...] [--] <pathname>...
'git check-attr' --stdin [-z] [--source <tree-ish>] [-a | --all | <attr>...]

git check-attr now includes in its man page:

--source=<tree-ish>
Check attributes against the specified tree-ish.
It is common to
specify the source tree by naming a commit, branch or tag associated
with it.

A: You can use command-line tool 'file' utility. On Windows it's included in git installation and normally located in in C:\Program Files\git\usr\bin folder
file --mime-encoding *

See more in Get encoding of a file in Windows


text:
Q: How to import more than one million data into CPLEX? I am using "SheetConnection" and "SheetRead" for importing my data into CPLEX.
The size of data that I am importing is more than what is allowed by excel (excel limit is one million). I would like to know what are the possible ways, commands for importing data into CPLEX which allows for importing around 3 million data.
Thank you.

A: Please don't use a spreadsheet for anything as big as that. They are fantastic tools that I use every day, but they are NOT intended or designed to handle data that large very efficiently. USE a DATABASE! Since you are probably on a version of Windows, you can probably use the basic version of SQL Server (which is free) and will perform far better than a spreadsheet. It will also be far more robust. I have lost data in spreadsheets in several projects, especially with many rows & columns. In the past 20 years I have never lost data in SQL Server.


text:
Q: How to resolve PHP error log in cpanel server causing blank screen php page Good day to everyone. I found this below php coding errors in the "error_log" which is in my cpanel server root directory, causing the php page for a schoolsystem I developed to be blank screen on browsers. I have tried, all I could but not working for me.
**`BELOW IS THE ERROR_LOG CONTENT:`**

[03-Dec-2016 10:17:36 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_pconnect() in /home/xayoutys/public_html/schoolsystem/functions/connection.php:14
Stack trace:
#0 /home/xayoutys/public_html/schoolsystem/setup.php(4): include()
#1 {main}
  thrown in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 10:19:06 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_pconnect() in /home/xayoutys/public_html/schoolsystem/functions/connection.php:14
Stack trace:
#0 /home/xayoutys/public_html/schoolsystem/setup.php(4): include()
#1 {main}
  thrown in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 10:19:21 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_pconnect() in /home/xayoutys/public_html/schoolsystem/functions/connection.php:14
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: style in /home/xayoutys/public_html/schoolsystem/setup.php on line 17
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: url in /home/xayoutys/public_html/schoolsystem/setup.php on line 18
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: name in /home/xayoutys/public_html/schoolsystem/setup.php on line 19
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: save in /home/xayoutys/public_html/schoolsystem/setup.php on line 20
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: stype in /home/xayoutys/public_html/schoolsystem/setup.php on line 21
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 308
[03-Dec-2016 10:21:20 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 308
[03-Dec-2016 10:22:52 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 10:22:52 UTC] PHP Notice:  Undefined index: style in /home/xayoutys/public_html/schoolsystem/setup.php on line 17
[03-Dec-2016 10:22:52 UTC] PHP Notice:  Undefined index: url in /home/xayoutys/public_html/schoolsystem/setup.php on line 18
[03-Dec-2016 10:22:52 UTC] PHP Notice:  Undefined index: name in /home/xayoutys/public_html/schoolsystem/setup.php on line 19
[03-Dec-2016 10:22:52 UTC] PHP Notice:  Undefined index: save in /home/xayoutys/public_html/schoolsystem/setup.php on line 20
[03-Dec-2016 10:22:52 UTC] PHP Notice:  Undefined index: stype in /home/xayoutys/public_html/schoolsystem/setup.php on line 21
[03-Dec-2016 10:22:52 UTC] PHP Deprecated:  mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/setup.php on line 47
[03-Dec-2016 10:22:53 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: style in /home/xayoutys/public_html/schoolsystem/setup.php on line 17
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: url in /home/xayoutys/public_html/schoolsystem/setup.php on line 18
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: name in /home/xayoutys/public_html/schoolsystem/setup.php on line 19
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: save in /home/xayoutys/public_html/schoolsystem/setup.php on line 20
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: stype in /home/xayoutys/public_html/schoolsystem/setup.php on line 21
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined variable: aval in /home/xayoutys/public_html/schoolsystem/setup.php on line 136
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined variable: ain in /home/xayoutys/public_html/schoolsystem/setup.php on line 163
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 173
[03-Dec-2016 10:22:53 UTC] PHP Notice:  Undefined variable: aval in /home/xayoutys/public_html/schoolsystem/setup.php on line 188
[03-Dec-2016 10:24:02 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 10:24:02 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 10:24:02 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 10:24:02 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 10:24:02 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 10:24:02 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 10:24:05 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 308
[03-Dec-2016 11:21:39 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 308
[03-Dec-2016 11:26:58 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 11:27:07 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 11:27:09 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: style in /home/xayoutys/public_html/schoolsystem/setup.php on line 17
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: url in /home/xayoutys/public_html/schoolsystem/setup.php on line 18
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: name in /home/xayoutys/public_html/schoolsystem/setup.php on line 19
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: save in /home/xayoutys/public_html/schoolsystem/setup.php on line 20
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: stype in /home/xayoutys/public_html/schoolsystem/setup.php on line 21
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 308
[03-Dec-2016 11:27:09 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 308
[03-Dec-2016 11:27:40 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 11:27:40 UTC] PHP Notice:  Undefined index: style in /home/xayoutys/public_html/schoolsystem/setup.php on line 17
[03-Dec-2016 11:27:40 UTC] PHP Notice:  Undefined index: url in /home/xayoutys/public_html/schoolsystem/setup.php on line 18
[03-Dec-2016 11:27:40 UTC] PHP Notice:  Undefined index: name in /home/xayoutys/public_html/schoolsystem/setup.php on line 19
[03-Dec-2016 11:27:40 UTC] PHP Notice:  Undefined index: save in /home/xayoutys/public_html/schoolsystem/setup.php on line 20
[03-Dec-2016 11:27:40 UTC] PHP Notice:  Undefined index: stype in /home/xayoutys/public_html/schoolsystem/setup.php on line 21
[03-Dec-2016 11:27:40 UTC] PHP Deprecated:  mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/setup.php on line 47
[03-Dec-2016 11:27:41 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: style in /home/xayoutys/public_html/schoolsystem/setup.php on line 17
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: url in /home/xayoutys/public_html/schoolsystem/setup.php on line 18
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: name in /home/xayoutys/public_html/schoolsystem/setup.php on line 19
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: save in /home/xayoutys/public_html/schoolsystem/setup.php on line 20
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: stype in /home/xayoutys/public_html/schoolsystem/setup.php on line 21
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined variable: aval in /home/xayoutys/public_html/schoolsystem/setup.php on line 136
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 136
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined variable: ain in /home/xayoutys/public_html/schoolsystem/setup.php on line 136
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 136
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined variable: ain in /home/xayoutys/public_html/schoolsystem/setup.php on line 136
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 136
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined variable: ain in /home/xayoutys/public_html/schoolsystem/setup.php on line 163
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 163
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined variable: aval in /home/xayoutys/public_html/schoolsystem/setup.php on line 173
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 173
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Undefined variable: aval in /home/xayoutys/public_html/schoolsystem/setup.php on line 188
[03-Dec-2016 11:27:41 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 188
[03-Dec-2016 11:27:59 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 11:27:59 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 11:27:59 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 11:27:59 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 11:27:59 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 11:27:59 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 11:28:00 UTC] PHP Deprecated:  mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xayoutys/public_html/schoolsystem/functions/connection.php on line 14
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: style in /home/xayoutys/public_html/schoolsystem/setup.php on line 17
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: url in /home/xayoutys/public_html/schoolsystem/setup.php on line 18
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: name in /home/xayoutys/public_html/schoolsystem/setup.php on line 19
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: save in /home/xayoutys/public_html/schoolsystem/setup.php on line 20
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: stype in /home/xayoutys/public_html/schoolsystem/setup.php on line 21
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: import in /home/xayoutys/public_html/schoolsystem/setup.php on line 23
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: username in /home/xayoutys/public_html/schoolsystem/setup.php on line 24
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: password in /home/xayoutys/public_html/schoolsystem/setup.php on line 25
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: host in /home/xayoutys/public_html/schoolsystem/setup.php on line 26
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined index: database in /home/xayoutys/public_html/schoolsystem/setup.php on line 27
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 262
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 278
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 288
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 298
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Undefined variable: val in /home/xayoutys/public_html/schoolsystem/setup.php on line 308
[03-Dec-2016 21:09:01 UTC] PHP Notice:  Trying to get property of non-object in /home/xayoutys/public_html/schoolsystem/setup.php on line 308

CONNECTION.PHP Code:
<?php
$aut_host = 'localhost';//e.g localhost
$aut_user = 'xayoutys_sman';
$aut_pass = 'school009#';
$aut_db = 'xayoutys_sman';

//$connect = mysql_pconnect('localhost', 'root', '');
//mysql_select_db('xsman');

/*$connect = mysql_pconnect('127.0.0.1', 'kokotrad_sman', 'cool');
$xtzone = mysql_query("SET time_zone = 'Africa/Lagos'");
mysql_select_db('kokotrad_sman');*/

$connect = mysqli_connect( 'localhost', 'xayoutys_sman', 'school009#');
$xtzone = mysql_query("SET time_zone = 'Africa/Lagos'");
mysql_select_db('xayoutys_sman');

if(@$page != 'setup')
{
//school type
$qtype = mysql_query("select type from type where id = 1");
$qtype_row = mysql_fetch_row($qtype);
$type = $qtype_row[0];

//sms sender id
$xsendq = mysql_query("select sender from smsapi where id = 1");
if(mysql_num_rows($xsendq) > 0)
{
    $xsendq_row = mysql_fetch_row($xsendq);
    $xsender = $xsendq_row[0];
}

//get style
$cstyle = mysql_query("select style, school_name, url, logo_ext from info where id = 1");
$cstyle_row = mysql_fetch_row($cstyle);
$xcstyle = $cstyle_row[0];
$csch_name = $cstyle_row[1];
$curlx = $cstyle_row[2];
$clogo_ext = $cstyle_row[3];

if($type == 'university')
{
    $tl = 'Lecturer';
    $cac = 'Association';
    $cco = 'Course';
}
elseif($type == 'school')
{
    $tl = 'Teacher';
    $cac = 'Club';
    $cco = 'Subject';
}

}//setup
?>

SETUP.PHP CODES
<?php
$page = 'setup';

include('functions/connection.php');
include('functions/error_success.php');
include('objects/query.php');
include('objects/upload_download.php');

//check stat
$check = new select();
$check->pick('info', 'stat', 'id', "1", '', 'record', '', '', '=', '');
if($check->count > 0)
{
    $check_row = mysql_fetch_row($check->query);
}

$style = $_POST['style'];
$url = $_POST['url'];
$name = $_POST['name'];
$save = $_POST['save'];
$stype = $_POST['stype'];

$import = $_POST['import'];
$username = $_POST['username'];
$password = $_POST['password'];
$host = $_POST['host'];
$database = $_POST['database'];

if($import)
{
    $val = new validate();
    $val->valid("$database,$username,$host");
    if($val->error_code < 1)
    {
        // Name of the file
$filename = 'sman.sql';
// MySQL host
$mysql_host = $host;
// MySQL username
$mysql_username = $username;
// MySQL password
$mysql_password = $password;
// Database name
$mysql_database = $database;

// Connect to MySQL server
mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error());
// Select database
mysql_select_db($mysql_database) or die('Error selecting MySQL database: ' . mysql_error());


text:
Q: htaccess for separate folder without disturbing homepage I have wordpress installed in rootfolder in http://example.com . I have created new folder named world http://example.com/world , I need htaccess to work on that particular folder alone , Is it possible?
My htaccess I need to use for folder world is given below. I added this in rootfolder htaccess and I got internal server error and hence I don't want to disturb the root folder.
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)(\/?)$ / [QSA,NC,L]

My root folder htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

A: Replace your DOCUMENT_ROOT/.htaccess with this code:
# BEGIN WordPress
<IfModule mod_rewrite.c>

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

# don't do anything for /world folder
RewriteRule ^world/ - [L,NC]

RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
# END WordPress

Replace your DOCUMENT_ROOT/world/.htaccess with this code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /world/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php [L]


text:
Q: .env variable in cloudinary.config is not working I am implementing an upload file function and this is my cloudinary config:
cloudinary.js
cloudinary.config({
  cloud_name: process.env.CLOUD_NAME,
  api_key: process.env.API_KEY,
  api_secret: process.env.API_SECRET
});

.env
ACCESS_TOKEN=auth
CLOUD_NAME=huabwxiwssd
API_KEY=7*************2
API_SECRET=A**************-**********I

(I do not want to reveal my api_key and api_secret so I use * to hide)
I installed dotend and config in server.js file
server.js
const express = require("express");
const app = express();
const cors = require("cors");
const route = require("./routes/ROUTES");
const db = require("./config/connectDB");
require("dotenv").config(); ------------------------> config here
const PORT = process.env.PORT || 5000;

//Connect to database
db.connect();

//Run json in request.http
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

//Enable cors
app.use(cors());

//Routes init
route(app);

app.listen(PORT, () => {
  console.log(`Example app listening at http://localhost:${PORT}`);
});

It always shoots an error "Must supply api_key". I tried to search Stackoverflow to fix this issue like adding double quotes in variable in .env file but it doesn't work. I can only upload file successfully when I bind value directly in cloudinary.config but I don't want my key to be revealed. So, how can I fix this issue?

A: I am implementing an upload file function and this is my cloudinary config:
import { v2 as cloudinary } from 'cloudinary';
import dotenv from 'dotenv';

// Config
dotenv.config();

cloudinary.config({
    cloud_name: process.env.CLOUD_NAME,
    api_key: process.env.API_KEY,
    api_secret: process.env.API_SECRET,
});

export default cloudinary;


text:
Q: Turning off the backlight on the console I'm using an IBM Thinkpad X21 as a 3G router.  It's running a server install of lucid.  The laptop has the lid up most of the time. There is no X, just a plain console.  The colsole blanks itself, but the LCD backlight is always on.
The graphics chip is ATI Technologies Inc Rage Mobility P/M AGP 2x (rev 64).
The following modules related to the framebuffer are now loaded:
$ lsmod | grep fb
fbcon                  35102  71
tileblit                2031  1 fbcon
font                    7557  1 fbcon
bitblit                 4707  1 fbcon
vga16fb                11385  1
vgastate                8961  1 vga16fb

Can I make the LCD backlight turn off when the colsole is unused and have it turn on automatically when needed?

A: You should be able to use setterm to do this:
# turn power save on, blank after 10 mins, powerdown after 20mins
setterm -powersave on -blank 10 -powerdown 20

A: vbetool works for me. I have used it on a dell inspiron 8100. Old computer, but it is supposed to be a general tool, I believe.
It was not installed by default on my computer: Ubuntu server 9.04.
I installed it using apt-get:
sudo apt-get install vbetool

Then, I can execute it:
sudo vbetool dpms off
sudo vbetool dpms on

For me this turns the laptop monitor completely off (including the backlight) and then on.
Doesn't seem to be exactly what you want, but maybe it is close enough.
Hope this helps

A: Not quite as automatically as you might like, still issuing the following ought to turn the brightness all the way down. Further poking around in the /sys tree might reveal other complementary steps to improve on it:
sudo su -c 'echo "0" > /sys/devices/virtual/backlight/acpi_video0/brightness';

Then use the power buttons on the keyboard to get the brightness back up. Be sure to verify the correctness of this line w.r.t. how your /sys tree looks.


text:
Q: DynamoDB - update/create item using Hash and Range key within TransactWrite I have the following table:
"KeySchema": [
    {
      "AttributeName": "Value",
      "KeyType": "HASH"
    },
    {
      "AttributeName": "Id",
      "KeyType": "RANGE"
    }
]

What I'm trying to do is update a record, but if it doesn't exist, create it.
This did not work, because it seems you can't update the Range key? (the Id field won't change, but the Value will)
I read that the best thing to do is to delete the item, then re-create it. However, doing this leads to the error Transaction request cannot include multiple operations on one item.
Very simply, I'd like to go from this record:
  Item: {
     Value: 'Email|tim@apple.com',
     Id: '01E9AR3D4MQ3CDKE98SM8CR5Q3'
  }

to this (and if the Key of Id and Value doesn't exist, create it):
  Item: {
     Value: 'Email|tim1@apple.com',
     Id: '01E9AR3D4MQ3CDKE98SM8CR5Q3'
  }

But it seems that I can't easily do this within this.db.transactWrite(req).promise()

A: I think you can use a PUTItem request, it will create a new row if missing or update it if already exists.
Just be aware to have all row data in the PUTItem request (in case you have other columns than HASH and RANGE), if not some data can be lost.
Note : PUTItem request can also be used in BatchWriteItem requests.
Some usefull links :

*

*https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html

*https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html
Hope this will help you.

A: Firstly don't you want your email to be your sort key? Your Ids look like a hash and don't have an order or am I missing something?
I think actually your are doing something wrong. An ID really should never be updated. Rather have a normal attribute email/age/etc and you can create an LSI on that if your partition key is unchanged, or GSI if you are needing to change your partition key, and then query that table.
You don't need to delete and recreate values to achieve this.


text:
Q: Handling strings in python I have 2 strings:
s7="ONE : TWO : THREE : FOUR : FIVE 30.1 : SIX 288.3 : SEVEN 1.9 : EIGHT 45.3 :"
s8="ONE : TWO : THREE : FOUR 155.5 : FIVE 334.7 : SIX 6.7 : SEVEN 44.5 :"

I'm using the following code to parse it:
c=s.count(':')
if c==8:
    res=""
    res=s.split(' : ')
    res = [item.strip() for item in s.split(':')]
    for index, item in enumerate(res):
        print index, item
if c==7:
    res=""
    res=s.split(' : ')
    res = [item.strip() for item in s.split(':')]
    for index, item in enumerate(res):
        print index, item

This output i get is
>>> parse(s7)
0 ONE
1 TWO
2 THREE
3 FOUR
4 FIVE 30.1
5 SIX 288.3
6 SEVEN 1.9
7 EIGHT 45.3
8
>>> parse(s8)
0 ONE
1 TWO
2 THREE
3 FOUR 155.5
4 FIVE 334.7
5 SIX 6.7
6 SEVEN 44.5
7

How can I extract the numerical values from index 4 to 7 in s7 and index 3 to 6 in s8? I need to store these values so I can write them into a database later.
I've tried a couple of things but they aren't working.
Please help.

A: Does it always look like that? you can simply do:
s7="ONE : TWO : THREE : FOUR : FIVE 30.1 : SIX 288.3 : SEVEN 1.9 : EIGHT 45.3 :"
for elem in s7.split(' '):
    try:
        print elem
        total += float(elem)
    except:
        pass
s7 = total
>>> s7
365.6

And do the same for s8 as well.

A: You can use the following regular expression on each string:
[A-Z][ ]+([\d.]+)

For each string, the value you're looking for will be in the first captured group, if not empty. You can see exactly what's going on at www.debuggex.com.
Full code:
import re

s7="ONE : TWO : THREE : FOUR : FIVE 30.1 : SIX 288.3 : SEVEN 1.9 : EIGHT 45.3 :"

def parse(s):
  res = s.split(' : ')
  matches = [re.search('[A-Z][ ]+([\d.]+)', x) for x in res]
  return [float(x.group(1)) for x in matches if x is not None]

print(parse(s7)) // prints "[30.1, 288.3, 1.9, 45.3]"

A: You could do a list comprehension as well.
Assuming the strings always take on the format you provided then this would work:
def parse(s):
    results = [float(x) for x in s.split(' ') if x.count('.') == 1]

>> [30.1, 288.3, 1.9, 45.3]
>> [155.5, 334.7, 6.7, 44.5]
This code says:
for every `x` in the split string, which I've split on whitespace,
cast it to a float if x's count of `.` is 1.

Using count() here works since it won't raise any exceptions if it doesn't find any occurences of the . however if you want to use exception handling then index() would be the one you're looking for.


text:
Q: DHCLIENT.CONF System variables I've just a little question.
My DNS Servers are updated by our DHCP Server (Microsoft Windows 2003 R2 SP2).
My clients are Debian Linux Distro's, and I have to modify my DHCLIENT.CONF file on it to send his Full Qualified Hostname.
BUT I've about 1600 computers and I don't want to modify each client one by one, then, Could I for exemple use a System Variable on the Config file?
Exemple:
#DHCLIENT CONF;
send "$hostname"  where $hostname variable is the alias write on BASHRC for the hostname -f command.
If you need any more informations just tell me.

A: The bleeding edge (4.2.x) versions of dhclient support this by providing a gethostname() function.
So with the latest dhclient alpha, you can put something like this in dhclient.conf
send host-name = gethostname();

Ubuntu have a patch in their version of dhclient which lets you do
send host-name = "<hostname>";

and it will replace it with the proper hostname.
Redhat patch their dhclient to provide -H and -F (-H = send host-name, -F = send fqdn.fqdn) command line options. So on Redhat you can run
dhclient -H $(hostname)

and it will send the proper hostname.
I'm not aware of anything available for Debian though - you might want to look at patching your dhclient with the Ubuntu patch

A: I guess you have a number of different approaches here. AFAIK, the dhclient.conf does not support variable expansion as you have listed. So that leaves two obvious options:

*

*Script to login to all hosts and build config file

*Configuration management (puppet/cfengine/chef)

Option 1. is ugly, it will get you past this hurdle but it will be difficult to maintain. Before you know it, you will regularly be writing scripts to login to all of your machines, which will take a long time, be error-prone (for instance how do you handle down hosts gracefully and come back later) and hard to maintain.
Option 2. is definitely what I would recommend, and I would recommend puppet as its far more flexible and easy to use relative to cfengine, yet relatively mature.
Here is your manifest (not tested)
class dhcp-client {
   file { "/etc/dhclient.conf":
       content => template("dhclient.conf")
   }
}

And the template :
other dhclient.conf stuff
send "<%= fqdn %>"

and node config:
node default {
   include dhcp-client
}

A: Many thanks for everyone (you both), I've discovered a huge tools, named Puppet and increase my skills in scripting.
Subject Resolved.


text:
Q: Python: While using the requests library and an API, how do I change the header "Content-Type" to JSON? I've been trying to use an api on a website for awhile now and the responses from the api return the data in xml. I want the response to be in JSON format, but when I try adding a header into the http request, it keeps sending the response in xml.
I've tried the following code:
import requests

param_list = {'key1': 'value1'}
headers = {'Content-Type': 'application/json'}
url = 'api url'

response = requests.get(url=url, params=param_list, headers=headers,)

print(response.text)
print(response.headers)

The second print statement shows that the 'Content-Type' header returns "text/html"
Any idea on how to fix this? Thanks for your time and help!


text:
Q: Is it ever better to use Berkeleys algorithm over NTP for time synchronization? As the topic states: Is it ever better to use Berkeleys algorithm over NTP for time synchronization?
As I understand it NTP is a robust state of the art algorithm that gives the best accuracy and that Berkeleys algorithm is used for synchronization in internal networks. Couldn't NTP be used in an internal network for the best accuracy and by doing so making Berkeleys algorithm sort of "useless" in that sense.
Or am I missing something?

A: You aren't missing anything.
The Berleley algorithm(created in 1989) is used when no machine in an internal network has an accurate time source. It works by a server polling all its clients, then it takes an average of all those times, and then adjusting each client based on that average. Its accuracy is on the order of 20ms.
NTP is a robust, time-tested, up-to-date protocol which has an accuracy on the order of a few milliseconds over the internet, and sub-milliseconds on an internal network.
NTP is the way to go in the present day...


text:
Q: Cappuccino - CPSplitView fixed subviews' size I have a class GridNode inheriting from CPSplitView that is used to wrap objects of type GridELement. Each consecutive split of a GridNode divides it into two new GridNodes (containing GridElements that resize with their parent).
Another class - GridToolbar inherits from GridElement. It should basically have the same behaviour as GridElement although the size shouldn't change automatically (as the container is resized) but only after user drags the splitter.
The problem is, even if I set the AutoresizingMask to a specific direction (as the toolbars can be either vertical or horizontal) it still gets resized in both of them.
Any suggestions on what I can do to prevent this from happening?
source of GridNode.j:
@implementation GridNode : CPSplitView
{
}

- (id)initWithFrame:(CGRect)aFrame
{
  self = [super initWithFrame:aFrame];

  if(self)
  {
    [self setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ];
    [self setBackgroundColor:[CPColor colorWithHexString:"EEEEEE"]]
  }

  return self;
}

- (void)split:(id)sender
{
  var parent = [sender superview];

  var gridNode = [
    [GridNode alloc]
    initWithFrame:CGRectMake(
      0, 0,
      CGRectGetWidth([parent bounds]),
      CGRectGetHeight([parent bounds])
    )
  ];
  [gridNode setVertical:(CGRectGetWidth([gridNode bounds]) >= CGRectGetHeight([gridNode bounds]) ? YES : NO)]

  var element = [
    [GridElement alloc]
    initWithFrame:CGRectMake(
      0, 0,
      CGRectGetWidth([parent bounds]),
      CGRectGetHeight([parent bounds])
    )
  ];

  [self replaceSubview:parent with:gridNode];

  [parent setBtnTarget:gridNode];
  [element setBtnTarget:gridNode];

  [gridNode addSubview:parent];
  [gridNode addSubview:element];
}

- (void)addBar:(id)sender
{
  var parent = [sender superview];

  var gridNode = [
    [GridNode alloc]
    initWithFrame:CGRectMake(
      0, 0,
      CGRectGetWidth([parent bounds]),
      CGRectGetHeight([parent bounds])
    )
  ];
  [gridNode setVertical:(CGRectGetWidth([gridNode bounds]) >= CGRectGetHeight([gridNode bounds]) ? YES : NO)]

  var isVertical = [gridNode isVertical];
  var toolbar = [
    [GridToolbar alloc]
    initWithFrame:CGRectMake(
      0, 0,
      CGRectGetWidth([parent bounds]),
      CGRectGetHeight([parent bounds])
    )
    vertical: isVertical
  ];

  [parent setBounds:CGRectMake(
    isVertical ? 32 : 0, isVertical ? 0 : 32,
    CGRectGetWidth([gridNode bounds]) - (isVertical ? 32 : 0),
    CGRectGetHeight([parent bounds]) - (isVertical ? 0 : 32)
  )];

  [self replaceSubview:parent with:gridNode];

  [parent setBtnTarget:gridNode];
  [toolbar setBtnTarget:gridNode];

  [gridNode addSubview:toolbar];
  [gridNode addSubview:parent];
}

@end

source of GridElement.j:
@implementation GridElement : CPView
{
  CPButton btnSPlit;
  CPButton btnToolbar;
}

- (id)initWithFrame:(CGRect)aFrame
{
  self = [super initWithFrame:aFrame]

  if (self)
  {
    [self setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ];
    [self setBackgroundColor:[CPColor colorWithCalibratedRed:Math.random() green:Math.random() blue:Math.random() alpha:1.0]];

    btnSPlit = [
        [CPButton alloc]
        initWithFrame:CGRectMake(0,0,128,24)
    ];

    [btnSPlit setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
    [btnSPlit setFrameOrigin:CGPointMake((CGRectGetWidth([self bounds]) - CGRectGetWidth([btnSPlit frame])) / 2.0,
                        (CGRectGetHeight([self bounds]) - CGRectGetHeight([btnSPlit frame])) / 2.0 - 15)];
    [btnSPlit setTitle:"split me!"];

    [btnSPlit setAction:@selector(split:)];

    [self addSubview:btnSPlit]

    btnToolbar = [
        [CPButton alloc]
        initWithFrame:CGRectMake(0,0,128,24)
    ];

    [btnToolbar setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
    [btnToolbar setFrameOrigin:CGPointMake((CGRectGetWidth([self bounds]) - CGRectGetWidth([btnToolbar frame])) / 2.0,
                        (CGRectGetHeight([self bounds]) - CGRectGetHeight([btnToolbar frame])) / 2.0 + 15)];
    [btnToolbar setTitle:"split me!"];

    [btnToolbar setAction:@selector(addBar:)];

    [self addSubview:btnToolbar]
  }

  return self;
}

- (void)setBtnTarget:(id)aTarget
{
  [btnSPlit setTarget:aTarget];
  [btnSPlit setTitle:"split "+aTarget._UID]
  [btnToolbar setTarget:aTarget];
  [btnToolbar setTitle:"toolbar "+aTarget._UID]
}

@end

source of GridToolbar.j:
@implementation GridToolbar : GridElement
{
  CPButtonBar btnBar;
}

- (id)initWithFrame:(CGRect)aFrame vertical:(BOOL)isVertical
{
  self = [super initWithFrame:CGRectMake(
    0,0,
    isVertical == NO ? aFrame.size.width : 32,
    isVertical == YES ? aFrame.size.height : 32
  )]

  if(self)
  {
    isVertical == YES ? [self setAutoresizingMask:CPViewWidthSizable] : [self setAutoresizingMask:CPViewHeightSizable];
    [self setBackgroundColor:[CPColor blackColor]];

    btnBar = [
      [CPButtonBar alloc]
      initWithFrame:CGRectMake(
        0,0,
        CGRectGetWidth([self bounds]),
        CGRectGetHeight([self bounds])
      )
    ];
  }

  return self;
}

@end

A: I received a useful suggestion here. Creating my own delegate that is handling the automatic resize of GridNode's subviews according to a fixed value set while dragging the divider was all I had to do.


text:
Q: NLTK (or other) Part of speech tagger that returns n-best tag sequences I need a part of speech tagger that does not just return the optimal tag sequence for a given sentence, but that returns the n-best tag sequences.  So for 'time flies like an arrow', it could return both NN VBZ IN DT NN and NN NNS VBP DT NN for example, ordered in terms of their probability.  I need to train the tagger using my own tag set and sentence examples, and I would like a tagger that allows different features of the sentence to be engineered.  If one of the nltk taggers had this functionality, that would be great, but any tagger that I can interface with my Python code would do.  Thanks in advance for any suggestions.

A: I would recommend having a look at spaCy. From what I have seen, it doesn't by default allow you to return the top-n tags, but it supports creating custom pipeline components.
There is also an issue on Github where exactly this is discussed, and there are some suggestions on how to implement it relatively quickly.


text:
Q: jQuery Alert Dialogs I'm quite new on jquery and i was looking for something that could replace the confirm dialog. I found jQuery Alert Dialogs at http://abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/#demo
but jConfirm do not return the same values as confirm().
Is possible to write a function to get the same confirm() value?
It's about the meaning of callback function that I admit is not so clear for me :-)

A: jConfirm will never "return" anything because it's "event driven".
jConfirm waits until the user has made a decision and then it will call the callback function which will handle the answer. But jConfirm will not block the code execution flow like the standard confirm(...) does.
So if your previous code looks like this:
// ask for a decision
var answer = confirm("Leave website?"); // the whole script stops until the user has made a decision!

// process answer
if (answer){
    alert("Bye bye!"); // the script waits here until the user has clicked "ok"
    window.location = "http://www.google.com/";
}
else{
    alert("Thanks for sticking around!"); // the script waits here until the user has clicked "ok"
}

it should look like this in jQuery:
// previous code

// show confirm dialog but the script will not wait, the script execution goes forward

jConfirm('Leave website?', 'Confirmation Dialog', function(answer) {

    // this is the callback function of the jConfirm dialog we made
    // we arrive here when the user has made a decision

    // the answer is true, he wants to leave
    if (answer){

      // show a jAlert box
      jAlert("Bye Bye!", "Some Title", function() {

        // this is the callback function of the jAlert box
        // we arrive here when the user has clicked "ok"

        // send him to google
        window.location = "http://www.google.com/";
      });

    }
    else{
      // show a jAlert box without any callback
        jAlert("Thanks for sticking around!", "Some Title");
    }

});

// the code that follows here will be immediately executed
// because unlike confirm(), jConfirm() will not block
// the code execution flow

And for illustration:
The standard JavaScript confirm() execution flow
  |
  |
  |
  \/
  confirm() waits for an answer...
  no further code will be executed
  until the user has made a decision
  |
  |
  \/
  handle the user's answer
  |
  |
  \/
  further code
  execution

The jConfirm execution flow
  |
  |
  \/ -------> jConfirm Dialog
  |                 |
  |                 |
  |                 \/
  |             Callback function
  |             when the user has made
  |             a decision.
  |             (handle the answer here)
  |
  |
  \/
 further code
 execution

A: You can use the .dialog from jQuery UI.  It's what I use.
You can make the buttons whatever you want and handle them like so:
$( "#dialog-confirm" ).dialog({

    draggable: false,
    resizable: false,
    modal: true,
    buttons: {

        Ok: function() {

            // Do whatever you want to do when the user clicks Ok

            // Lastly, close the dialog
            $(this).dialog("close");

        },
        Cancel: function() {

            // Do whatever you want to do when the user clicks Cancel

            // Lastly, close the dialog
            $(this).dialog("close");
        }

    }

});

A: The confirm() function is a synchronous call (i.e. it returns only when the user has clicked a button). jQuery-type dialogs are asynchronous (one call to open it, and a callback with the result). So you have to use a callback function and write your code differently. It's not possible to have a jquery-type dialog running in a synchronous call.

A: you can wrap the jconfirm in another function then wait for the response something like:
function Confirm(){
var response;
jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
    response = r;
});
return response
}

now you can use if(Confirm()){alert('Has been confirmed');}

A: Please see the reusable code below.
Please remember that , Jquery alert won't wait for the user action. The statement after showAlert() will be executed immediately.
/** dialogUtils.js  start */
var iconStyle = '';
var messageStyleStart = '';
var messageStyleEnd = '';
var alertDialogHeight =190;
var alertDialogWidth =460;
var fieldToFocus;
var $alertDialog;

/**
shows the alert box - if the title is passed display that otherwise shows
the default title
message - message to display on the alert box
title - title of the box
fieldIdtoFocus - if you need to give the focus to any field after showing the alert (id of the field)
height
width

*/
function showAlert(message,title,fieldIdtoFocus,height,width)
{
    $alertDialog.html(iconStyle + messageStyleStart +message + messageStyleEnd);
    if(title =='undefined'|| null ==title ||''==title)
        $alertDialog.dialog( "option", "title", alertHeader );
    else
        $alertDialog.dialog( "option", "title", title );
    // check for the field focus value, if the value passed use it, otherwise reset it.
    if(fieldIdtoFocus == 'undefined' || null == fieldIdtoFocus || ''== fieldIdtoFocus)
        fieldToFocus = null;
    else
        fieldToFocus = fieldIdtoFocus;
    // check if got height
    if(height == 'undefined' || null == height || ''== height)
        $alertDialog.dialog( "option", "height", alertDialogHeight);
    else
        $alertDialog.dialog( "option", "height", height);
    //check if got width
    if(width == 'undefined' || null == width || ''== width)
        $alertDialog.dialog( "option", "width", alertDialogWidth);
    else
        $alertDialog.dialog( "option", "width", width);

    // open the alert dialog box
    $alertDialog.dialog('open');
    // prevent the default action
    return false;
}

$(document).ready(function(){
//jquery alert box - the general alert box
    $alertDialog = $('

')
        .html('This Message will be replaced!')
        .dialog({
            autoOpen: false,
            modal: true,
            position: 'top',
            buttons: {
                Ok: function() {
                    $( this ).dialog( "close" );
                    if(null != fieldToFocus){
                        if($('#'+fieldToFocus).is(':visible')) // if it is visble then only show
                            $('#'+fieldToFocus).focus();
                    }
                }
            }
    });
});

/** dialogUtils.js  end */

// call the function from anywhere in your code after including the dialogUtils.js  above */

showAlert("Please enter your phone number",'Alert!','phoneNumber');


text:
Q: How to get CC.net build status for a project programatically? From a shell script, I want to detect if CC.net is currently building a project.  I have the URL of the CC.net server and the name of the project.
Heck, to make it easier, I'm running this on the CC.net server itself!  So any kind of local-process querying is fine.
I know I can grab the status page as HTML, and then grep that or something, but it seems awkward (especially as this is Windows).  Is there an easier way?

A: Yes, if you don't mind writing some code you should be able to write a wrapper around ThoughtWorks.CruiseControl.Remote.dll if you poke around the source for CCTray you'll see that it is calling ICruiseManager.GetProjectStatus() which will give you a ProjectStatus array containing each of the active projects, from there you should have all you need.


text:
Q: How to make quantized tflite support tf.pow function? Because the original tf.pow function cannot be quatilized. So I want to adjust the implementation method of the pow function so that tflite can support the pow function.
The original method of Pow function is
Po = Pi ^ gamma

changed to
ln (Po) = gamma * ln (Pi)

so,
Po = exp ^ ( gamma * ln (Pi) )

In this way, the power function can be replaced by exp function and ln function.
Because Taylor expansion only needs multiplication and addition to calculate exp function and ln function, tflite provides multiplication and addition.
I just need the range 0~1. The range of Taylor expansion of ln function (at x=1) is as follows:

I need all ranges less than 0. So I tried the exponential function of taylor expenditure in the subsection, as follows:

I also tried linear approximation of exponential function.

I still can't speed up the model with both methods.
Can anyone help me?

quantized tflite support function list:
https://github.com/tensorflow/tensorflow/tree/f9bdcd6d9c714fc5dde232ba3b8b0a5128a07516/tensorflow/lite/delegates/hexagon


text:
Q: converting/Casting ISingleResult - List values to DataTable without Looping I am using Linq to Sql. When My StoredProcedure Executing its result ll returned in form of IMultipleResults.
I am converting it to ISingleResults and It can be Casted as List.
So I need to Convert it to DataTable so That I can Bind it to Dataset and Pass the values to UI.
But I want such method where I can convert it without LOOP.
Please Any body Help me.
For Any Clarification Contact me.
Thanking you.

A: First you might want to see if you could cast your list to a BindingList, or do something like this:
BindingListX = New BindingList(Of elementX)(QueryResult.ToList())

You might be able to bind with that.  If that doesn't work though here's another question:  Do you want to not use a loop in your code at all, or just not see a loop in your code?  It is possible to create an extension function that does the conversion:
public static class HelperFunctions
    {
        public static void Map<T>(this IEnumerable<T> source, Action<T> func)
        {
            foreach (T i in source)
                func(i);
        }

        public static DataTable ToDataTable<T>(this IEnumerable<T> source)
        {
            var dt = new DataTable();
            var properties = typeof(T).GetProperties();
            dt.Columns.AddRange(properties.Select(x => new DataColumn(x.Name, x.PropertyType)).ToArray());
            source.Select(x => dt.NewRow().ItemArray = properties.Select(y => y.GetValue(x, null)).ToArray()).Map(x => dt.Rows.Add(x));
            return dt;
        }
    }

But as you can see, the other extension function 'Map' is nothing more than a foreach that can be used inline.  If that is not what you want then I apologize and will try to come up with a different way.
It is also worth noting that I'm not sure if assigning to Item Array is the best way to populate a row so if it doesn't work then please let me know so that I may draft another version of the function.
Hope this helps!


text:
Q: How to access data in Docker from my Django app? I am new to Docker so I wonder if I have 2 containers, a streamer that pushes data to the queue and vernemq which is the message queue.
How can I access the data to work with it in my django rest api app?
I was wondering is there a way to export or the data and create a separate database in django with it or it's not how it works?
Or is there a way to directly access the data in docker from django app.
Note the django rest api app is not in a docker Image.

A: depends on how your current Django REST API is configured... if is looking at a Database? is it looking at a series of other your companies RESI APIs, etc?
I can edit this with more info once I  get a little more details. Don't have enough reputation to write a comment.
BUT I would say the best way if the Django app is looking at a database is to write a script to transfer code from the messaging queue and save to the database.
What I would say though is instead of using a message queue to just have the streamer push it directly to where you have your Django app looking.


text:
Q: POST request from Node to another server with windows credentials I am trying to send a post request to a service from my node server.
Node is running on http://localhost:3000. The method I am trying to reach is reachable through http://localhost:80/some/adress/business/layer/myMethod.
var options = {
    host: 'localhost',
    path: '/some/adress/business/layer/myMethod',
    port: '80',
    method: 'POST',
    headers: {
         'Content-type': 'application/json',
         'Content-Length': data.length
    }
};

var req = http.request(options, function (resu) {
    console.log('statusCode: ' + res.statusCode)

    resu.on('data', function (d) {
        console.log(d);
    });

    resu.on('error', function (err) {
                    console.log(err);
    });

    resu.on('end', function () {
        res.jsonp({ result: true });
        res.end();
    });
});

req.write("data");
req.end();

The request works fine, well more or less. I am getting a 401 status back. The question is: How can I send windows credentials from node to the named server running on localhost:80... ?

A: Without knowing the exact details of your setup, I can't be sure, but you probably need to use NTLM authentication. There are several libraries that do this for node. Take a look at this question. Hope this helps!


text:
Q: How can I drop explicit 0's from tf.SparseTensor? In each epoch of my model training, a tf.SparseTensor changes its values to have more explicit zeros. Removing such explicit zeros would make the number of explicit edges small, hence makeing the whole computation be faster.
So, I need a way to drop explicit zeros from tf.SparseTensor to make it more "slim". Does anyone know a way to do this?

A: You can solve this problem using the tf.sparse_retain() op:
st = ...  # A `tf.SparseTensor` object.

# Compute a vector of booleans indicating which values of `st` should be dropped
# (if False) or retained (if True)
is_nonzero = tf.not_equal(st.values, 0)

# `tf.sparse_retain()` computes a new `tf.SparseTensor` with the specified values
# retained in the output.
st_without_zeros = tf.sparse_retain(st, is_nonzero)


text:
Q: Broke pulse audio and permissions I had an issue where pulseaudio would only play sound of a single application at a time.  If you fired up ncmpcpp and then tried to play a game or play youtube, the latter would output no sound. (I never fixed this issue)
Upon some attempts to fix it I installed alsa-base which then blew up my audio installation.
I am running:
Ubuntu Server 16.06LTS with i3, but no desktop environment.
Things worked fine from a single audio source, but now I have all sorts of issues I'm not sure how to fix and google searches have failed me.
If I run pulseaudio, it'll fail with the following:
W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

The output of aplay -l is:
aplay: device_list:268: no soundcards found...

The output of sudo aplay -l is:
**** List of PLAYBACK Hardware Devices ****
Home directory not accessible: Permission denied
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC1150 Analog [ALC1150 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: ALC1150 Digital [ALC1150 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

pacmd won't work either, citing no daemon is running.
If I run pulseaudio -D then run pacmd, it tells me 0 sinks, and 0 cards are available.
I would love to prevent a full OS reinstall and set up so any help is much appreciated.

A: No, I wasn't trying to run as root as it'd throw an error.
I reinstalled the alsa-base and pulseaudio packages and restarted and it magically worked.  It also fixed the multi-input sound issue so things are fine, but I have no idea what I did to fix it.

A: Try export $(dbus-launch) before starting PulseAudio.


text:
Q: Why Pixel Bender filter behaves differently in Toolkit than in Flex/Air application? Ok, so I've tried this simpler filter with same Air code as below:
<languageVersion : 1.0;>

kernel NewFilter
<   namespace : "Your Namespace";
    vendor : "Your Vendor";
    version : 1;
    description : "your description";
>
{
    input image4 src;
    output pixel4 dst;

    void
    evaluatePixel()
    {
        pixel4 cPix  = sampleNearest(src,outCoord());
        pixel3 RGB = cPix .rgb;
        float r = RGB.r;
        float g = RGB.g;
        float b = RGB.b;
        //float minVal = min(r, g);
        dst = pixel4(r, g, b, 1);
    }
}

It turns out, that if I uncomment this line float minVal = min(r, g);, I do not get original picture any more, but this:
Result
Instead of this:
Original
If someone could explain this to me... I'd be very grateful...
//------------------------------------------------------------------
//------------------- ORIGINAL POST --------------------------------

I'm trying to make pixel bender filter for flex application, which changes selected range of hue values of input image to defined new hue value.
I made such filter in Pixel bender Toolkit, and it gives satisfactory results.
This is the code for that filter:
<languageVersion : 1.0;>

kernel ColorChange
<   namespace : "Your Namespace";
    vendor : "Your Vendor";
    version : 1;
    description : "your description";
>
{
    input image4 src;
    output pixel4 dst;

    parameter float HUE
    <
        minValue: 0.;
        maxValue: 359.9;
        defaultValue: 0.;
    >;
    parameter float SAT
    <
        minValue: -1.;
        maxValue: 1.;
        defaultValue: 0.;
    >;
    parameter float VAL
    <
        minValue: -1.;
        maxValue: 1.;
        defaultValue: 0.;
    >;

    parameter float MIN_RANGE
    <
        minValue: 0.;
        maxValue: 360.;
        defaultValue: 0.;
    >;

    parameter float MAX_RANGE
    <
        minValue: 0.;
        maxValue: 360.;
        defaultValue: 360.;
    >;

    void
    evaluatePixel()
    {
        pixel4 cPix = sample(src,outCoord());
        pixel3 RGB = cPix.rgb;
        float3 HSV;
        //--------------------------------------------------------------
        // CONVERT RGB TO HSV
        //--------------------------------------------------------------
        pixel1 r = RGB.r;
        pixel1 g = RGB.g;
        pixel1 b = RGB.b;

        pixel1 minVal = min(min(r, g), b);
        pixel1 maxVal = max(max(r, g), b);
        pixel1 delta = maxVal - minVal;
        HSV[2] = maxVal;
        if (maxVal == 0.) {
            HSV[0] = 0.;
            HSV[1] = 0.;
        }
        else
        {
            HSV[1] = delta / maxVal;
        }

        if(r == maxVal)
            HSV[0] = (g-b)/delta;
        else if(g == maxVal)
            HSV[0] = 2. + (b-r) / delta;
        else
            HSV[0] = 4. + (r-g) / delta;

        HSV[0] *= 60.;
        if(HSV[0] <0.)
            HSV[0] += 360.;

        //--------------------------------------------------------------
        // FILTER RANGE OF HUE
        //--------------------------------------------------------------
        if((HSV[0] < MIN_RANGE) || (HSV[0] > MAX_RANGE))
        {
            dst = cPix;
        }
        else
        {
            //--------------------------------------------------------------
            // CHNAGE HSV
            //--------------------------------------------------------------
            float hH = HUE;
            float sS = SAT;
            float vV = VAL;
            HSV[0] = HUE;
            HSV[1] += SAT;
            if(HSV[1] > 1.)
                HSV[1] = 1.;
            else if(HSV[1] < 0.)
                HSV[1] = 0.;
            HSV[2] += VAL;
                if(HSV[2] > 1.)
                    HSV[2] = 1.;
                else if(HSV[2] < 0.)
                    HSV[2] = 0.;
            //----------------------------------------------------------------------
            // CONVERT HSV TO RGB
            //----------------------------------------------------------------------
            float h = HSV[0];// / 360.;
            float s = HSV[1];// / 100. * 255.;
            float v = HSV[2];// / 100. * 255.;

            if (s == 0.) {
                RGB.r = v;
                RGB.g = v;
                RGB.b = v;
            } else {
                h = h / 60.;
                int var_i = int(floor(h));
                float f = h - float(var_i);
                float p = v * (1.-s);
                float q = v * (1.-s*f);
                float t = v * (1.-s*(1.-f));
                if (var_i == 0) {
                    RGB.r = v;
                    RGB.g = t;
                    RGB.b = p;
                }
                else if (var_i == 1) {
                    RGB.r = q;
                    RGB.g = v;
                    RGB.b = p;
                }
                else if (var_i == 2) {
                    RGB.r = p;
                    RGB.g = v;
                    RGB.b = t;
                }
                else if (var_i == 3) {
                    RGB.r = p;
                    RGB.g = q;
                    RGB.b = v;
                }
                else if (var_i == 4) {
                    RGB.r = t;
                    RGB.g = p;
                    RGB.b = v;
                }
                else {
                    RGB.r = v;
                    RGB.g = p;
                    RGB.b = q;
                }
            }
            dst = pixel4(RGB.r, RGB.g, RGB.b, 1);
        }
    }
}

So the principle is simple, convert every pixel to HSV color space, check if hue falls between selected range, if it does change it's hue to defined one and convert back to RGB.
The problem is, when used in Air application, I don't get the same results, starting from point of using only default parameters of filter.
This is the code of Air application:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       width="1400" height="800" backgroundAlpha="0.0" xmlns:mx="library://ns.adobe.com/flex/mx"
                       creationComplete="windowedapplication1_creationCompleteHandler(event)">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.events.ColorPickerEvent;
            import mx.events.FlexEvent;

            import spark.filters.ShaderFilter;
            import spark.utils.BitmapUtil;

            [Embed(source="myFilter.pbj", mimeType="application/octet-stream")]
            private var MyBender:Class;

            private var shader:Shader = new Shader();
            private var shaderJob:ShaderJob;
            private var shaderResult:BitmapData;

            private function filter():void
            {
                // Configure desired input parameters of shader.
                shader.data.src.input = originalImage.bitmapData;

//              shader.data.HUE.value = [H_slider.value];
//              shader.data.SAT.value = [S_slider.value];
//              shader.data.VAL.value = [V_slider.value];
//              shader.data.MAX_RANGE.value = [H_max_slider.value];
//              shader.data.MIN_RANGE.value = [H_min_slider.value];

                shaderJob = new ShaderJob(shader, shaderResult);
                shaderJob.start(true);
                bendedImage.source = new Bitmap(shaderResult);
            }

            private function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
            {
                // Create new shader instance and initialize with embedded byte code.
                shader = new Shader(new MyBender());
                shaderResult = new BitmapData(originalImage.width, originalImage.height);
                filter();
            }

        ]]>
    </fx:Script>
    <s:HGroup width="100%">
        <s:Group id="originalGroup" width="100%">
            <s:Image id="originalImage" source="mandelbrot.png"/>
        </s:Group>
        <s:Group id="bendedGroup" width="100%">
            <s:SWFLoader id="bendedImage" source="mandelbrot.png" />
            <s:HSlider id="H_slider" minimum="0" maximum="359.9" stepSize="0.1" value="0" change="filter()" width="500" toolTip="HUE"/>
            <s:HSlider id="S_slider" minimum="-1" maximum="1" stepSize="0.1" value="0" y="20" change="filter()" width="500" toolTip="SAT"/>
            <s:HSlider id="V_slider" minimum="-1" maximum="1" stepSize="0.1" value="0" y="40" change="filter()" width="500" toolTip="VAL"/>
            <s:HSlider id="H_max_slider" minimum="0" maximum="360" stepSize="0.1" value="360" y="60" change="filter()" width="500" toolTip="HUE MAX"/>
            <s:HSlider id="H_min_slider" minimum="0" maximum="360" stepSize="0.1" value="0" y="80" change="filter()" width="500" toolTip="HUE MIN"/>
        </s:Group>
    </s:HGroup>
</s:WindowedApplication>

So, applying PixelBender filter in Air app with default parameters produces this:
http://i.stack.imgur.com/UyoZR.png
But in Pixel Bender Toolkit i see this with same parameters:
http://i.imgur.com/LNnCi.png
Changing HUE_MAX slider in app (binded to MAX_RANGE parameter of filter), it doesn't filter out HUE values smoothly, but instead thresholds at HUE_MAX=59.9, where at lower values looks like no filter is applyed, and at HUE_MAX=299.9 where between 60 and 299.9 looks like this:
http://i.stack.imgur.com/5kePu.png (sorry, new user)
Any ideas what am I doing wrong?

A: min function does somenthing to its parameters which i cannot explain.
But the problem is solved when using
pixel1 minVal = r;
if(g < minVal)
minVal = g;
if(b < minVal)
minVal = b;

instead of
pixel1 minVal = min(min(r, g), b);

A: You have a lot of float comparisons in your PB code. Lines like this:
if (maxVal == 0.)

are extrenely susceptable to rounding errors. I suggest using something like this instead:
if (abs(maxVal) < epsilon)

A: Your AS code has the lines that set the parameter values commented out. Can you try commenting them back in and set the values to the defaults. The default values you put into a PB file aren't automatically set by the runtime, they're just meant as hints to the UI.


text:
Q: Swift 4: How to update image Property? Can someone help me fix the code below so that the image data property is updated properly and getImage() is not returning nil? Also, after the image is downloaded, the image data property of the Photo object should be updated and save the context. I am using SimSim to view the content of the database. After loading the photo album, the image data column is showing NULL values.
Thank you in advance!!
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionPhotoCell", for: indexPath) as! PhotoCollectionCell
    let photo = photos[(indexPath as NSIndexPath).row]

    if let getImage = photo.getImage() {
        cell.photoImageView.image = getImage
    } else {
        // Photo Placeholder
        cell.photoImageView.image = UIImage(named: "imgPlaceholder.png")

        // Activity Indicator
        cell.activityIndicator.isHidden = false
        cell.activityIndicator.startAnimating()
        FlickrClient().imageData(photo) {
            (imageData, error) in
            guard error == nil else {
                return
            }

            DispatchQueue.main.async {
                cell.activityIndicator.isHidden = true
                cell.activityIndicator.stopAnimating()
                cell.photoImageView.image = UIImage(data: imageData!)
            }
        }
    }
    cell.photoImageView.alpha = 1.0
    return cell
}


text:
Q: Validation rule to compare the queue name with a Custom object field I need to create a validation rule to compare the text field value (which is input type) with the Queue list present in my org and if the Text field value is not present the into the Queue List then need to give error message.
Thanks in Advance.

A: If you strictly want to NOT use code.  Then the option I can think of is to have a copy of Queue Names in Custom settings (hierarchical).  Your validation rules can access custom settings and hence you can validate.
Just make sure your Queues and Custom settings are always in sync if you prefer this approach.


text:
Q: Why isn't RandomSearchCV returning the optimum parameters for the XGBoost Model, and how can I avoid Overfitting? I have a dataset for energy consumer customers and binary target variables with which I want to predict the churn for the customers.
Counts of target values

*

*Not Churn 0: 14153

*Churn 1: 1520

I have trained XGBoost model with tree different strategies, but unfortunately model overfit the training dataset

*

*I split the data into 80/20 and trained the XGBoost model with the following parameters

model = xgb.XGBClassifier(
        learning_rate = 0.1,
        max_depth = 6,
        n_estimators = 500,
        n_jobs = -1,
        min_child_weight = 9
)

Result:
Accuracy:  0.9132431742791528
Precision:  0.7323943661971831
Recall:  0.13941018766756033
AUC Test: 0.709404
AUC Train: 0.989078

*Same model but with StratifiedKFold

StratifiedKFold(n_splits=5, random_state=13, shuffle=True)
AUC Train: 0.986
AUC Test: 0.712

--- UPDATED TEXT
3. Same Model but with additional parameters to add complexity
parameters = {'subsample': 0.8,
 'scale_pos_weight': 1,
 'n_estimates': 1100,
 'min_child_weight': 1,
 'max_depth': 12,
 'learning_rate': 0.01,
 'gamma': 4.0,
 'colsample_bytree': 0.60}

AUC Train: 0.7238
AUC Test: 0.6568

The Question here is following

*

*obviously, the model overfits the training example. How can I reduce the overfitting? I was reading the article that adding more parameters to the model would probably do that, but how can I select parameters? this would be the hit and trial method. What is the best way?

*I got the best parameters from RandomSearchCV for the third model, but with those values, I got AUC-test and Train 0.5 both, which is strange because it is supposed to give me the best parameters and the best AUC score. After getting unsuccessful results, I updated parameter values on my own and didn't use the Best_parameters_ given by Random CV. Why isn't it providing me with the best parameters?


text:
Q: Basic programmation : My function doesn't return the expected output (Angular - firebase - JavaScript) I'm probably going to ask something very easy. I'm a beginner in programming. I have a function called getUserName.
I initialized an output "Hello my friend". I'm using function into my function but my output is not changing. At the end, I'm returning the same "Hello my friend" output while I should get a LastName.
  getUserName(){
    this.output='Hello my friend';
    firebase.database().ref('/users/').orderByChild("email").equalTo('test1@test.com').on('value', function (snapshot) {
       //snapshot would have list of NODES that satisfies the condition
          console.log(snapshot.val())
        console.log('-----------');

       //go through each item found and print out the lastName
       snapshot.forEach(function(childSnapshot) {

            var key = childSnapshot.key;
            var childData = childSnapshot.val();
              //this will be the actual lastName value found
              console.log(childData.lastName);

              //Here my console.log is not working, this.output doesn't take the lastName value.
              this.output = childData.lastName;
              console.log("Not working one : " + this.output);
        });
  });
        return this.output;
  }

A: Yes this issue is happening because of the return itself.
Code execution flow is like below
1) called method and intialized the output variable
2) called async operation as it is async it wont wait for it operation to get completed
3) return output
4) async operation might received response from firebase and it print console and assign the value to output variable but it is of no use because method already returned output in step three
Solution:
1) use async await concept and make your async operation complete fully
 2) change return statement inside the subscription


text: Q: HttpActionContext storage location for life of request I have a HttpActionContext (WebApi) and am looking for a place to store a piece of information for the life of the request.  I found HttpActionContext.Request.Properties is this a good place, or is there a better place?


text:
Q: How to easily copy SQL Statements from multiple extended events like I used to do in SQL Profiler? One thing I miss from using SQL Profiler is selecting multiple rows in profiler (looking at Batch Completed and RPC Completed events) and seeing all the SQL in the below panel, i.e. as one combined text field with all the SQL statements. I could copy it all and paste into SQL Management Studio and work on it there. Is there an easy way to do similarly with Extended Events?
When I do an extended events session, e.g. using XEvent Profiler > Standard, it's a much less friendly UX to get all the SQL Statements generated. I have to double-click on each one, click the Copy All button on the popup, close that popup, then double-click on the next row. I could right-click on the row and choose Copy > Cell but that doesn't preserve line breaks in the copied text. If I've got more than a few events this isn't fun.
Am I missing something? How does everyone else use Extended Events without becoming super frustrated with the UX? I'm such an occasional user of it I've put off learning all the ins and outs of scripting event sessions and doing clever things with the results.

A: There is a way to move the fields from the detail page down below, up to the grid above. Once it's in the grid, you can sort, filter, group, export, pretty much anything you want.
There are a couple of ways to do this. One is, right click on the field in the bottom pain. In the context menu, select "Show column in table". That will move it up to the top where you can control things from there. Second method is to look at the tool bar for the Data Explorer window. There's a button there, near the far right side by default, labeled "Choose Columns...". Selecting that will open a window showing all the fields for the events currently captured. You can pick which ones you want in the upper table.
From there, it's just a question of using the table functions. Look again to the toolbar for all the stuff I mentioned above. For more details, here is a video I did for GroupBy. There is a whole bunch of other stuff at my blog on this topic.


text:
Q: Http cache by vary on a custom header I'm researching http cache by using Vary header, my website has to serve a response content base on a user preferred currency, they can choose displayed currency from the currency selection on my site and I'm using session to store their chosen currency instead of using query parameter in the url.
I want to cache responses base on currencies, I created the custom header for every response x-currency: currency_value and set the vary header vary: x-currency, to tell the http cache to create a different cached content by currency.
but I don't understand at the point, when a user send a request to the http cache, that request header is not included the custom header x-currency: current_value, so how the http cache knows a preferred currency to serve the correct response to user ?
I also think about vary on cookie, but it seems to serve a cached response to unique user not for the group of users that have the same preferred currency.
please show me what I misunderstood or any alternative solutions to achieve that !

A: You have misunderstood what header the Vary header should indicate. Vary:

describes what parts of a
request message, aside from the method, Host header field, and
request target, might influence the origin server's process for
selecting and representing this response.

In this case, you say you're:

using session to store their chosen currency

That means that the response you're selecting is influenced by the Cookie header that the user's session was sent in. You should therefore send:
Vary: cookie

in the response.
As a point of design, you mention that you've chosen session storage:

instead of using query parameter in the url.

and also mention:

I also think about vary on cookie, but it seems to serve a cached response to unique user not for the group of users that have the same preferred currency.

You're right. Using a query parameter would be significantly more cacheable, as requests for the same currency could be reused. Vary: cookie is essentially the same as Cache-control: private, as no two users will have the same session cookie.


text:
Q: How to build apple's opensource libc? I'm trying to build apple's opensource libc (from http://www.opensource.apple.com/source/Libc/Libc-763.11/) on my OS X 10.6.8 laptop. This is in an attempt to essentially get a locally generated replica of /usr/lib/libSystem.B.dylib, which I intend to experiment on further.
I see a couple basic roadblocks though (unless, obviously, I'm missing something basic):

*

*No instructions on how to do the build. There are a couple of Makefiles in the URL I reference above, but they fail to build when I try to do straightforward makes:

$make -f Makefile
Makefile:14: *** missing separator.  Stop.

*

*I suspect the source available for download is incomplete. Not incomplete in the sense that Apple isn't revealing all of the changes, but incomplete in the sense that there are source files that were (presumably) not modified by Apple, so isn't included in the collection. For example, I don't see the implementation of the "open" call (which, in the gnu libc hierarchy, is available at io/open.c)

The closest reference I could find after some googling was this: http://www.projectosx.com/forum/index.php?showtopic=1922&st=0&p=12457&#entry12457 but it still isn't close enough for my taste!
Any pointers?
Thanks!

A: Only some general pointers (although some links are discussing older OSX versions):

*

*http://darwinbuild.macosforge.org/trac/ticket/6

*http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-projects/darwin/overlay/sys-libs/libc-darwin/libc-darwin-391.ebuild?view=markup&sortby=log

*http://althenia.net/wiki/darwin#standard_library_libc

*http://dev.gentoo.org/~vapier/CROSS-COMPILE-GUTS

*http://www.raccoonfink.com/fink/darwin-cross/