text:
Q: [HTML DOM].style undefinded? (html5 app: address book) so basically I can't figure out why is giving me the folling error, when I call add() function (when you click on add button)...
it says: status.style is undefined
status is an html dom, an  html tag
I think the error is located almost at the end of the sheet

var myArray = []; // * used to store all the data
myArray[0] = ['John', 'Doe', '1980'];
myArray[1] = ['Jane','Malloy','1982'];
myArray[2] = ['Vincent','Malloy','1988'];

var firstName = document.getElementById('firstName');
var secondName = document.getElementById('secondName');
var bornYear = document.getElementById('bornYear');
var output = document.getElementById('output');
var form1 = document.getElementById('form1');
var status = document.getElementById('status');

var add = function() { //calls statusMessagge()

 // check if input[] its not empty...
 if ( firstName.value.length>0 && secondName.value.length>0 && bornYear.value.length>0 ) {
  // * adding inputs to myArray
  myArray[myArray.length] = [firstName.value ,secondName.value ,bornYear.value ];
  //clearBoxes();
  // * status messagge
  statusMessagge('good');
  alert('is good');
 }
 else {
  statusMessagge('bad');
  alert('is bad');
 }
};

var statusMessagge = function(arg) { // * it is been called by: add(), show()

 // * selecting the messagge to appear
 switch (arg) {
  case 'good':
   status.innerHTML = 'Person added successfully.';
   break;
  case 'bad':
   status.innerHTML = 'Please fill all the fields.';
   break;
  case 'loading':
   status.innerHTML = 'Loading...';
   break;
  case 'loaded':
   status.innerHTML = 'Finish.';
   break;
 }

 // * do opacity effect slow: show|hide
 status.style.opacity = 1; // this is the part that I get the error.
 setTimeout (function() {
  status.removeAttribute('style');
 }, 1000);
};
body {
 background: lightgray;
 font-family: consolas;
 font-size: 13px;
 padding: 0;
 margin: 0;
}
main {
 background: #dbcdcd;
 margin: 0 auto;
}
form:nth-of-type(1) {
 float: left;
}
form:nth-of-type(2) {
 float: left;
}
label { /* for alining elements correctly */
 display: inline-block;
 width: 77px;
 text-align: right;
}
input[type="text"]:not(:first-of-type) {
 margin-top: 5px;
}
#status {
 opacity: 0;
 transition: opacity .20s;
 clear: both;
}
<!doctype html>

  <title>.:_My Exercise_:.</title>
  <link rel="stylesheet" type="text/css" href="style.css"/>
  <meta charset="utf-8"/>

   <form id="form1" action="">
    <fieldset>
    <legend>Please introduce new person...</legend>

     firstName:
     <input id="firstName" type="text" autofocus tabindex="1"/>
     <input type="button" value="Add" onclick="add()"/>

     secondName:
     <input id="secondName" type="text" tabindex="2"/>
     <input type="button" value="Show" onclick="show()"/>

     bornYear:
     <input id="bornYear" type="text" tabindex="3"/>
     <input type="button" value="Sort" onclick="sort()"/>
    </fieldset>
   </form>

   <form>
    <fieldset>
    <legend>Sort...</legend>
     <input type="button" value="a-z" onclick=""/>
     <input type="button" value="z-a" onclick=""/>
    </fieldset>
   </form>

A: Different approach:
I run your code on chrome, with one difference: run script.js after event 'DOMContentLoaded', the event holds your script until browser informs that loaded all html:

document.addEventListener('DOMContentLoaded', function(){

var myArray = []; // * used to store all the data
myArray[0] = ['John', 'Doe', '1980'];
myArray[1] = ['Jane','Malloy','1982'];
myArray[2] = ['Vincent','Malloy','1988'];

var firstName = document.getElementById('firstName');
var secondName = document.getElementById('secondName');
var bornYear = document.getElementById('bornYear');
var output = document.getElementById('output');
var form1 = document.getElementById('form1');
var status = document.getElementById('status');

window.add = function() { //calls statusMessagge()

 // check if input[] its not empty...
 if ( firstName.value.length>0 && secondName.value.length>0 && bornYear.value.length>0 ) {
  // * adding inputs to myArray
  myArray[myArray.length] = [firstName.value ,secondName.value ,bornYear.value ];
  //clearBoxes();
  // * status messagge
  statusMessagge('good');
  alert('is good');
 }
 else {
  statusMessagge('bad');
  alert('is bad');
 }
};

var statusMessagge = function(arg) { // * it is been called by: add(), show()

 // * selecting the messagge to appear
 switch (arg) {
  case 'good':
   status.innerText = 'Person added successfully.';
   break;
  case 'bad':
   status.innerText = 'Please fill all the fields.';
   break;
  case 'loading':
   status.innerText = 'Loading...';
   break;
  case 'loaded':
   status.innerText = 'Finish.';
   break;
 }

 // * do opacity effect slow: show|hide
 status.style.opacity = 1; // this is the part that I get the error.
 setTimeout (function() {
  status.removeAttribute('style');
 }, 1000);
};
});

In function statusMessagge() you assign status with string, so it isn't html element anymore.
Try do:
status.innerText = 'some text';

A: I think that what you want is to display a message in console. Use console.log() for that. It worked in Firefox for me.
Example:
// ... (your previous code)
if ( firstName.value.length>0 && secondName.value.length>0 && bornYear.value.length>0 ) {

    myArray[myArray.length] = [firstName.value ,secondName.value ,bornYear.value ];

    console.log("good");
    alert('is good');
}
else {
    console.log("bad");
    alert('is bad');
}
// ...

A: I passed the element through to the statusMessage function allowing me to set it's innerHTML value.
We get the elements on the time of click rather onload to prevent the variables to be undefined.

var myArray = []; // * used to store all the data
myArray[0] = ['John', 'Doe', '1980'];
myArray[1] = ['Jane','Malloy','1982'];
myArray[2] = ['Vincent','Malloy','1988'];

var add = function() { //calls statusMessagge()
var firstName = document.getElementById('firstName');
var secondName = document.getElementById('secondName');
var bornYear = document.getElementById('bornYear');
var output = document.getElementById('output');
var form1 = document.getElementById('form1');
var status = document.getElementById('status');
 // check if input[] its not empty...
 if ( firstName.value.length>0 && secondName.value.length>0 && bornYear.value.length>0 ) {
  // * adding inputs to myArray
  myArray[myArray.length] = [firstName.value ,secondName.value ,bornYear.value ];
  //clearBoxes();
  // * status messagge
  statusMessage(status, 'good');
 }
 else {
  statusMessage(status, 'bad');
 }
};

var statusMessage = function(element, arg) { // * it is been called by: add(), show()
    element.style.opacity = 1;
 switch (arg) {
  case 'good':
   element.innerHTML = 'Person added successfully.';
            break;
  case 'bad':
   element.innerHTML = 'Please fill all the fields.';
            break;
  case 'loading':
   element.innerHTML = 'Loading...';
            break;
  case 'loaded':
   element.innerHTML = 'Finish.';
            break;
        default:
            element.innerHTML = "";
            break;
 }
 // * do opacity effect slow: show|hide

 setTimeout (function() {
  element.removeAttribute('style');
 }, 1000);
};
body {
 background: lightgray;
 font-family: consolas;
 font-size: 13px;
 padding: 0;
 margin: 0;
}
main {
 background: #dbcdcd;
 margin: 0 auto;
}
form:nth-of-type(1) {
 float: left;
}
form:nth-of-type(2) {
 float: left;
}
label { /* for alining elements correctly */
 display: inline-block;
 width: 77px;
 text-align: right;
}
input[type="text"]:not(:first-of-type) {
 margin-top: 5px;
}
#status {
 opacity: 0;
 transition: opacity .20s;
 clear: both;
}
<!doctype html>

  <title>.:_My Exercise_:.</title>
  <link rel="stylesheet" type="text/css" href="style.css"/>
  <meta charset="utf-8"/>

   <form id="form1" action="">
    <fieldset>
    <legend>Please introduce new person...</legend>

     firstName:
     <input id="firstName" type="text" autofocus tabindex="1"/>
     <input type="button" value="Add" onclick="add()"/>

     secondName:
     <input id="secondName" type="text" tabindex="2"/>
     <input type="button" value="Show" onclick="show()"/>

     bornYear:
     <input id="bornYear" type="text" tabindex="3"/>
     <input type="button" value="Sort" onclick="sort()"/>
    </fieldset>
   </form>

   <form>
    <fieldset>
    <legend>Sort...</legend>
     <input type="button" value="a-z" onclick=""/>
     <input type="button" value="z-a" onclick=""/>
    </fieldset>
   </form>


text:
Q: what are the commands that will create this git graph hello guys I am new to git and I am working on a project where I need to respect this graph I just want to know what can I do to get this git graph what are the commands and with explanation please
All I know that every vertex is a commit all the labels are branch names
I don't know where to start like do I need to create all branches before or what it's not clear at all

A: git init                                 # initialize a git repo
git commit --allow-empty -m foo          # create a commit with message "foo"
git checkout -b feature1                 # create and check out a branch named "feature1" from the current commit
git commit --allow-empty -m bar          # create a commit with message "bar"
git checkout -b feature2                 # create and check out a branch named "feature2" from the current commit
git commit --allow-empty -m baz          # create a commit with message "baz"
git checkout -b feature3                 # create and check out a branch named "feature3" from the current commit
git commit --allow-empty -m qux          # create a commit with message "qux"
git checkout master                      # check out branch "master"
git commit --allow-empty -m toto         # create a commit with message "toto"
git merge -m 'merge feature 1' feature1  # merge feature1 with message "merge feature 1"
git merge -m 'merge feature 2' feature2  # merge feature2 with message "merge feature 2"
git merge -m 'merge feature 3' feature3  # merge feature3 with message "merge feature 3"

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can i do a javascript timer that show div at the end of the timer for few second and repeat it I added my code that I am using (based on other question here)
for now it is not works for me because there is no sync between the interval and the div
I tried without success these steps : 60 sec timer starting,
after 60 sec the clock will be remove and other div will show,
 and after 3 second that the new div shown the clock will start again(and the second div will disappear  and ... etc
Thank you
    $("#div1").hide();

        var count=5;

        var counter = setInterval(timer, 1000);

        function timer()
        {
          count=count-1;

          if (count <= 0)
          {
            clearInterval(counter);
                $("#div1").fadeIn("slow");
                $("#div1").delay(3000).fadeOut("slow");
                myTimeoutFunction();

             count = 5;
             //counter ended, do something here
             // return;
          }
            console.log(count);
          //Do code for showing the number of seconds here
        }

        function myTimeoutFunction()
        {
            console.log("test");

        }

       });

    </script>

 3

A: counter not appear rest after calling clearTimeout(counter)
Try chaining .delay() to .fadeIn() , using complete callback of .fadeOut() to reset count ,  counter , call MyTimeoutFunction

<!doctype html>

    3

A: Understanding :

*

*1 second ticker.

*Every 5 ticks, stop the ticker, perform an animation-delay-animation sequence, then restart the ticker.

*Do something at a certain point in the cycle.

The basic animation-delay-animation sequence can be coded as :
$("#div1").fadeIn('slow').delay(3000).fadeOut('slow')

However, the interesting part of the problem is to "do something at a certain point in the cycle" as the cycle affords several cardinal points at which something might be done, not just the one indicated in the question. To this end, you might choose to implement the animation-delay-animation sequence as a promise chain, in which the sequence is split into its individual components, giving access to the cardinal points.
jQuery's .promise() method makes writing a promise chain very simple.
The following code affords a comprehensive set of opportunities to "do something" :
var $div1 = $('#div1').hide(),
    count, counter;
function startTicker() {
    // Start of a fresh 5 second countdown - possibly do something here.
    count = 5;
    counter = setInterval(ticker, 1000);
}
function ticker() {
    if (--count <= 0) {
        // Counter ended
        clearInterval(counter);
        doAsynchronousStuff().then(startTicker);
    }
    // Do code for showing the number of seconds here.
}
function doAsynchronousStuff() {
    // Before fadeIn starts - possibly do something here.
    return $div1.fadeIn('slow').promise()
    .then(function() {
        // After fadeIn completes but before delay starts - possibly do something here.
        return $div1.delay(3000).promise();
    })
    .then(function() {
        // After delay but before fadeOut starts - possibly do something here.
        return $div1.fadeOut('slow').promise();
    });
}

startTicker(); // start the cycle

Other approaches exist, but a promise chain avoids deep nesting of callback functions.
To make ticker() clearer, the asynchronous tasks appear in a separate function doAsynchronousStuff(), which returns a promise to ticker(). Thus ticker() is able to execute doAsynchronousStuff().then(startTicker), ie call doAsynchronousStuff() and start another cycle on completion of all the asynchronous tasks.


text:
Q: How to add custom directory in URL for app hosted locally on IIS? I have the following situation for testing purposes my app is hosted on IIS on my machine and when I direct the physical path to the solution folder not the direct folder of the project when I try to access the .aspx file of the site I get the following error:

The URL (it uses https protocol) is as it should be:

localhost:159/SalesforceV5RapidSearch/RapidSearch.aspx?

The bolded folder must be there because on the staging server the URL is generated automatically and I have to make it work locally with this url. To the core of the problem when I direct the physical path to the project folder everything works and the Urls is localhost:159/RapidSearch.aspx? the thing is I need that path to be the same as the above URL.
The given error is because the <authentication> element can be set only in the global web.config not in any of the subfolders and when I direct the path to the directory of the solution the web.config used is in a subfolder. Even if I put the project in two folders to make the URL the same it returns the same error because the web.config is again in a subfolder and the IIS does not recognize it as global.

A: Make sure you have installed all the required authentication features of the IIS server and have actually published the website in the IIS.

A: I found a solution it was to add a web application to the hosted web site in IIS which application leads to the directory in that way the URL is as it should be localhost:159/SalesforceV5RapidSearch/RapidSearch.aspx?


text:
Q: Angular 8 two areas with other templates How I can to use 2 other templates for my WEB?
I have Admin Area and Public Area, so for Admin I want to use - Dashboard Layout ( for example ) and it's should have access only for logged users, and Landing Page Layour for Public Area ( for all users ).
I just can't find solution in google
Can you, please, show architecure for project like this or take me some recommendations?


text:
Q: how to separate array while parsing the json jquery? I am parsing the json .Actually I need to find property from json. In my json I have two nested array (list, array).I need to get there separate value .But I am getting all value in an array can we split array "list" array in separate array   ."array" in separate array.
I am getting this out put :
33, 44, 23, 11
Here is my fiddle :
http://jsfiddle.net/f5Awq/
var arrayLabel=new Array();
var listLabel=new Array();

function recursiveIteration(object, callback, data) {
  for (var property in object) {
    if (object.hasOwnProperty(property)) {
      if (typeof object[property] == "object"){
        recursiveIteration(object[property], callback, data);
      }
      else {
        callback(object, property, data);
      }
    }
  }
}
function test_cb(object, property, data) { console.log(property);
  if(property == data.filter && object[property]){
    data.array.push(object[property]);
  }
}

recursiveIteration(json, test_cb, {filter: 'label', array: arrayLabel});

console.log(arrayLabel);

document.body.textContent = arrayLabel.join(', ');

I am getting out put in arrayLabel: 33, 44, 23, 11
My expected out put :
arrayLabel :33, 44.
   listLabel is 11,23
33, 44 because they are in "array".and 11,23 in list in my json.can we add condition ?

A: I hope youneed this:
var arrayLabel = {'list':[],'array':[]};
var listLabel = new Array();

function recursiveIteration(object, callback, data,parent) {
    parent=parent||'root';
    for (var property in object) {
        if (object.hasOwnProperty(property)) {
            if (typeof object[property] == "object") {
                if (['list','array'].indexOf(property)>=0) {parent=property;} //the condion you looked for
                recursiveIteration(object[property], callback, data,parent);
            } else {
                callback(object, property, data,parent);
            }
        }
    }
}

function test_cb(object, property, data,parent) {
    if (property == data.filter && object[property]) {
        data.array[parent].push(object[property]);
    }
}

so, I recording the current "legal" parent name and accumulate it to data. You can easy make it an option.
http://jsfiddle.net/oceog/f5Awq/1/


text:
Q: jQuery's getScript - including files into the main scope? I have thought a lot about how I should include files in my backbone.js-application. In production, I am obviously going to join my files and minimize them to keep requests at a minimum, but during development, it would be nice to just have all files loaded and not having to call a buildscript for every little change.
So I have taken a look at jQuery's getScript()-method. I tried it out and were able to load my files.
As I've put the getScript-call into a function, to ensure that files are loaded before I initiate my backbone.js application, it appears that every script loaded, are not included into the global scope.
var loader = function () {
     var scripts = ['/app/routers/myrouter.js'];

     for (var i = 0; i < scripts.length; i++) {
         $.getScript(scripts[i], function () {});
     }

     console.log(myrouter); // Works - myrouter is a function
     init(); // Callback - we've loaded all scripts
 };

var init = function () {
    console.log(myrouter); // myrouter is undefined
};

$(document).ready(loader());

A: Well first of all, you are just calling loader() instead of passing the function:
$(document).ready(loader);

Will fix that
Secondly, you are calling the init callback right away instead of when all the scripts are loaded. If there are many scripts you need to use promises:
    var scripts = ['/app/routers/myrouter.js'];
    for (var i = 0; i < scripts.length; i++) {
        scripts[i] = $.getScript(scripts[i]);
    }

    $.when.apply( $, scripts ).then( init, function(){
        "some script failed";
    });

The syntax used above is $.when( promise1, promise2, ...).then( successCallback, failureCallback) - we fill the array with promises and use .apply to apply them as arguments.
http://api.jquery.com/jQuery.when/
http://api.jquery.com/Deferred.then/


text:
Q: Как избавить от белой полоски между виджетами установленными в QVBoxLayout Пытаюсь разобраться в контейнерах. Как я понимаю, контейнеры создают между добавленными в них виджетами некоторую рамку.
Как от нее избавиться?
from PyQt5.Qt import *
import sys

class Window(QWidget):
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)

        self.setMinimumSize(1000,500)

        self.top_bar = QFrame()
        self.content = QFrame()

        self.vbox = QVBoxLayout()
        self.vbox.setContentsMargins(0,0,0,0)

        self.top_bar.setStyleSheet("background-color: rgb(45,45,45);")
        self.content.setStyleSheet("background-color: rgb(35,35,35);")

        self.top_bar.setMaximumHeight(40)

        self.vbox.addWidget(self.top_bar)
        self.vbox.addWidget(self.content)

        self.setLayout(self.vbox)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())

A:
void QBoxLayout::setSpacing(int spacing)
Устанавливает для свойства spacing значение.

from PyQt5.Qt import *
import sys

class Window(QWidget):
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)

        self.setMinimumSize(1000,500)

        self.top_bar = QFrame()
        self.content = QFrame()

        self.vbox = QVBoxLayout()
        self.vbox.setContentsMargins(0,0,0,0)
        self.vbox.setSpacing(0)                                       # +++

        self.top_bar.setStyleSheet("background-color: rgb(45,45,45);")
        self.content.setStyleSheet("background-color: rgb(35,35,135);")

        self.top_bar.setMaximumHeight(40)

        self.vbox.addWidget(self.top_bar)
        self.vbox.addWidget(self.content)

        self.setLayout(self.vbox)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())


text:
Q: template with lambda as unique default parameter on each instantiation I'm looking for a way to automatically make default template parameter be unique each time a template is instantiated. Since unnamed function objects created by lambda expressions have different types I thought of adopting them somehow. With recent changes to standard daft removing "A lambda-expression shall not appear in ... a template-argument" restriction (see Wording for lambdas in unevaluated contexts) it seemed like a good idea. So I wrote the following kinda working snippet that compiles on recent gcc and clang:
#include <type_traits>

template<void ( * ) (void) = [](){}> class
unique final {};

static_assert(false == ::std::is_same_v<unique<>, unique<>>);

int main()
{
    return 0;
}

Is this a viable approach or one of those "ill-formed, no diagnostic is required" cases?
Some additional context: I want to use this to implement Ada-style strong type definitions that should work in a single translation unit without manually inventing unique tags that would be otherwise unused:
struct _tag_WowInt {};
using Int = type<int, _tag_WowInt>;
struct _tag_SoUnique {};
using DifferentInt = type<int, _tag_SoUnique>;

Upd1: I would like to mention that approaches involving __COUNTER__ or similar macros won't work in general case because they will be expanded by preprocessor only once and won't yield unique types when used inside of template for example.

A: I believe that you are right, it seems to me that is "ill-formed, no diagnostic required". I think this is covered by
[temp.res/8.4] and [temp.res/8.5]:

(8.4) ― a hypothetical instantiation of a template immediately following its definition would be ill-formed due to
  a construct that does not depend on a template parameter, or
(8.5) ― the interpretation of such a construct in the hypothetical instantiation is different from the interpretation
   of the corresponding construct in any actual instantiation of the template. [Note: This can happen in situations including the following:
(8.5.1) ― a type used in a non-dependent name is incomplete at the point at which a template is defined but is complete at the point at which an instantiation is performed, or
(8.5.2) ― lookup for a name in the template definition found a using-declaration, but the lookup in the corresponding scope in the instantiation does not find any declarations because the using-declaration was a pack expansion and the corresponding pack is empty, or
(8.5.3) ― an instantiation uses a default argument or default template argument that had not been defined at the point at which the template was defined, or
(8.5.4) ― constant expression evaluation within the template instantiation uses
(8.5.4.1) ― the value of a const object of integral or unscoped enumeration type or
(8.5.4.2) ― the value of a constexpr object or
(8.5.4.3) ― the value of a reference or
(8.5.4.4) ― the definition of a constexpr function,
  and that entity was not defined when the template was defined, or
(8.5.5) ― a class template specialization or variable template specialization that is specified by a non-dependent simple-template-id is used by the template, and either it is instantiated from a partial specialization that was not defined when the template was defined or it names an explicit specialization that was not declared when the template was defined.
  — end note]

Even though your use case is not explicitly listed in the examples of the note, in my understanding the requirement implies that unique<> must refer to the same thing throughout the whole program, otherwise it is ill-formed, no diagnostic required.
This was CWG1850. The Committee appear to dislike this
kind of stateful meta-programming. The constexpr counter no longer works
in newer versions of the compilers.


text:
Q: Building XP drivers from VS2013 I have VS 2013 + WDK installed on my PC and I've been trying to create a driver for XP.
So I created a new KMDF Driver project from Visual Studio menu and changed the platform toolset to XP:

Basically I just tried the most basic template:
#include <ntddk.h>
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
    DbgPrint("Hello World\n");
    return STATUS_SUCCESS;
}

However, when I change it I'm getting an error:
C1083: Cannot open include file: 'ntddk.h': No such file or directory

Can anyone tell me what I'm doing wrong?
Or at least how I can compile a driver to support Windows XP?
Thanks a lot.

A: v120 present a user mode develop kits, you should use kernaldriver8.1.
And if you want to write a driver use both in xp and win7 , WDM is your best choice.


text:
Q: How to read subdirectory data into bigsql table? Bigsql is not able to read data from subdirectory like hive can by setting parameters.
set tblproperties (
    "hive.input.dir.recursive" = "TRUE",
    "hive.mapred.supports.subdirectories" = "TRUE",
    "hive.supports.subdirectories" = "TRUE",
    "mapred.input.dir.recursive" = "TRUE")

I tried adding above parameters into bigsql tableproperties but it's not able to read subdirectory data.
What parameters I need to set in bigsql to read subdirectory data?

A: As per my understanding, Bigsql only looks up for files in parent directory. It doesn't even bother checking sub-directories. It will display an empty table because it cannot read the data recursively.This feature is still under product improvement ideas with IBM product and engineering team.


text:
Q: Api to Generate Reports in mylyn, Tasktop Pro I have been an active user for tasktop Pro. I admire its simplicity and robustness. I am specially impressed with the time tracking options it provides.
I was feeling a need to use command line / batch / shell script / maven / ant or any other automator tools which allows me to create reports without the need to visit the 'Create Personal report' in Tasktop Pro. Is there any form of API available to access those resources?

A: Unfortunately, there is no API available for accessing time tracking data. You could consider opening a request for this feature at https://tasktop.com/bugs


text:
Q: byte to string error in for loop I have variable called out and I stored value there is:
b'0,0.0372549,0.00653595,0,0.00490196,0.00653595,0.897386,0.00653595,0.0294118,0.00653595,0,0,0,0,0,0.00490196,0,0,0,0\n0,0.0158333,0.0179167,0.00277778,0.116111,0.327083,0.0265278,0.174167,0.0623611,0.116806,0.055,0.0270833,0,0,0.01875,0.0333333,0,0,0,0.00625\n0,0.997554,0.00133297,4.75327e-05,0.000118379,6.65359e-05,0.000253487,0.000141784,0.000183293,0.000220498,7.08961e-05,0,0,0,0,0,1.10967e-05,0,0,0\n0,0.082346,0.890084,0,0.000346861,0.0161043,0.0105323,0.000354988,0.00011562,0.00011562,0,0,0,0,0,0,0,0,0,0\n0,0.654957,0.306633,0,0.00150356,0.000466853,0.00273321,0.000933707,0.00233427,0.00186741,0,0,0,0,0.0190476,0.00952381,0,0,0,0\n0,0.429955,0.0543849,0.106071,0.0297159,0.0876241,0.16761,0.0435997,0.0293692,0.0167052,0.00492931,0.0143504,0.00664048,0.00127352,0.000520984,0.00405789,5.78871e-05,0,0,0.00313481\n0,0.372212,0.459023,0.00909091,0.0183902,0.00273224,0.0897315,0.00666667,0.0163417,0.000546448,0.000208333,0.00929924,0.00666667,0,0,0,0,0,0,0.00909091\n0,0.916784,0.0557399,0.00127288,0.0044239,0.00263795,0.00418008,0.00522153,0.00448012,0.0016537,0.0015471,0.00140777,0.00011532,4.21977e-05,4.21977e-05,5.76602e-05,0,0,0,0.000393295\n0,0.817223,0.10791,0.0119181,0.00617358,0.00279979,0.027469,0.00652177,0.00186348,0.00522515,0.0121172,0.000151166,0,0,0,0,0.00017316,0,0,0.000454545\n'
Now I am writing following code:
for p in out.rstrip().split('\n'):
    print(p)

Now I am getting following error:
TypeError: a bytes-like object is required, not 'str'
How to solve this error ? I tried unicoding but doesn't work. what would be the for loop code to get desired output.

A: To change it to a normal string permanently to remove the b:
out = out.decode("utf-8")

for p in out.rstrip().split('\n'):
    print(p)

A: You're trying to use "split" on a 'string', so you basically just need to remove 'b', or even use str(foo) before the loop:
foo = '0,0.0372549,0.00653595,0,0.00490196,0.00653595,0.897386,0.00653595,0.0294118,0.00653595,0,0,0,0,0,0.00490196,0,0,0,0\n0,0.0158333,0.0179167,0.00277778,0.116111,0.327083,0.0265278,0.174167,0.0623611,0.116806,0.055,0.0270833,0,0,0.01875,0.0333333,0,0,0,0.00625\n0,0.997554,0.00133297,4.75327e-05,0.000118379,6.65359e-05,0.000253487,0.000141784,0.000183293,0.000220498,7.08961e-05,0,0,0,0,0,1.10967e-05,0,0,0\n0,0.082346,0.890084,0,0.000346861,0.0161043,0.0105323,0.000354988,0.00011562,0.00011562,0,0,0,0,0,0,0,0,0,0\n0,0.654957,0.306633,0,0.00150356,0.000466853,0.00273321,0.000933707,0.00233427,0.00186741,0,0,0,0,0.0190476,0.00952381,0,0,0,0\n0,0.429955,0.0543849,0.106071,0.0297159,0.0876241,0.16761,0.0435997,0.0293692,0.0167052,0.00492931,0.0143504,0.00664048,0.00127352,0.000520984,0.00405789,5.78871e-05,0,0,0.00313481\n0,0.372212,0.459023,0.00909091,0.0183902,0.00273224,0.0897315,0.00666667,0.0163417,0.000546448,0.000208333,0.00929924,0.00666667,0,0,0,0,0,0,0.00909091\n0,0.916784,0.0557399,0.00127288,0.0044239,0.00263795,0.00418008,0.00522153,0.00448012,0.0016537,0.0015471,0.00140777,0.00011532,4.21977e-05,4.21977e-05,5.76602e-05,0,0,0,0.000393295\n0,0.817223,0.10791,0.0119181,0.00617358,0.00279979,0.027469,0.00652177,0.00186348,0.00522515,0.0121172,0.000151166,0,0,0,0,0.00017316,0,0,0.000454545\n'

for p in foo.rstrip().split('\n'):
    print(p)

Another solution would be to use 'splitlines' instead, like this:
for p in foo.rstrip().splitlines():
    print(p)


text:
Q: jQuery sortable changing name attribute not showing input name when posted back to php Hi Im using Laravel and Jquery to create a project which can have many statuses assigned to the tasks from a list of many. The statuses need to be written to the assigned_statuses table which has a project_id and a status_id to form the relevant relationships.
To assign these I have two connected sortable lists which have two hidden inputs, I am using sortable as the tasks in the project will move in a certain order that is assigned when posted back. Anyway my rendered blade file outputs the hidden form with the name of statuses and it posts them all back. However I need to know which ones are the assigned ones. This is my code so far:

      @foreach($statuses as $status)

id}}" name="{{$status->id}}">
         {{Form::hidden('available-statuses[]',$status->id,array('class' => 'sortable-hidden-input'))}}
          {{$status->name}}

      @endforeach

$(function() {
$( "#available-statuses, #assigned-stauses" ).sortable({
      connectWith: ".connected-sortable",
      stop: function(event, ui) {
           var present = $(ui.item).find('.sortable-hidden-input').attr("name", "assigned-statuses[]");
            console.log(present);
        }
    }).disableSelection();
});

The name attribute is changed on the input which has the class of .sortable-hidden-input however when this is posted back it doesn't have the key name in the array, the array is below:
array(7) {
    ["project_name"] ""
    ["start_date"] "01/01/2015"
    ["end_date"] "13/03/2015"
    ["available-statuses"] array(2) {
        [0] "17"
        [1] "20"
    }
    array(3) {
        [0] "19"
        [1] "16"
        [2] "18"
    }
}

As you can see the available statuses are in its own array but the other assigned statuses id's are not. I'm not sure why as the code successfully assigns the new name attribute on the input. Any ideas what I'm doing wrong and how I can successfully capture this on the back end??
Edit
Statuses Dump:
array(5) {
[0] array(8) {
["id"] "16"
["name"] "Backlog"
["order"] "0"
["created_at"] "2015-07-19 17:41:25"
["updated_at"] "2015-07-19 20:29:20"
}
[1] array(8) {
["id"] "17"
["name"] "Open"
["order"] "4"
["created_at"] "2015-07-19 17:41:25"
["updated_at"] "2015-07-19 20:29:11"
}
[2] array(8) {
["id"] "18"
["name"] "In Progress"
["order"] "1"
["created_at"] "2015-07-19 17:41:25"
["updated_at"] "2015-07-19 20:29:11"
}
[3] array(8) {
["id"] "19"
["name"] "Review"
["order"] "2"
["created_at"] "2015-07-19 17:41:25"
["updated_at"] "2015-07-19 20:29:21"
}
[4] array(8) {
["id"] "20"
["name"] "Done"
["order"] "3"
["created_at"] "2015-07-19 17:41:25"
["updated_at"] "2015-07-19 20:30:14"
}
}

Full Form
@extends('layouts.master')
@section('content')

Create new Project

        * required fields

        {{ Form::open(array('url' => route('project.add'), 'class'=> 'create-project-form')) }}

            {{ Form:: label ('project_name', 'Project name *' )}}
            {{ Form:: text ('project_name', '', array('placeholder' => 'Project Two', 'class' =>'form-control', 'id' => 'project-name') )}}

            {{ Form:: label ('start_date', 'Start Date *' )}}

            {{ Form:: text ('start_date', '', array('placeholder' => '2015/08/31', 'class' =>'form-control', 'data-provide' => 'datepicker', 'data-date-format' => 'yyyy/mm/dd', 'id' => 'start_date') )}}

            {{ Form:: label ('end_date', 'End Date *' )}}

            {{ Form:: text ('end_date', '', array('placeholder' => '2015/08/31', 'class' =>'form-control', 'data-provide' => 'datepicker', 'data-date-format' => 'yyyy/mm/dd', 'id' => 'end_date') )}}

        {{Form::label('globalstatues', 'These statuses have been assigned globally to all projects.')}}
            @foreach($globalstatuses as $status)
               {{$status->name}}
            @endforeach

        {{Form::label('overideglobalstatues', 'Would you like to override?')}}

The statuses on the left are available for selection. Drag them to the area on the right in the order you would like the scrum board to run. E.g. Backlog > In Progress > Review > Done > Deloyped.

                        @foreach($statuses as $status)

id}}" name="{{$status->id}}">{{Form::hidden('status[]',$status->id,array('class' => 'sortable-hidden-input'))}}{{$status->name}}

                        @endforeach

        {{ Form::submit('Create new project', array('class' => 'btn btn-success', 'id'=> 'create-project')) }}

        {{ Form::close() }}

@stop

A: Your code should work, this looks like a formatted array:
  array(7) {
    ["project_name"] ""
    ["start_date"] "01/01/2015"
    ["end_date"] "13/03/2015"
    ["available-statuses"] array(2) {
        [0] "17"
        [1] "20"
    }
    array(3) {
        [0] "19"
        [1] "16"
        [2] "18"
    }
}

Right click on your browser and view source and see if the contents are different.


text:
Q: What's wrong with this linq query (DBContext)? I'm using VS2012, and the DBContext (Entity Framework).
The following query throws an exception
Customer cust;
using (var context = new MiniNorthwindContext()) {
    cust = (from c in context.Customers
            where c.CustomerName.Contains("SN")
            select c).SingleOrDefault();
}

When I run it, it throws the following error: "Sequence contains more than one element".
If I replace it with
Customer cust;
using (var context = new MiniNorthwindContext()) {
    cust = (from c in context.Customers
            where c.CustomerName == "SN Software"
            select c).SingleOrDefault();
}

Then it passes.
What could I be doing wrong.

A: SingleOrDefault can do one of three things:

*

*if there are no results, return the default;

*if there is one result; return it;

*if there is more than one result, it throws that exception.

So your query is matching more than one row.

A: SingleOrDefault() will throw an exception whenever the query returns more than one record. You can use FirstOrDefault() instead to take the first record if there is any one at all.

A: Both querys are correct. The problem is the data:
CUSTOMERNAME
ESNF CO
SN SOFTWARE
MICROSOFT
APPLE
The first Query (c.CustomerName.Contains("SN")) result:

*

*ESNF CO

*SN SOFTWARE

Return 2 rows, so that Exception, becouse SingleOrDefault() only allow 1 record.
The second Query (c.CustomerName == "SN Software") result:

*

*SN SOFTWARE

Return only 1 row
Runs perfect !!!.
The problem is the data.


text:
Q: Solving $\left| {2z + 3i} \right| = \left| {{z^2}} \right|$
This is a multiple choice question with one or more correct, my approach is as follow
$\left| {2z + 3i} \right| = \left| {{z^2}} \right| \Rightarrow \left| {2\left( {a + ib} \right) + 3i} \right| = \left| {{a^2} - {b^2} + i2ab} \right|$
$ \Rightarrow \left| {2a + i\left( {2b + 3} \right)} \right| = \left| {{a^2} - {b^2} + i2ab} \right| \Rightarrow {\left| {2a + i\left( {2b + 3} \right)} \right|^2} = {\left| {{a^2} - {b^2} + i2ab} \right|^2}$
$ \Rightarrow 4{a^2} + {\left( {2b + 3} \right)^2} = {\left( {{a^2} - {b^2}} \right)^2} + 4{a^2}{b^2} = {\left( {{a^2} + {b^2}} \right)^2} \Rightarrow 4{a^2} + {\left( {2b + 3} \right)^2} = {\left( {{a^2} + {b^2}} \right)^2}$
Not able to procced further

A: $|z|^2 = |2z+3i| \le 2|z|+3 \Rightarrow |z| \le 3$ with equality when $z=3i$
Also $|z|^2 = |2z-(-3i)| \ge 3-2|z| \Rightarrow |z| \ge 1$ with equality when $z=-i$

A: By what it looks like, the question most likely does not want you to proceed to solve $a$ or $b$. Since, this is multiple choice you can try proving each option true/false by "catering" your method towards it;
For example, Option A states $3 \ge \|z\| > u$. You found $a^2 + b^2 = \sqrt{4a^2 + (2b + 3)^2}$.
Let $\{f(a,b): a^2 + b^2 = k\}$ and $\{g(a,b): a^2 + (b + \frac{3}{2})^2 = \frac{k^2}{4}\}$, $k \in \mathbb{R^+}$. $f(a, b)$ has the centre, $C_1 = (0, 0)$ and $g(a,b)$ has the centre, $C_2 = (0, -\frac{3}{2})$, with respect to $a,b$ axes. Since, $\|z\| = \sqrt{k}$, we need to disprove that $k > 9$ or prove that $k < 9$ for all $a, b$. Let's claim that $k < 9$.
Both $f(a, b)$ and $g(a, b)$ are elliptic functions on the cartesian plane. By the solving $k = \frac{k^2}{4}, k ≠ 0$, we observe that both elliptic function have same radii at $k = 4$. The function $\frac{k^2}{4}$ has a greater gradient ($>\frac{d}{dk}$) after $k = 4$, than $k$. Hence, $g(a, b)$ will "grow" in size faster than $f(a, b)$ as $k$ approaches $\infty$.
What this indicates, is that there is a certain $k$ value (Let this be denoted by $x$), for which values $>x$, $f(a, b) = \sqrt{g(a, b)}$ stop having solutions.
If our claim is true, there are $2$ solutions to $f(a, b) = \sqrt{g(a, b)}$, for $k < 9$, $1$ solution for $k = 9$ and $0$ solutions for $k > 9$.
Using the elliptic definition on cartesian plane ($a$ = horizontal axis, $b$ = vertical axis (interchangeable, but once defined, keep consistent)), the $2$ solutions always exist for $\{b: b > -\sqrt{k}, b < \frac{k}{2} - \frac{3}{2} \}$. Hence,
$\frac{k - 3}{2} > -\sqrt{k}, k > 0$
$\frac{(k - 3)^2}{4} < k$
$k^2 - 10k + 9 < 0$
$(k - 9)(k - 1) < 0$
We find that $9 \ge k \ge 1$, for  $1$ or $2$ solutions to $a^2 + b^2 = \sqrt{4a^2 + (2b + 3)^2}$. The claim is true.
Hence, $1 \le \|z\| \le 3$. Therefore, Option A is correct.
For $1 \le \|z\| \le 3$, if $\|z\| \in N$, then, $\|z\| = 1, 2, 3$. Hence, Option B is correct.
If $\|z\| = 3$, $\alpha^2 + \beta^2 = 9 \to \alpha^2 = 9 - \beta^2$
Then $81 = 36 - 4\beta^2 + 4\beta^2 + 12\beta + 9 \to b = 3$. Since $\beta = \|z\|_{max}$, $\alpha = 0$ and $\alpha^3 + \beta^3 = 0^3 + 3^3 = 27$. Hence, Option C is correct.
Option D is left as an exercise.


text:
Q: Windows Azure production vs staging server and Facebook integration We use Windows Azure Cloud services to host our application. One of the great features of Windows Azure is the Production/Staging model. You can have the clients of your application routed to your production server, while you can test your new code running on a staging server. For example, you can configure Azure to point a production server to http://www.coolapp.com while designating a staging server for the same app to something like this: http://7f8e9d5ba73a4f7ea9ebd65a02ee195d.cloudapp.net.
Physically both of these servers are publicly facing. If you were to know the cryptic URL of a staging server you would be able to browse to the app just as easily as you would browse to www.coolapp.com. However, the presence of a GUID in the URL makes it virtually impossible for someone to guess it, thus making the staging server "private". This gives a nice mechanism to the developers of an application to deploy and test the new bits on a staging server before releasing them to public. Once they make sure that things look good, with a flip of a switch they swap the two servers, making staging server a production server and vice versa.
This model creates a small problem for us in relation to Facebook integration. To be able to integrate Facebook plugins you have to register your app with them. FB will then issue an AppId and an AppSecret keys. These keys are tied to the URL of your application. So in order for my app to work with FB plugins I need to obtain one set of keys that is tied to 7f8e9d5ba73a4f7ea9ebd65a02ee195d.cloudapp.net, and another set that is tied to www.coolapp.com.
When I read about Windows Azure, they really urge developers to treat staging vs. production servers as the same. The only difference between them should be the URL. In other words, Azure does not recommend basing your app logic on which server the code happens to be running on as Azure has no inherent knowledge of this. Staging vs. production is just a handy "abstraction" if you will. I guess you see the problem here. In our example above, I have to use one set of keys issued by FB versus another depending on which URL (production vs. staging) my app is running at. I assume I am not the first one running into this problem. What are the correct ways of handling this? One obvious way is to sniff the URL property of the Request object and branch my logic that way. However, intuition tells me this is a hack. Any other ideas?
Regards,
Archil

A: The mechanisms I know of are:

*

*using "production" within a totally separate service account to "testing" - this leaves "staging" within the production service to be used as an area for "deployment candidates" and provides a separate clean testing domain with a non-changing URL for earlier "dev and test" work.

*using different .cscfg files for staging and production - and being careful to update this .cscfg before you do any live switching.

*sniffing the incoming URL - as you suggest

Personally, I use the first of these techniques - its easy and it helps prevent nasty accidents

As an aside, one of the techniques we've used for "removing" the Guid from staging is to CNAME the Guid with a really short TTL on the DNS - this allows us to quickly and automatically update the CNAME record for the staging server when we deploy.


text:
Q: Fatal error: Call to a member function get() on null in C:\wamp\www\Cocolani\php\req\checkusername.php on line 4 I get an error in my file "checkusername.php".
The error I get is:

( ! ) Fatal error: Call to a member function get() on null in
  C:\wamp\www\Cocolani\php\req\checkusername.php on line 4

There is a "checkusername.php" file :
<?php
    include_once("../../includes/db.php");
    include_once("settings.php");
    $db = new database($obj->get("db_name"), $obj->get("db_server"), $obj->get("db_user"), $obj->get("db_password"), $obj->get("url_root"));

    $username = isset($_POST['username']) ? mysqli_real_escape_string($_POST['username']) : "";
    $password = isset($_POST['password']) ? mysqli_real_escape_string($_POST['password']) : "";
    $email = isset($_POST['email']) ? mysqli_real_escape_string($_POST['email']) : '';
    $birthdate = isset($_POST['birthdate']) ? mysqli_real_escape_string($_POST['birthdate']) : "";
    $firstname = isset($_POST['firstname']) ? mysqli_real_escape_string($_POST['firstname']) : "";
    $lastname = isset($_POST['lastname']) ? mysqli_real_escape_string($_POST['lastname']) : "";
    $sex = isset($_POST['sex']) ? mysqli_real_escape_string($_POST['sex']) : "";
    $tribeid = isset($_POST['clan']) ? mysqli_real_escape_string($_POST['clan']) : "";
    $mask = isset($_POST['mask']) ? mysqli_real_escape_string($_POST['mask']) : "";
    $mask_color = isset($_POST['maskcl']) ? mysqli_real_escape_string($_POST['maskcl']) : "";
    $lang_id = isset($_POST['lang_id']) ? addslashes($_POST['lang_id']) : 0;
    $error = '';

   // get language suffix
     if ($lang_id != 0) {
     $db->setQuery("SELECT * FROM `cc_extra_langs` WHERE id='{$lang_id}'");
     $res = $db->loadResult();
     $lang = "_".$res->lang;
   } else $lang = "";

   $reg_ok = true;

   $db->setQuery("SELECT one_email_per_registration FROM `cc_def_settings`");
   $res = $db->loadResult();
   $one_registration_per_email = ($res->one_email_per_registration == 1);

   $email_check_ok = true;
   if ($one_registration_per_email == true) {
     $sql = "SELECT COUNT(*) AS counter FROM `cc_user` WHERE email='{$email}'"; // for several registrations per one email address -- no check
       $db->setQuery($sql);
       $res1 = $db->loadResult();
       $email_check_ok = $res1->counter == "0";
     }
   if ($email_check_ok == false) {
     $sql = "SELECT * FROM `cc_translations` WHERE caption='DUPLICATED_EMAIL'";
     $db->setQuery($sql);
     $res = $db->loadResult();
       echo 'error='.urlencode($res->{"name".$lang});
       $reg_ok = false;
   }

    /*if ($reg_ok && $email != '') {
      // get number of already registered number of registrations with this email address
      $sql = "SELECT count(*) as registered_num_emails FROM `cc_user` WHERE email='{$email}'";
      $query = $db->setQuery($sql);
      $row = mysql_fetch_object($query);
      $registered_num_emails = $row->registered_num_emails;

      $sql = "SELECT max_num_account_per_email from `cc_def_settings`";
      $query = $db->setQuery($sql);
      $row = mysql_fetch_object($query);

      // it's possible to create new registration using this email address
      if ($registered_num_emails >= $row->max_num_account_per_email) {
        $sql = "SELECT * FROM `cc_translations` WHERE caption='MAX_NUM_REGISTRATION_REACHED'";
        $db->setQuery($sql);
        $res = $db->loadResult();
          echo 'error='.urlencode($res->{"name".$lang});
        $reg_ok = false;
      }
    }*/
////////
//     echo 'error=111';
//     $reg_ok = false;
////////

     if ($reg_ok) {
     // check for swear words
     $db->setQuery("SELECT COUNT(*) as counter from `cc_swear_words` where INSTR('".$username."', `name`)");
     $res2 = $db->loadResult();
     if ((int)($res2->counter) > 0) { // swear word founded!
       $sql = "SELECT * FROM `cc_translations` WHERE caption='USERNAME_NOT_PERMITTED'";
       $db->setQuery($sql);
       $res = $db->loadResult();
       echo 'error='.urlencode($res->{"name".$lang});
       $reg_ok = false;
     }
   }

     if ($reg_ok) {
     // first check there is no username with this name already registered.
     $db->setQuery("SELECT COUNT(*) AS counter FROM `cc_user` WHERE username='".$username."'");
     $res = $db->loadResult();
     if ((int)($res->counter) > 0) { // swear word founded!
       // get warning message from db
       $db->setQuery("SELECT * FROM `cc_translations` WHERE caption='USERNAME_IN_USE'");
       $res = $db->loadResult();
       echo 'error='.urlencode($res->{"name".$lang});
       $reg_ok = false;
       }
   }

   if ($reg_ok) echo 'result=true';

?>

The problem on line 4 which is :
$db = new database($obj->get("db_name"), $obj->get("db_server"), $obj->get("db_user"), $obj->get("db_password"), $obj->get("url_root"));

There is a "settings.php" :
<?php

    $db_server = "localhost";
    $db_user = "root";
    $db_password = "pass1234";
    $db_name = "cocolani_battle";
    $appsecret = "80f730a73ac60417c36c341bc975f6f1";

    $connect = mysqli_connect("$db_server","$db_user","$db_password","$db_name");

?>

and there is a "db.php" :
<?php

/*
Usage
$db = new database($dbname);

for selects:
$db->setQuery("SELECT * FROM `table`")
$resultArray = $db->loadResults();

$db->setQuery("SELECT * FROM `table` WHERE `primary_id` = '1'");
$resultObject = $db->loadResult();

for inserts:
$db->setQuery("INSERT INTO `table` (`id`, `example`) VALUES ('1', 'abc')");
if (!$db->runQuery()) {
    echo $db->getError();
}
*/

class database {
    var $_debug = 0;
    var $_sql = '';
    var $_error = '';
    var $_prefix = '';

    var $_numrows = 0;

    var $_DBhost = 'localhost';
    var $_DBuser = "root";
    var $_DBpass = "pass1234";
    var $_DBname = "cocolani_battle";
    var $url_root = "localhost/cocolani";

    public function __construct($dbname = 'cocolani_battle', $dbuser = 'root', $dbpsw = 'pass1234', $dbhost = 'localhost', $urlroot = 'localhost/cocolani') {

            $this->_DBname = 'cocolani_battle';
            $this->_DBuser = 'root';
            $this->_DBpass = 'pass1234';
            $this->url_root = 'localhost/cocolani';
            $this->_DBhost = 'localhost';

        $this->_connection = mysqli_connect($this->_DBhost, $this->_DBuser, $this->_DBpass) or die("Couldn't connect to MySQL");
        mysqli_select_db($this->_connection, $this->_DBname) or die("Select DB Error: ".mysqli_error());

    }

    public function __destruct() {
        mysqli_close($this->_connection);
    }

    function debug($debug_level) {
        $this->_debug = intval($debug_level);
    }

    function setQuery($sql) {
        /* queries are given in the form of #__table need to replace that with the prefix */
        $this->_sql = str_replace('#__', $this->_prefix.'_', $sql);
    }

    function getQuery() {
        return "
" . htmlspecialchars( $this->_sql) . "
";
    }

    function prepareStatement($sql) {
        $this->sql = mysqli_prepare($this->_connection, $sql);
        return $this->sql;
    }

    function runQuery($num_rows=0) {
        mysqli_select_db($this->_connection, $this->_DBname) or die("Select DB Error: ".mysqli_error());

        $this->_numrows = 0;
        $result = mysqli_query($this->_connection, $this->_sql);
        if ($this->_debug > 1) echo "
" . htmlspecialchars( $this->_sql) . "
";

        if (!$result) {
            $this->_error = mysqli_error($this->_connection);
            if ($this->_debug) {
                echo 'Error: ' . $this->getQuery() . $this->_error;
            }
            return false;
        }
        if ($num_rows) {
            $this->_numrows = mysqli_num_rows($result);
        }
        return $result;
    }

    /* Retrieve Mysql insert id */
    function mysqlInsertID() {
        $insert_id = mysqli_insert_id();
        return $insert_id;
    }

/* Escapes special characters while inserting to db */
    function db_input($string) {
      if (is_array($string)) {
          $retArray = array();
          foreach($string as $key => $value) {
              $value = (get_magic_quotes_gpc() ? stripslashes($value) : $value);
              $retArray[$key] = mysqli_real_escape_string($value);
          }
          return $retArray;
      } else {
          $string = (get_magic_quotes_gpc() ? stripslashes($string) : $string);
          return mysqli_real_escape_string($string);

      }
    }

    function getError() {
        return $this->_error;
    }
    /* Load results into csv formatted string */
    function loadCsv() {
        if (!($res = $this->runQuery())) {
            return null;
        }

        $csv_string = '';
        while ($row = mysqli_fetch_row($res)) {
            $line = '';
            foreach( $row as $value ) {
                if ( ( !isset( $value ) ) || ( $value == "" ) ) {
                    $value = ",";
                } else {
                    $value = $value. ",";
                    $value = str_replace( '"' , '""' , $value );
                }
                $line .= $value;
            }
            $line = substr($line, 0, -1);
            $csv_string .= trim( $line ) . "\n";
        }
        $csv_string = str_replace( "\r" , "" , $csv_string );
            //$csv_string .= implode(",", $row) . "\n";
        mysqli_free_result($res);
        return $csv_string;
    }

    /* Load multiple results */
    function loadResults($key='' ) {
        if (!($res = $this->runQuery())) {
            return null;
        }
        $array = array();

        while ($row = mysqli_fetch_object($res)) {
            if ($key) {
                $array[strtolower($row->$key)] = $row;
            } else {
                $array[] = $row;
            }
        }
        mysqli_free_result($res);
        return $array;
    }

    function loadResult() {
        if (!($res = $this->runQuery())) {
            if ($this->_debug) echo 'Error: ' . $this->_error;
            return null;
        }
        $row = mysqli_fetch_object($res);
        mysqli_free_result($res);
        return $row;
    }

    /* Load a result field into an array */
    function loadArray() {
        if (!($res = $this->runQuery())) {
            return null;
        }
        $array = array();
        while ($row = mysql_fetch_row($res)) {
            $array[] = $row[0];
        }
        mysqli_free_result($res);
        return $array;
    }

    /* Load a row into an associative an array */
    function loadAssoc() {
        if (!($res = $this->runQuery())) {
            return null;
        }
        $row = mysqli_fetch_assoc($res);
        mysqli_free_result($res);
        return $row;
    }

    /* Return one field */
    function loadField() {
        if (!($res = $this->runQuery())) {
            return null;
        }
        while ($row = mysql_fetch_row($res)) {
            $field = $row[0];
        }
        mysqli_free_result($res);
        return $field;
    }

}

  /*if ($_SERVER["SERVER_ADDR"] == '127.0.0.1') {
    $url_root = "http://cocolani.localhost";
  } else {
    $url_root = "http://dev.cocolani.com";
  }*/

?>

How can I fix this error?

A: As I mentioned in my comment, you can either use the variables you defined in your settings.php:
$db = new database($db_name, $db_server, $db_user, $db_password, $db_urlroot); // You didn't define $db_urlroot anywhere, but you can define it

OR hard-code it into your class. You're not using the variables you pass in anyway, so there's no need to ask for them.
public function __construct() {


text:
Q: Fix invalid child element in WCF RIA with SOAP endpoint Is there anyway to fix the warning that Visual Studio flags when you try and add the SOAP endpoint to a WCF RIA service ?
The element 'system.serviceModel' has invalid child element 'domainServices'

I found one blog post, Silverlight forums, but the only "answer" in it just says edit the Visual Studio DotNetConfig.xsd, not actually what to do


text:
Q: Get url as www.abcd.com?curr=USD I am working on e-commerce website
I have a drop down of different currencies if user selects USD as currency then all the links in the website should open as www.abcd.com/aboutus.php?curr=USD
Thanks

A:  <form action='www.abcd.com/aboutus.php' method='get'>
 <select name="curr" id='test'>
 <option value='USD'>USD</option>
 <option value='Euro'>Euro</option>
 </select>
 <input type='submit' value='submit'>
 </form>

on your pages simply put
 <? $curr = $_GET['curr'];  ?>

now on every link include
 abcd.com?curr=<? echo $curr ?>


text:
Q: Conceptual description of the isotypical component This is probably rather simple but I have not found it in the literature.
Consider the category $C$ of representations of a finite group $G,$ over a field $k$ of characteristic not dividing the order of $G$ (so that the category is semi-simple). Fix an irreducible representation $L$ of $G.$
Is there a nice abstract description of the functor $F: C \to C$ sending a representation $V$ to its component associated to $L$ (and similarly for morphisms)? I mean $F(V)$ is naturally isomorphic to $L \otimes_k Hom_G(L,V),$ but is there a more conceptual way to write it? Perhaps using adjoint functors?

A: I approve Ben's answer, and I would add that the center of an algebra can be interpreted as the endomorphisms of the identity functor. So if you have a central idempotent, taking the image you get an endofunctor which is a projector. This applies in particular to group algebras. For a primitive central idempotent, in the semisimple case you get a "projection to isotypical component" functor, while in the modular case you get a "projection to a block" functor.

A: In the group algebra, the sum $e=\frac{\chi(e)}{\#G}\sum \bar\chi(g)g$ for an irreducible character $\chi$ is an idempotent and central (by the orthogonality relations).  (NOTE: I just fixed the formula above.)  The same relations show that the image of $e$ acting on any representation (which is a subrepresentation by centrality) is the isotypic component for $\chi$.


text:
Q: Are sections of the structure sheaf of a scheme determined by their values at its closed points? This question got me thinking if it's true that for every commutative ring with $1$, $R$, we have that the structure sheaf of $X_{max}=MaxSpec R$ at a distinguished open set $D(f)$ is exactly $R_f$. As I don't know the answer for this, but do know it's true for $X=Spec R$ I tried the following approach:
Define the sections of the structure sheaves at an open set $U$ as functions $s:U\to\bigsqcup_{I\in U} A_I$, where $I$ is either a maximal or prime ideal depending on whether we're working in $MaxSpec$ or $Spec$, respectively, and we further require that these sections are locally a quotient.
I tried coming up with an isomorphism between $\mathcal{O}_{X_{max}}(D(f))\cong\mathcal{O}_X(D(f))$ or a counterexample. The isomorphism seems clearly true when $R$ is an integral domain, but is it still true in general? Clearly, given any open set $U$, every $s\in\mathcal{O}_X(U)$ induces a section in $\mathcal{O}_{X_{max}}(U)$, but how about the converse? Is every section of the structure sheaf of a scheme determined by its values in the closed points?
Here's my attempt to construct a counter example:
Consider $R$ not an integral domain with a unique maximal ideal $m$ containing at least another prime ideal $(0)\subsetneq p\subsetneq m$. Furthermore, assume there are two different elements $r,s\in R$ and some $0\neq f\in m-p$ such that $rf=sf=0$. Then, we further assume $\frac{r}{1}\neq\frac{s}{1}\in R_m-\{0\}$, and by construction they are both zero in $R_p$.
Therefore, $r$ and $s$ define different global sections of $\mathcal{O}_X$, but are both zero as sections of $\mathcal{O}_{X_{max}}$. In this way we conclude that both sheaves are different, so they must also differ in the basic open sets of the topology.
Is my reasoning correct?

A: Let $R$ be local domain (but not a field) and $0\neq f$ a non-unit.
If we work with the maximal spectrum, we have $D(f)=\emptyset$, i.e. there are no sections.
If we work over the prime spectrum, we have the familiar $\mathcal O_{\operatorname{Spec} R}(D(f))=R_f \neq 0$.

To understand whats going on here, you should take another look at the proof that $\mathcal O_{\operatorname{Spec} R}(D(f))=R_f$, for instance at Hartshorne. You will notice that the fact $\sqrt I = \bigcap\limits_{\mathfrak p \supset I} \mathfrak p$ is a crucial ingredient of the proof.
It turns out that you can actually take the same proof for the maximal spectrum if $\sqrt I = \bigcap\limits_{\mathfrak m \supset I} \mathfrak m$ (only running through maximal ideals) holds, i.e. if $R$ is a Jacobson ring (for example if $R$ is a finitely generated algebra over a field).
A local ring of positive dimension is of course not a Jacobson ring, thats how I came up with the counterexample.
Summarizing, the question whether $\mathcal O_{\operatorname{MaxSpec} R}(D(f))=R_f$ holds comes down to the question whether $R$ is a Jacobson ring. Being a domain or not is totally irrelevant. This should also answer your other question. There $R$ was a finitely generated $k$-algebra, i.e. everything is fine there.


text:
Q: How to make same website layout for mobile devices (not responsive) I've tired for finding an answer of a question. I want a website that can be seen same from mobile or similar device. I don't mean about responsive rather I mean, from mobile visitor can see same layout of the website even by horizontal mouse scrolling. This is possible for every website. Do not need any code for that. Same layout is normally seen by mobile with horizontal mouse scrolling. But, I've troubled with one scenario. I've built an example. Here is it..
If you see that website from mobile or similar device like small notebook etc(or resizing to small browser), you'll see this:

You're seeing that blue div can't be able to fill the 100% width of the browser though that div was defined with 100% width! Look the grey div below portion of that images. At normal stage both blue(div.top) and grey(div#gcontent) div is center of the browser but at small screen, grey div fill the 100% width where blue div has failed to fill 100% width. What's the reason. How can I fix it?
structure of it:

Lorem Ipsum is simply dummy text .... of Lorem Ipsum.

WELCOME

Lorem Ipsum is simply dummy text ... of Lorem Ipsum.

Lorem Ipsum is simply dummy text ... of Lorem Ipsum.

Lorem Ipsum is simply dummy text ... of Lorem Ipsum.

CSS:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
    border: 0 none;
    font-size: 100%;
    margin: 0;
    padding: 0;
    vertical-align: baseline;
}

a {
    text-decoration: none;
    color: #fff;
}
.clear { clear: both; }
body {
    background: url(../images/bg.png) repeat-x #fff;
    color: #000;
    font-family: Helvetica, Myriad Pro, Verdana;
    font-size: 14px;
    line-height: 1em;
}

.outer {
    width: 100%;
    float: left;
    display: block;
}
.top {
    background: #009999;
}

.inner {
    width: 940px;
    margin: 0 auto;

}
.wrapper {
    width: 940px;
    margin: 0 auto;
    text-align: left;

}

#header {
    width: 100%;
    float: left;
}

h1 { font-weight: normal; }
h2 { font-size: 22px; font-weight: normal; }
h3 { font-size: 15px; font-weight: normal; }
p { font-size: 12px; }
.logo a {
    display: block;
    width: 124px;
    height: 104px;
    margin: 31px 46px 0 10px;
    float: left;
}

#header h1 {
    font-size: 23px;
    text-transform: uppercase;
    font-family: 'HelveticaNeueLTStd-Bd-75';
    color: #004481;
    padding: 110px 0 33px 0;
}

#content {
    width: 100%;
    float: left;
    background: #b2b0b0;
    margin: 0 0 200px 0;
    -moz-box-shadow: 1px 0 5px 5px #acacac;
    -webkit-box-shadow: 1px 0 5px 5px #acacac;
    box-shadow: 1px 0 5px 5px #acacac;
}

I asked a similar type of question at here before some days. But, I didn't find a solution. Somebody told me problem with inner div(width: 940px) which create that problem for small screen. But, my point is blue div(div.top) is at outer div whose width is 100%. So, why inner div is responsible for this! Somebody told me to make a different stylesheet for small screen. Though, I can't understand the problem, but shouldn't the solution be simple? But, if at last it's the only solution to make a different stylesheet for small screen, then what will be the code for that scenario?
Basically, I'm making a website of this similar structure at where I need lots of this:
.outer {
   width: 100%;
   float: left;
}
.inner {
  width: 940px;
  margin: 0 auto;
}

I don't want that website would be responsive. But, at least visitor shouldn't see that scenario(blue or div.top: width: 100% can't fill 100% of the browser) from mobile. So, kindly just give me the solution of filling the 100% width of the browser by that blue div for any small screen in simple way. It seems to me adding one or tow line code of that outer div can solve the problem but I don't know what are that code :(
Thanks in advance!

A: If you set a rule like width: 100%;, in this case, for the way your css is done, the 100% comes from the browser size, not from the actual width of the site. Your site is getting a width of about 940px, but on a mobile, the browser size is smaller.
Just try to add a rule like this:
html {
   min-width: 940px;
}

Probably, that is enough.
By using min-width, instead of plain width, in the case of a browser with a longer width (like a desktop), the site will look the same way as now, and the adjustment will apply only to browsers with an smaller width.

A: The problem is that the div with the blue background is specified to also be 100% width. When 100% width is less than 940px then the blue background will be smaller than the div containing the text. You could either change the site so that there is no fixed 940px width, or apply the top class to the same div that contains the text (with the inner class).

A: Just add this in the head of your HTML
    <meta name='viewport' content='width=device-width, initial-scale=1 />


text:
Q: Converting Javascript Date I have a date String in this format: Tue Sep 02 00:00:00 GMT+200 2014, I'd like to have only in Javascript this ISO Format: 2014-09-02T00:00:00.000Z.
So I have wrote this code:
var date = new Date("Tue Sep 02 00:00:00 GMT+200 2014");
date.toJSON();

but it returns: "2014-09-01T22:00:00.000Z".
How can I have the right date in ISO format? Thank you.

A: If you want to use the JavaScript native Date Object, you may want to look at its documentation first, especially the toISOString() method.
var date = new Date("Tue Sep 02 00:00:00 GMT+200 2014");
var n = date.toISOString();

this returns:
n: '2014-09-01T22:00:00.000Z'

which is the right ISO format. Your initial time is GMT+2 so, in ISO time, it corresponds to the same date/time but two hours before. As it is the 2nd of Sept, 00:00:00, 2 hours before lead to the day before, the 1st of Sept, at 22:00:00. You can't have the 2014-09-02T00:00:00.000Z you want in your question because it is not corresponding to an ISO date.
You can read more about ISO 8601 on Wikipedia.

A: There is a method for that.
date.toISOString()


text:
Q: While Loop being interrupted when if statement is false I have this piece of code that is meant to ask you what the blank word should be and then moves on to the next one if you correctly guess. That part is working fine, but if you enter the wrong answer it should ask the question again but is not doing that. Instead the python shell just sits there blank, no error, nothing. I can't see the problem:
while victory == False:
    if askq == answerx[counter]:
        newstring = newstring.replace(blank_list[counter],answerx[counter])
        counter += 1
        print newstring
        if counter < len(blank_list):
            askq = raw_input('What word is ' + blank_list[counter] + '? ')
    if newstring == answers:
        print 'Congratulations!'
        victory = True

A: I think I figured it out! There may be a better way, but this just worked:
while victory == False:
    if askq == answerx[counter]:
        newstring = newstring.replace(blank_list[counter],answerx[counter])
        counter += 1
        print newstring
        if counter < len(blank_list):
            askq = raw_input('What word is ' + blank_list[counter] + '? ')
    else:
        print newstring
        askq = raw_input('What word is ' + blank_list[counter] + '? ')
    if newstring == answers:
        print 'Congratulations!'
        victory = True


text:
Q: How to draw vertical shape in the centre of XML drawable How can a vertical line be drawn within an XML drawable when using a layer-list? I declared 3 shapes within the drawable but for some reason it doesn't appear as expected.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/green"/>
        </shape>
    </item>

    <item android:top="0dp" android:left="1dp" android:bottom="0dp" android:right="5dp">
        <shape android:shape="rectangle">
            <size android:width="3dp"/>
            <solid android:color="@android:color/white"/>
        </shape>
    </item>
    <item android:top="0dp" android:left="5dp" android:bottom="0dp" android:right="1dp">
        <shape android:shape="rectangle">
            <size android:width="3dp"/>
            <solid android:color="@android:color/white"/>
        </shape>
    </item>
</layer-list>

Current result

Expected result

A: <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item
    android:width="16dp"
    android:left="15px">
    <shape
        android:shape="rectangle">
        <solid android:color="@color/colorAccent" />/>
        <size android:width="5dip" />
        <stroke android:color="@color/colorAccent" />
    </shape>
</item>
<item
    android:width="16dp"
    android:left="80px">

    <shape
        android:shape="rectangle">
        <solid android:color="@color/colorAccent" />/>
        <size android:width="5dip" />
        <stroke android:color="@color/colorAccent" />
    </shape>
</item>

<item
    android:width="16dp"
    android:left="140px">
    <shape
        android:shape="rectangle">
        <solid android:color="@color/colorAccent" />/>
        <size android:width="5dip" />
        <stroke android:color="@color/colorAccent" />
    </shape>
</item>

</layer-list>

A: Try this solution
drawable/shape.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorAccent" />/>
<size android:width="5dip" />
<stroke
    android:color="@color/colorAccent"
    />
</shape>

Include in the layout file the following
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<View
    android:layout_width="15dip"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/activity_horizontal_margin"
    android:background="@drawable/shape"></View>

<View
    android:layout_width="15dip"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/activity_horizontal_margin"
    android:background="@drawable/shape"></View>

<View
    android:layout_width="15dip"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/activity_horizontal_margin"
    android:background="@drawable/shape"></View>

</LinearLayout>

Change the colors and fix the margins of the layout.


text:
Q: Dividing by zero I'm studying this function and I have this limit.
I think the domain is $x\neq0$ so it can't be calculated the limit for $x \rightarrow 0^-$.
$\lim\limits_{x \rightarrow 0^+} \dfrac{ 1-2lnx }{ x^2 }$
Now I'm stuck because $1-2lnx$ tends to $-1$ and $x^2$ tends to $0^+$ so I tought the result would be $-\infty$ but Wolfram says it's generic infinite $\infty$ and in the graph it shows $+\infty$.

A: In fact the domain of $f(x) = \frac{1-2 \ln x}{x^2}$is not $\mathbb R \setminus \{0\}$ but $\mathbb R_+$ as $\ln x$ is only defined for $x \gt 0$.
Now as both $\lim\limits_{x \to 0^+} 1-2 \ln x = \lim\limits_{x \to 0^+} \frac{1}{x^2} = \infty$, you get $\lim\limits_{x \to 0^+} f(x) = \infty$.


text:
Q: How can I load a folders files into a ListView? I'd like to have a user select a folder with the FolderBrowserDialog and have the files loaded into the ListView.
My intention is to make a little playlist of sorts so I have to modify a couple of properties of the ListView control I'm assuming. What properties should I set on the control?
How can I achive this?

A: A basic function could look like this:
    public void DisplayFolder ( string folderPath )
    {
        string[ ] files = System.IO.Directory.GetFiles( folderPath );

        for ( int x = 0 ; x < files.Length ; x++ )
        {
            lvFiles.Items.Add( files[x]);
        }
    }

A: Surely you just need to do the following:
    FolderBrowserDialog folderPicker = new FolderBrowserDialog();
    if (folderPicker.ShowDialog() == DialogResult.OK)
    {

        ListView1.Items.Clear();

        string[] files = Directory.GetFiles(folderPicker.SelectedPath);
        foreach (string file in files)
        {

            string fileName = Path.GetFileNameWithoutExtension(file);
            ListViewItem item = new ListViewItem(fileName);
            item.Tag = file;

            ListView1.Items.Add(item);

        }

    }

Then to get the file out again, do the following on a button press or another event:
    if (ListView1.SelectedItems.Count > 0)
    {

        ListViewItem selected = ListView1.SelectedItems[0];
        string selectedFilePath = selected.Tag.ToString();

        PlayYourFile(selectedFilePath);

    }
    else
    {
        // Show a message
    }

For best viewing, set your ListView to Details Mode:
ListView1.View = View.Details;

A: List item
private void buttonOK_Click_1(object sender, EventArgs e)
    {

        DirectoryInfo FileNm = new DirectoryInfo(Application.StartupPath);
        var filename = FileNm.GetFiles("CONFIG_*.csv");
        //Filename CONFIG_123.csv,CONFIG_abc.csv,etc

       foreach(FileInfo f in filename)
        listViewFileNames.Items.Add(f.ToString());

    }


text:
Q: Update Multiple Rows with Multiple Conditions in SQL Server I have code like this to update multiple rows
--ZZSEQUENCENBR
UPDATE AUSP
SET CharacteristicValue = SUBSTRING(@RolNum, 5, 1)
WHERE Object = @Batch AND Internalcharno = 'ZZSEQUENCENBR'

--ZZPOSITIONMS
UPDATE AUSP
SET CharacteristicValue = SUBSTRING(@RolNum, 6, 1)
WHERE Object = @Batch AND Internalcharno = 'ZZPOSITIONMS'

--ZZDERIVATIVEMS
UPDATE AUSP SET CharacteristicValue = SUBSTRING(@RolNum,7,1) WHERE Object = @Batch AND Internalcharno = 'ZZDERIVATIVEMS'
--ZZPOSITIONSS
UPDATE AUSP SET CharacteristicValue = SUBSTRING(@RolNum,8,1) WHERE Object = @Batch AND Internalcharno = 'ZZPOSITIONSS'
--ZZDERIVATIVESS
UPDATE AUSP SET CharacteristicValue = SUBSTRING(@RolNum,9,1) WHERE Object = @Batch AND Internalcharno = 'ZZDERIVATIVESS'
--ZZNOMORROLL
UPDATE AUSP SET CharacteristicValue = @RolNum WHERE Object = @Batch AND Internalcharno = 'ZZNOMORROLL'

--UPDATE Speed
UPDATE AUSP SET Valuefrom = @SPEED WHERE Object = @Batch AND InternalCharNo = 'ZZSPEED'
--Update Panjang, Lebar, berat & Xtra Length
UPDATE AUSP SET Valuefrom = @LebarActual WHERE Object = @Batch AND InternalCharNo = 'ZZWIDTH'
UPDATE AUSP SET Valuefrom = @PanjangActual WHERE Object = @Batch AND InternalCharNo = 'ZZLENGTH'
SELECT @Thick = ZZTYPEFILM.[ThicknessFilm(Micron)], @Density = ZZTYPEFILM.[Density(g/Cm3)] FROM (SELECT CharacteristicValue FROM AUSP WHERE (InternalCharNo = N'ZZCODE') AND (Object = @Batch)) AS View1 INNER JOIN ZZTYPEFILM ON View1.CharacteristicValue = ZZTYPEFILM.KodeFilm
SET @QtyRol = ROUND((@LebarActual * @PanjangActual * convert(float,@Thick) * convert(float,@density))/1000000,1)
UPDATE AUSP SET Valuefrom = @QtyRol WHERE Object = @Batch AND InternalCharNo = 'ZZCONVERSIONROLLKG'
UPDATE AUSP SET Valuefrom = @XtraPanjang WHERE Object = @Batch AND InternalCharNo = 'ZZEXLENGTH'

I was try code like this to update Internalcharno, not yet in Valuefrom :
UPDATE AUSP
SET CharacteristicValue = (case when Internalcharno = 'ZZPRODLINE' then 'EDIT'
                        when Internalcharno = 'ZZMONTHYEAR' then 'EDIT1'
                        when Internalcharno = 'ZZSEQUENCENBR' then 'EDIT2'
                        when Internalcharno = 'ZZPOSITIONMS' then 'EDIT3'
                        when Internalcharno = 'ZZDERIVATIVEMS' then 'EDIT4'
                        when Internalcharno = 'ZZPOSITIONSS' then 'EDIT5'
                        when Internalcharno = 'ZZDERIVATIVESS' then 'EDIT6'
                        when Internalcharno = 'ZZNOMORROLL' then 'EDIT7'
                end)
WHERE Internalcharno in ('ZZPRODLINE', 'ZZMONTHYEAR', 'ZZSEQUENCENBR', 'ZZPOSITIONMS',
'ZZDERIVATIVEMS', 'ZZPOSITIONSS', 'ZZDERIVATIVESS', 'ZZNOMORROLL' ) AND
        [Object] = '414095';

But this code throws an error :

Msg 512, Level 16, State 1, Procedure HistoryAUSPBeforeUpdate, Line 27
  Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
  The statement has been terminated.

Can anyone help? Thanks,

A: As You changed your question,I think problem is not in your last update query but somewhere here:
SELECT @Density = ZZTYPEFILM.[Density(g/Cm3)]
FROM (SELECT CharacteristicValue FROM AUSP WHERE (InternalCharNo = N'ZZCODE')
AND (Object = @Batch)) AS View1 INNER JOIN ZZTYPEFILM ON View1.CharacteristicValue = ZZTYPEFILM.KodeFilm

Make sure your every subquery is giving you a single value.


text:
Q: What is the path in public SSH key used for? Public SSH key has the following structure:

*

*Encryption algorithm type

*Key content

*Host

*Path to the file

Does any part of the authentication use the path to file? Is it safe to modify it if I had renamed the file and would prefer the path to match?


text:
Q: If subquery returns no rows, return 0 else return value of the subquery I got a question and you can most likely help me.
I have got a query with a subquery that narrows the search. The query ends with this.
SELECT
    *
FROM
    Purchase
WHERE
    Total < 5000
AND
    Total >
            (
                SELECT TOP 1
                   buyamount
                FROM
                   employee
                WHERE
                   manager = 'TST'
                ORDER BY
                   buyamount ASC
            )
ORDER BY Date DESC

I want the value of the subquery after the ">"... but if the subquery gives nothing in return, i want it to be 0. How do i do this?

A: In the example you posted you could simply wrap the subquery in COALESCE and get your desired result.
SELECT
    *
FROM
    #Purchase
WHERE
    Total < 5000
AND
    Total > COALESCE(
            (
                SELECT TOP 1
                   buyamount
                FROM
                   #employee
                WHERE
                   manager = 'TST'
                ORDER BY
                   buyamount ASC
            ), 0)
ORDER BY Date DESC

You could also use a variable in your provided example instead of a subquery. I prefer this approach because it separates the logic, making it easier to read. Subqueries can also be a performance killer. Having it broken out like this, it should perform better.
DECLARE @BuyAmount INT
SET @BuyAmount = (SELECT TOP 1 BuyAmount FROM #Employee WHERE Manager = 'TST' ORDER BY BuyAmount ASC)
IF @BuyAmount IS NULL SET @BuyAmount = 0

SELECT *
FROM #Purchase
WHERE Total < 5000 AND Total > @BuyAmount
ORDER BY Date DESC


text:
Q: How to implement infix operator matrix multiplication in Python 2? I have been using python 3.7 for a few months, but I recently had to shift to python 2.7. Since I am developing scientific code, I heavily rely on the use of infix operator @ to multiply nd-arrays. This operator was introduced with python 3.5 (see here), therefore, I cannot use it with my new setup.
The obvious solution is to replace all M1 @ M2 by numpy.matmul(M1, M2), which severely limits my code's readability.
I saw this hack which consists in defining an Infix class allowing to create custom operators by overloading or and ror operators. My question is: How could I use this trick to make an infix |at| operator working just like @?
What I tried is:
import numpy as np

class Infix:
    def __init__(self, function):
        self.function = function
    def __ror__(self, other):
        return Infix(lambda x, self=self, other=other: self.function(other, x))
    def __or__(self, other):
        return self.function(other)
    def __call__(self, value1, value2):
        return self.function(value1, value2)

# Matrix multiplication
at = Infix(lambda x,y: np.matmul(x,y))

M1 = np.ones((2,3))
M2 = np.ones((3,4))

print(M1 |at| M2)

When I execute this code, I get :
ValueError: operands could not be broadcast together with shapes (2,3) (3,4)

I think I have an idea of what is not working. When I only look at M1|at, I can see that it is a 2*3 array of functions:
array([[<__main__.Infix object at 0x7faa1c0d6da0>,
        <__main__.Infix object at 0x7faa1c0d6860>,
        <__main__.Infix object at 0x7faa1c0d6828>],
       [<__main__.Infix object at 0x7faa1c0d6f60>,
        <__main__.Infix object at 0x7faa1c0d61d0>,
        <__main__.Infix object at 0x7faa1c0d64e0>]], dtype=object)

This is not what I expected, since I would like my code to consider this 2d-array as a whole, and not element-wise...
Does anybody have a clue of what I should do?
PS: I also considered using this answer, but I have to avoid the use of external modules.

A: I found the solution to my problem here.
As suggested in the comments, the ideal fix would either be to use Python 3.x or to use numpy.matmul, but this code seems to work, and even has the right precedence :
import numpy as np

class Infix(np.ndarray):
    def __new__(cls, function):
        obj = np.ndarray.__new__(cls, 0)
        obj.function = function
        return obj
    def __array_finalize__(self, obj):
        if obj is None: return
        self.function = getattr(obj, 'function', None)
    def __rmul__(self, other):
        return Infix(lambda x, self=self, other=other: self.function(other, x))
    def __mul__(self, other):
        return self.function(other)
    def __call__(self, value1, value2):
        return self.function(value1, value2)

at = Infix(np.matmul)

M1 = np.ones((2,3))
M2 = np.ones((3,4))
M3 = np.ones((2,4))

print(M1 *at* M2)
print(M3 + M1 *at* M2)


text:
Q: T_{0} space with clopen base is totally disconnected I have a problem trying to prove the following theorem.
If $X$ is a $T_{0}$ space with a base $C$ of clopen sets, then X is totally disconnected.
By definition, a space is totally disconnected if and only if $C(x) = {x} \quad \forall x \in X$. I try to prove it by contradiction, suposing that $\exists y \in C(x) ,  x \neq y $ and trying to use the  $T_{0}$ property for finding a contradiction, but I am stucked.
I haven't found any solution to the problem in the web, so I would aprecciate if somebody could help me.
Regards.

A: HINT: If $x\ne y$, then either there is an open $U$ such that $x\in U$ and $y\notin U$, or there is an open $U$ such that $y\in U$ and $x\notin U$. Without loss of generality assume that there is an open $U$ such that $x\in U$ and $y\notin U$. Since $X$ has a clopen base, there is a clopen $B$ such that $x\in B\subseteq U$. Use $B$ to show that $y\notin C(x)$.


text:
Q: Let $A$, $B$, $C$ be three sets. Prove that if $A \setminus B \subseteq C$, then $A \setminus C \subseteq B$.
Let $A$, $B$, $C$ be three sets. Prove that if $A \setminus B \subseteq C$, then $A \setminus C \subseteq B$.

I was thinking of proving this with double inclusion but not too sure how I would approach it

A: Suppose that $(A \setminus B) \subset C$, and let $x \in A \setminus C$.
If you had $x \notin B$, then you would have $x \in A \setminus B$, so $x \in C$ by hypothesis. This is a contradiction. So $x \in B$.
So $(A \setminus C) \subset B$.

A: Proof: Let $A, B$ and $C$ be any sets. Suppose that $A \setminus B \subseteq C.$ Let $x \in A \setminus C.$ By definition, we have that $x \in A,$ and $x \notin C.$ We will consider two cases, namely if $x \in B$ and if $x \notin B.$
Case $1:$ $x \in B.$ Hence we conclude that $A \setminus C \subseteq B.$
Case $2:$ $x \notin B.$ Hence $x \in A \setminus B.$ Then we have that $x \in C.$ Which is a contradiction. So this case cannot happen.
Therefore, we have that $A \setminus C \subseteq B.$ $\square$


text:
Q: Plesk Obsidian, Github Cloning not working I am using this method mentioned here to clone my Github repo to my httpdocs folder: Is it possible to connect to private Github repositories using Plesk Git extension?, but I am unable to connect. I always get the following error:
Public key for the server at 'github.com' is already known in '/var/www/vhosts/new.example.com/.ssh/git_known_hosts'.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I am not using the standard SSH port but even if I switch to the default 22, I keep getting similar errors.
My firewall is accepting connections on my SSH port and I have added the public key on the SSH section on my Github account.
HTTPS is not an option because I am cloning a shared private repo.
I am using Centos 7 with Plesk Obsidian. Everything up to date.
I tried to use the same procedure on my Plesk Onyx server and it worked fine. Same firewall settings.
Any suggestions?
Thanks.

A: I managed to resolve it with the help of a support agent from Plesk (through teamviewer). I had to delete or rename the id_rsa, id_rsa.pub and known_hosts files from the .ssh folder and recopy the ssh key to my github account.

A: That error message generally appears when you already used the Plesk Git extension in some domain, so the solution is to have a different SSH public key for each domain you want to associate with a Git repo.
If you are in the Plesk panel, you should create a new subscription for that specific domain in order to get a new SSH public key generated by default in the Plesk Git extension.
Remember to add the public SSH key generated in you Github account.

A: You may try the following (solution for UBUNTU).

*

*Get details from key inside plesk: /etc/ssh# nano ssh_host_ed25519_key.pub

*Copy the content as is, eg; "ssh-ed25519 AAAAC... plesk.page"

*Go to Github --> SSH Keys page and create a new key, Name your key and paste the content from ssh_host_ed25519_key.pub

*After completion step 3, Go to plesk and create GitHub repository, ignore copying/pasting the SSH public key from plesk. It should now work.

*Alternative see this extension from Plesk to manage SSH Keys.
https://www.plesk.com/extensions/ssh-keys/

A: After changing domain name GIT cloning was no more working.
In my case the following file had to be updated:
nano /etc/ssh/ssh_host_rsa_key.pub

the domain name was at the end of the long line:
ssh-rsa <SSH public key> <domain to be replaced>


text:
Q: Nativescript 6.x project using Xcode 12. Will Xcode 13 work? I've got a NS 6.x project.
I can build it using Xcode 12.
If I download Xcode 13 (for iOS 15 testing), will it build the same NS 6.x project - without breaking it, requiring ns/plugin updates.
Thanks.

A: In case you haven't tried already, I have been able to compile an app using NS 6.8.0 on Xcode 13.  A couple of points:

*

*At first it seemed to fail building, but it does now work.  I think the solution was to remove my platforms folder but I can't confirm if this is the actual fix.

*My app now seems to be affected by a transparent status bar at the top of the app.  When you start to scroll the page the colour fills in, but I am still trying to find a solution for this.

I hope that helps!?

A: Regarding the transparent status bar, I was able to hack out this code and get it working:
in main-page.js:
const Color = require("tns-core-modules/color").Color
const Frame = require("tns-core-modules/ui/frame").Frame;
const platform = require("tns-core-modules/platform");

in onNavigatingTo
  let osVersionMajor = platform.device.osVersion.split(".")[0];
  if (platform.isIOS && osVersionMajor >= 15 ) {
    let navigationBar = Frame.topmost().ios.controller.navigationBar;
    let appearance = new UINavigationBarAppearance();
    appearance.configureWithOpaqueBackground();
    appearance.backgroundColor = new Color("#FF2525FE").ios;
    appearance.titleTextAttributes = NSDictionary.dictionaryWithDictionary({
      [NSForegroundColorAttributeName]: UIColor.whiteColor
    });
    navigationBar.standardAppearance = appearance;
    navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance;
  }

This matches the blue title bar in the blue theme, but you could change the  hex code for the background color to whatever you want.  Also note, this is a NativeScript 6.8 JavaScript project.


text:
Q: How to cancel orders using payment method in magento I am creating an Open Source Extension for Magento. Its in very early stages. I am struggling with cancel orders problem. I found some solution here
Magento - How can I run code when my order is canceled or refunded.
But whenever I cancel an order it calls neither void (in case of only Authorize payment action) nor refund (in case of authorize-capture payment action).
When I use capture-refund, It says the order cannot be cancelled.
When I use authorize-void, It say's the order have been cancelled. But the Void() function wasn't called at all. I kept some Mage::Log() functions inside. Which are not shown in Log file.
I don't understand what is wrong.
Here is the code.
This is payment method model
<?php
class Package_Cashondelivery_Model_Createorder extends Mage_Payment_Model_Method_Abstract
{
    protected $_code = 'cashondelivery';
    protected $_canCapture = true;
    protected $_canUseCheckout = true;
    protected $_canFetchTransactionInfo     = true;
    protected $_isGateway                   = true;
    protected $_canUseInternal = true;
    protected $_canVoid    = true;
    protected $_canRefund = true;

    public function validate()
    {

        $paymentInfo = $this->getInfoInstance();
         if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
             $postCode = $paymentInfo->getOrder()->getBillingAddress()->getPostcode();

         }
         else {
             $postCode = $paymentInfo->getQuote()->getBillingAddress()->getPostcode();
         }
         $res=Api->validatePostCode($postCode);
         $r = $res=='false'? FALSE : TRUE;
         if (!$r) {
             Mage::throwException($this->_getHelper()->__('Sorry ! Service is not available in your area'));
         }
         return $this;
    }

    public function authorize(Varien_Object $payment, $amount)
    {
        -------------------------------
        -------------------------------
        -------------------------------
        #This is working fine
        $transactionId = Api->someCall();
        $payment->setTransactionId();
       -------------------------------
       -------------------------------
       -------------------------------
       -------------------------------
       -------------------------------
       -------------------------------
        return $this;
    }

    public function void(Varien_Object $payment)
    {
        if (!$this->canVoid($payment)) {
            Mage::throwException($this->_getHelper()->__('Void action is not available.'));
        }
        -------------------------------
        -------------------------------
        -------------------------------
        -------------------------------
        Mage::Log('Starting Void here....');
        $transactionId = $Payment->getTransactionId();
        Api->cancelOrder($transactionId);
        return $this;
        -------------------------------
        -------------------------------
        -------------------------------
    }
}
?>

Here is config file.
<?xml version="1.0"?>
<config>
    <modules>
       <Package_Cashondelivery>
<!-- declare module's version information for database updates -->
          <version>0.1.0</version>
       </Package_Cashondelivery>
    </modules>
    <global>
<!-- declare model group for new module -->
        <models>
<!-- model group alias to be used in Mage::getModel('newmodule/...') -->
            <cashondelivery>
<!-- base class name for the model group -->
                <class>Package_Cashondelivery_Model</class>
            </cashondelivery>
        </models>
        <helpers>
            <cashondelivery>
                <class>Package_Cashondelivery_Helper</class>
            </cashondelivery>
        </helpers>
<!-- declare resource setup for new module -->
        <resources>
<!-- resource identifier -->
            <cashondelivery_setup>
<!-- specify that this resource is a setup resource and used for upgrades -->
                <setup>
<!-- which module to look for install/upgrade files in -->
                    <module>Package_Cashondelivery</module>
                </setup>
<!-- specify database connection for this resource -->
                <connection>
<!-- do not create new connection, use predefined core setup connection -->
                    <use>core_setup</use>
                </connection>
            </cashondelivery_setup>
            <cashondelivery_write>
                <connection>
                  <use>core_write</use>
                </connection>
            </cashondelivery_write>
            <cashondelivery_read>
               <connection>
                <use>core_read</use>
              </connection>
            </cashondelivery_read>
        </resources>
    </global>
<!-- declare default configuration values for this module -->
    <default>
        <payment>
            <cashondelivery>
                <active>1</active>
                <model>cashondelivery/createorder</model>
                <order_status>Processing</order_status>
                <payment_action>authorize</payment_action>
                <title>Cash On Delivery</title>
                <example_uri>services.example.com</example_uri>
            </cashondelivery>
         </payment>
    </default>
</config>

Anybody has any idea why this happens and how to resolve.

A: Sadly I don't have enough "experience" to just comment, so I'll post this as an answer instead.
Can you verify the order is in the proper state before canceling? For example, some orders are auto processed, like software downloads. Credit card charging, and product distribution can all be done automatically, then I doubt it lets you cancel. Can you verify the order is still pending?

A: You should only be able to 'Cancel' or 'Void' an order that has not been captured. i.e. an order that doesn't have an associated invoice.
If you want to refund a captured order, then this should be done by creating a creditmemo on the invoice.
For the issue of your payment method's void function not being called - you should set up an IDE like Netbeans, using X-Debug, and put a break point in the first line of the cancelAction and voidPaymentAction functions in Mage_Adminhtml_Sales_OrderController. This way you can step through the code and see where the issue is.
For example, the route to void should be something like...
Mage_Adminhtml_Sales_OrderController->voidPaymentAction:629
Mage_Sales_Model_Order_Payment->void:602
Mage_Sales_Model_Order_Payment->_void:1088
Package_Cashondelivery_Model_Createorder->void:
So if you don't want to get into using a proper debugging environment, then put your log statements along that path and check all the conditions are valid to call your payment method's void function.

A: The problem is that Magento indeed does not call either Void, nor Refund when you press cancel. When you press void it runs the void method, and when you click on refund it calls the refund method. And guess what, when you press on cancel, it actually calls the cancel method.
I agree that when you press cancel you actually want to void the authorization, but it comes handy to have separate methods just in case you would like to do something else too. So you could do something like this:
/*
 * Your class stuff
 */

public function cancel(Varien_Object $payment){

    // void the order if canceled
    $this->void($payment);

    return $this;
}

public function void(Varien_Object $payment){

    /* Whatever you call to void a payment in your gateway */

}


text:
Q: Ruby: Use module method inside a class method How do we use a module method inside a class method without extending the module?
module TestModule
  def module_method
    "module"
  end
end

class TestClass
  include TestModule

  def self.testSelfMethod
    str = module_method
    puts str
  end
  TestClass.testSelfMethod
end

Then it returns:
test.rb:11:in `testSelfMethod': undefined local variable or method `module_method' for TestClass:Class (NameError)

A: By including the module, you make module_method is an instance method on TestClass, meaning you need to invoke it on an instance of the class, not the class itself.
If you want to make it a method on the class itself, you need to extend TestModule, not include it.
module TestModule
  def module_method
    "module"
  end
end

class TestClass
  extend TestModule # extend, not include

  def self.testSelfMethod
    str = module_method
    puts str
  end
  TestClass.testSelfMethod # "method"
end

A: Just because comments are too few characters, but agree with maegar:
module TestModule
  def module_method
    "module"
  end
end

class TestClass

  def self.testSelfMethod
    str = module_method + " from class"
    puts str
  end

  def testSelfMethod
    str = module_method + " from instance"
    puts str
  end
end

TestClass.extend TestModule
TestClass.testSelfMethod # => module from class

TestClass.include TestModule
TestClass.new.testSelfMethod # => module from instance