text:
Q: Deserialize a single XML tag into separate properties with C# Consider the following simplified XML. I get it passed from a service and don't have any influence on its structure. It contains 3 tags that are defined by their order, i.e. the first-occuring <string> always refers to the same property.
<?xml version="1.0" encoding="UTF-8"?>
<result>
   <entry>
      <string>foo</string>
      <int>42</int>
      <string>bar</string>
   </entry>
   <entry>
      <string>baz</string>
      <int>1234</int>
      <string>foobar</string>
   </entry>
</result>

I'd like to deserialize the <entry> elements into a class with separate properties, e.g.
public class ResultEntry {
  // this property equals to the 1st-occuring <string> element in the XML
  public String PropA { get; set; }
  // this property equals to the 2nd-occuring <string> element in the XML
  public String PropB { get; set; }
  // this property equals to the <int> element in the XML
  public Int32  PropC { get; set; }
}

Is there any way to deserialize the two <string> elements into the two different properties? I can't just add the [XmlElement(ElementName="string")] annotation to both of them, as this results an an InvalidOperationException.
One way could be to add a property like
[XmlElement(ElementName="string")]
public List<string> StringVals {get; set;}

instead, and to manually move the values later on, but this feels way too hacky to me.

A: Use following :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace ConsoleApplication161
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XmlReader reader = XmlReader.Create(FILENAME);
            XmlSerializer serializer = new XmlSerializer(typeof(Result));
            Result result = (Result)serializer.Deserialize(reader);
        }
    }
    [XmlRoot("result")]
    public class Result
    {
        [XmlElement("entry")]
        public List<ResultEntry> entries { get; set; }
    }
    public class ResultEntry
    {
        [XmlElement("string")]
        public List<String> PropA { get; set; }
        [XmlElement("int")]
        public int PropB { get; set; }
    }
}

You could do something like below which I do not recommend
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace ConsoleApplication161
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XmlReader reader = XmlReader.Create(FILENAME);
            XmlSerializer serializer = new XmlSerializer(typeof(Result));
            Result result = (Result)serializer.Deserialize(reader);
        }
    }
    [XmlRoot("result")]
    public class Result
    {
        [XmlElement("entry")]
        public List<ResultEntry> entries { get; set; }
    }
    public class ResultEntry
    {
        private string PropA { get; set; }
        private string PropB { get; set; }

        [XmlElement("string")]
        public List<String> Properties {
            get { return new List<string> { PropA, PropB};}
            set { PropA = value[0]; PropB = value[1]; }
        }
        [XmlElement("int")]
        public int PropC { get; set; }
    }
}


text:
Q: Get the set of grouped values as a list using linq I am taking a datatable and finding all the rows for a specific key that have fewer than three entries in the table for that key value. I can do this fine and it returns a grouping with the key being the id I want to group on and a list of the datarows that, for each key value, don't exist at least three times. Now I want to get a straight list of all those datarows that failed. I am having trouble doing this. All I can seem to do is get a list of lists.
var rows = from dr in stagingTable.AsEnumerable()
group by dr.Field<long>("KEY_ID") into g
where g.Count() < 3
select new {ID = g.Key, Values = g};

Now that I have the grouped information, I want a straight list of all the datarows that can be found within all the groups. Doing g.ToList() just gives me a list of lists.
Any suggestions?

A: If you wanted to flatten that list of lists:
 var flattened = rows.SelectMany(x=>x.Values).ToList();

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to lock a table before running an insert in Laravel eloquent I have a table "transfers" to track transfer of amount from user A to user B.
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id       | int(10)     | NO   | PRI | NULL    |       |
| sender   | int(10)     | NO   |     | NULL    |       |
| amount   | int(10)     | NO   |     | NULL    |       |
| receiver | int(10)     | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+

Before every new insert to this table, I need to check if the sender has enough balance.
Here is the "users" table
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id       | int(10)     | NO   | PRI | NULL    |       |
| name     | varchar(100)| NO   |     | NULL    |       |
| balance  | int(10)     | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+

How do I implement locking here so that users balance doesn't gets reduced by some others methods after passing balance validation.
public function store(Transfer $transfer, TransferRequest $request)
{
    $transfer->isAllowed($request); // Will abort if users balance is low

     //what if the users balance gets reduced by some other request here !!

    $transfer->fill($request->all())->save();

    return redirect()->route('transfers.index')->withStatus(__('Transfer successfully created.'));
}

A: you can use sharedLock or lockForUpdate method in laravel documentation
https://laravel.com/docs/5.2/queries#pessimistic-locking


text:
Q: Blur Background on Lifting a Card What I'm working on
I am currently working on a basic card game.  I have gotten done some of the styling but am struggling with a couple of things in jQuery.
Question
There are two major issues with the code.

*

*When you lift a card and drag it on top of another, the divs overlap, oddly.

*I wish to blur the rest of body when you pickup and start dragging a card.  I have no idea how to start doing that.  I have googled around a bit and haven't made any progress.

Code
Aside: Any suggestion on how to improve the code is encouraged.

cards = [{
    "name": "Mutant",
    "attack": 500,
    "defense": 100,
    "health": 1000,
    "img": "http://neil.computer/stack/bg2.jpg",
    "effects": {

    },
  },
  {
    "name": "Angry Mom",
    "attack": 500,
    "defense": 100,
    "health": 9001,
    "img": "http://neil.computer/stack/bg3.jpg",
    "effects": {

    },
  }
];

function render($selector, card) {
  $(`

` + card["name"] + `

` + card["attack"] + `

` + card["defense"] + `

` + card["health"] + `
`).appendTo($selector);
  $selector.css({
    "background-image": "url(" + card["img"] + ")",
  });
}

render($(".card").draggable(), cards[1]);
@import url(https://fonts.googleapis.com/css?family=Macondo);
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css);

body {
margin:0;
padding:0;
}

.card {
font-family:Macondo, cursive;
position:relative;
width:200px;
height:200px;
border:1px solid #000;
border-radius:4px;
background-size:cover;
background-repeat:no-repeat;
background-position:center center;
}

.card .front {
position:absolute;
z-index:1;
color:#FFF;
font-size:20px;
background:rgba(77,77,77,.7);
border:1px solid #000;
-webkit-transition:background .1s;
transition:background .5s;
padding:2px;
}

.card:hover .front {
background:rgba(55,55,55,.9);
-webkit-transition:background .1s;
transition:background .5s;
}

.card .front i {
margin-right:6px;
}

.card .name {
top:0;
left:0;
text-align:center;
font-weight:700;
border-radius:2px 2px 0 0;
width:calc(100%-6px);
}

.card .attack {
border-radius:0 5px 0 2px;
left:0;
bottom:0;
}

.card .defense {
border-radius:5px 0 2px 0;
right:0;
bottom:0;
}

.card .health {
top:50%;
left:50%;
transform:translate(-50%,-50%);
border-radius:5px;
}

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">

A: Here you go. Try this working snippet.

cards = [{
    "name": "Mutant",
    "attack": 500,
    "defense": 100,
    "health": 1000,
    "img": "http://neil.computer/stack/bg2.jpg",
    "effects": {

    },
     },
     {
    "name": "Angry Mom",
    "attack": 500,
    "defense": 100,
    "health": 9001,
    "img": "http://neil.computer/stack/bg3.jpg",
    "effects": {

    },
     }
   ];

 renderCards( cards );

 $(document).on("drag", ".card", function(){
  $(this).addClass('active');
  $('.masking').addClass('mask');
 });

 $('.masking').on("click", function(){
  $(this).removeClass('mask');
  $('.card').removeClass('active');
 });

 function renderCards( cards ) {
  $( cards ).each(function( index ) {
   var card  = cards[index];
   var cardDiv = $('
');

   $('
' + card["name"] + '

' + card["attack"] + '

' + card["defense"] + '

' + card["health"] + '
').appendTo(cardDiv);

   cardDiv.css({"background-image": "url(" + card["img"] + ")"}).draggable().appendTo('.cards');
  });
 }
 @import url(https://fonts.googleapis.com/css?family=Macondo);
 @import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css);
 @import url(https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css);

 body {
  background: #000;
  margin:0;
  padding:0;
 }

 .card {
  font-family:Macondo, cursive;
  position:relative;
  cursor: pointer;
  display: inline-block;
  width:200px;
  height:200px;
  border:1px solid #000;
  border-radius:4px;
  background-size:cover;
  background-repeat:no-repeat;
  background-position:center center;
  margin: 10px;
  z-index: 1;
 }
 .card.active{
  z-index: 3;
 }

 .card .front {
  position:absolute;
  z-index:1;
  color:#FFF;
  font-size:20px;
  background:rgba(77,77,77,.7);
  border:1px solid #000;
  -webkit-transition:background .1s;
  transition:background .5s;
  padding:2px;
 }

 .card:hover .front {
  background:rgba(55,55,55,.9);
  -webkit-transition:background .1s;
  transition:background .5s;
 }

 .card .front i {
  margin-right:6px;
 }

 .card .name {
  top:0;
  left:0;
  text-align:center;
  font-weight:700;
  border-radius:2px 2px 0 0;
  width:calc(100%-6px);
 }

 .card .attack {
  border-radius:0 5px 0 2px;
  left:0;
  bottom:0;
 }

 .card .defense {
  border-radius:5px 0 2px 0;
  right:0;
  bottom:0;
 }

 .card .health {
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  border-radius:5px;
 }

 .mask {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: white;
  opacity: 0.5;

  filter: blur(8px);
  -webkit-filter: blur(8px);
  -moz-filter: blur(8px);
  -o-filter: blur(8px);
  -ms-filter: blur(8px);
  z-index: 2;
 }


text:
Q: Crear aplicacion de java a .exe con Launch4j Desarrollé una aplicación en java en Netbeans. Lo que necesito es convertirla a .exe para usarla en un equipo que tiene Windows xp de 32 bits a este no tiene ni se le puede poner el JRE por cuestiones de seguridad.
Mi PC trabaja con Windows 10 a 64 bits, encontré un post que me explicaba como con el Launch4j podría resolver el problema del JRE pero al abrir la App en la computadora con Windows xp 32 bits me da un problema de compatibilidad.
¿Alguna idea de como poder resolver este problema?

A: Launch4j te permite descargar el en el pc destinatario el runtime java para ejecutar la aplicación.
Ya que en este caso no puedes instalarla, puedes descargar desde la página de Oracle un runtime java de 32 bits y meterlo junto con la aplicación y crear un script bat para ejecutarlo. Esto aumentará considerablemente el tamaño de la aplicación (Aplicaciones como JDownloader tienen embebido su propio runtime de java por ejemplo)
También puedes usar Avian http://readytalk.github.io/avian/ para integrar una pequeña maquina virtual jutno con la aplicación y tener el .exe


text:
Q: Inadvertent character strip when reading .txt file in Python I have a Python script that reads DB table names from a .txt file, executes a set of SQL statements against them, and exports out a .CSV file with results. The .txt file looks like this:
TableA
TableB
TableC

I have code that reads through that file looks like this:
f = open("table.txt", "r")
for s in f:
    cfg_tbl = s[0:len(s) -1]
    func_1(cfg_tbl)
f.close()

(func_1 is a function outside of this that executes the sql, not important)
The problem I am having is, when I save the .txt file and the cursor is right next to the 'C' in 'TableC', the 'C' gets truncated.  I have to save the file with an extra space after the last table in order for it to work.  But if I change this:
cfg_tbl = s[0:len(s) -1]

to this:
cfg_tbl = s[0:len(s)]

it errors out with:
Invalid argument: 'TableA \n.csv'

Any ideas how to read the .txt file without having to account for extra spaces needed, or even blank lines etc.
Thanks

A: You're using s[0:len(s) -1] to remove the newline at the end of each line. The problem is that the last line of the file doesn't end with a newline, so you're removing the last character of the filename with that.
Use the strip() method to remove leading and trailing whitespace from a string.
cfg_tbl = s.strip()

If there's no newline, it won't remove anything.
BTW, s[0:len(s) -1] can be written more simply as s[:-1]. When the end of a slice is negative, it counts from the end.


text:
Q: What's "\." in postgresql dump file? I have a Postgresql dump file which i'm trying to restore. I get this error regarding an invalid data i guess.

ERROR:  invalid input syntax for integer: "."

and when i checked the file, there are data like this:
469215  2009-10-10 18:16:47.041377  0   1
471217  2009-10-10 18:25:12.536352  0   1
473224  2009-10-17 09:46:43.041604  0   1
473228  2009-10-22 10:58:40.194244  0   1
.

so i was wondering what is this "." do?
i check some other working dumps and they ended their data line with "." which i guess it's the correct syntax!
Please tell me what's the correct syntax and what does it do?
thank you

A: Seems that it marks the end of a COPY statement
From the documentation
End of data can be represented by a single line containing just backslash-period (\.).
 An end-of-data marker is not necessary when reading from a file, since the end of file
serves perfectly well; it is needed only when copying data to or from client
applications using pre-3.0 client protocol.


text:
Q: Simple Power Sink Circuit I've got a test bench for brushless DC motors, which is supplied with a regulated power supply unit. The motor itself is driven by an electronic speed control (ESC), which feeds energy back to the power supply when actively slowing down the motor (regenerative braking). My power supply cannot sink current, which leads to non-transient high voltages when braking or spinning down. This would damage the test bench's measurement equipment, causing it to terinate the test run.
I have (unsuccessfully) tried to sink the power into a MOSFET crowbar circuit, which turned out to be a bad idea. Although rated for a continuous \$I_D\$ of 72A (at \$V_{GS}\$ = 10V, though), the transistor got fried at ~500 mA already, despite a solid connection to a large metal beam as heatsink.
Before frying the next components, I'd like to ask:

*

*Is the (a) crowbar circuit applicable in this case?
It does not seem such a good idea to me anymore.

*What would be a better power sink circuit?

A: *

*It could be. But you need to keep the power on the mosfet within limits.

*

*Electrical limits.

*Thermal limits.

Although the datasheet might say it can do 150 Watt, you can't go from 0 to 150 Watt in an instance when it's at room temperature. It will  destroy itself from the thermal stress. I'd keep the TO-220 around 40 Watts maximum.

*A variable frequency drive with brake uses a resistor with chopper. This can be as simple as a comparator enabling the resistor when the DC-Link voltage exceeds the threshold. This is the voltage on the capacitor bank.

(source)
This is basically what you did with the crowbar, except with a resistor as the dissipating element. Resistors can handle more abuse than semiconductors in linear mode*.
*Infineon appnote: Linear Mode Operation and Safe Operating Diagram of Power-MOSFETs (J . Schoiswohl)


text:
Q: Difference between Layer File, Layer Package, and Map Package? What would I use them for? I know map package comprises all the layers but how is a map package different from the others?

A: Layer File

A Layer File (.lyr) is a file that stores the path to a source
  dataset and other layer properties, including symbology.

Layer Package:

A Layer Package encapsulates the data, cartography, and other
  properties of the layer as it's authored in ArcGIS into one easily
  shareable package

Map Package:

A Map Package contains a map document (.mxd) and the data
  referenced by the layers it contains, packaged into one convenient,
  portable file. Map packages can be used for easy sharing of maps
  between colleagues in a work group, across departments in an
  organization, or with any other ArcGIS users via ArcGIS Online.

(Quotes all from Esri)
So to put in a few words, a Layer File holds path, symbology and layer settings (but no data).  Layer Package holds the layer settings plus the data in one package.  A Map Package holds the entire MXD/map information, multiple layers, and the data in one package.


text:
Q: Running a public static void main in Groovy Eclipse Sorry Groovy Noob here:
Here is my Groovy Class -
class MyClass {
    static void main() {
        println("Hello World");
    }
    ...

How do I run this classin Eclipse STS?  I want to keep the main method.  I do not want to change this to just a script.
Thanks

A: To initiate a method, main you must pass in a string array (String[] something). Use the following.
public static void main(String[] args)
{
System.out.println("Hello World")!
}

A: Remember... a Groovy class is a Java class.  All you need to do is right-click -> Run as -> Java application.


text:
Q: O_TRUNC in system call "open()" not actually deleting contents of file From what I understand, the O_TRUNC specifier for the open() function should delete what's in the file first, then start writing.
Instead what it's doing is just having me overwrite what's in the file as I go.
My issue is the file contains the ASCII '11', and what it should do is read that and overwrite it to '8', but the file ends up as '81' as it's not deleting the whole thing before writing.
The goal of the code is to read the number in the file, decrement it by 3, then put that number back in the file, using only system calls.
#include <unistd.h>
#include <fcntl.h>

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

    int fp = open("file.txt", O_RDONLY);
    char c1, c2, c3='\n';

    read(fp, &c1, 1);
    read(fp, &c2, 1);
    close(fp);
    fp = open("file.txt", O_TRUNC || O_WRONLY);

    if (c2 == '\n')
        c1 -= 3;
    else {
        if (c2 >= '0' && c2 <= '2' ) {
            c1--;
            c2 += 7;
        }
        else
            c2 -= 3;

    }
    if (c1 != '0')
        write(fp,&c1,1);
    if (c2 != '\n')
        write(fp,&c2,1);
    write(fp,&c3,1);
    return 0;
}

A: O_TRUNC || O_WRONLY is a logical "or" and almost certainly results in a int value of 1, which is usually what O_WRONLY is defined to.  You want a bitwise "or" with the | operator.  Note that it's just one | character:
fp = open("file.txt", O_TRUNC | O_WRONLY);


text:
Q: PHP Object creation, Factory Method and Dependency Injection I'm looking forward for a nice pattern to create objects that are bound to a database. I'm going to illustrate my thoughts with a simple example: the creation of a user.
First: Factory method to Create/Load a user. User configuration is done in the new created instance.
$user = User::Create($db); // Flag the instance to create an user when save() is called
$user->setUsername('...');
$user->set...;
$user->save(); // Will insert a new user into the database.

...
$user = User::Load($db, id); // Load an user from the database. Flag object to update.
$user->setUsername('...'); // Change username.
$user->save(); // Update existing object instead of inserting a new one.

Second: Factory method to create immediatly a new user.
User::Create($db, $username, $password, ...); // Create and insert a new user.
...
$user = User::Load($db, 1);
$user->setUsername("..."); // Change username.
$user->save(); // Save only updates a user, no flag needed because an user is entirelly created by User::Create().

Third: Using a factory class with static factory methods.
Factory::newUser($db, $username, $password, ...); // May contain many other types of objects.

And i can do always something like this:
$factory = new Factory($db);
$user = $factory->newUser($username, $password, ...);

Another thing is, should i create a singleton that provides an handle to a database that will be used on the application to create objects (without hardcoding the handle inside objects) ?
Example:
class DB {
    public static function handle() { /* Do a lazy connection to a database once. */ }
}

...
$user = User::Create(DB::handle(), ...);

So, my real question is, what's the best pattern? I know that this might be too relative, but i need some hints, and of course, i want to leave the dependencies outside, not hardcoded inside objects.
Thanks in advance.

A: If your problem comes from "model layer" you should look for database patterns, such as:

*

*Data Mapper

*Active Record


text:
Q: Appended button not calling function when clicked I made a userscript that appends two input elements in a form, the first working as textarea and the second working as button. They work perfectly fine on a local/static page but if I try to click on the button that should call the function uuid(), nothing happens.
Edit: Something I forgot to mention is that this userscript should work together with another userscript that adds/edits elements so maybe there is an issue with loading timings. I thought I had solved the issue making the my custom userscript load when the page finishes to load but I still have issues..
This is the script:
var qrform, rbutton, milliseconds, randomnumber, css;
css = document.createElement("style");
css.type = "text/css";
/*jshint multistr: true */
css.innerHTML = "#rb{\
    display: -webkit-flex;\
    display: flex;\
    -webkit-align-items: stretch;\
    align-items: stretch;\
    height: 25px;\
    margin-top: 1px;\
    text-transform: uppercase;\
    font-size: 10px;\
    }\
    #rb #uform + input {\
    text-transform: uppercase;\
    font-size: 10px !important;\
    }\
    #uform{\
    width:95%;\
    text-align:center;\
    }\
    ";
document.body.appendChild(css);
qrform = document.getElementById("qr").getElementsByTagName("form")[0];
rbutton = document.createElement('div');
rbutton.setAttribute("id", "rb");
qrform.appendChild(rbutton);
rbutton.innerHTML = "<input id=\"uform\" type=\"text\" name=\"UUID\" placeholder=\"UUID\" readonly><input type=\"button\" value=\"GENERATE\" onclick=\"uuid()\">";

function uuid() {
    milliseconds = Date.now();
    randomnumber = Math.floor(Math.random() * 365 * 86400000);
    document.getElementById("uform").value = milliseconds - randomnumber;
    document.getElementById("uform").readOnly=true;
}

Edited with the working script:
var qrform, rcontainer, rbutton, parentrbutton, milliseconds, randomnumber, css;
css = document.createElement("style");
css.type = "text/css";
/*jshint multistr: true */
css.innerHTML = "#rb{\
    display: -webkit-flex;\
    display: flex;\
    -webkit-align-items: stretch;\
    align-items: stretch;\
    height: 25px;\
    margin-top: 1px;\
    text-transform: uppercase;\
    font-size: 10px;\
    }\
    #rb #uform + input {\
    text-transform: uppercase;\
    font-size: 10px !important;\
    }\
    #uform{\
    width:95%;\
    text-align:center;\
    }\
    ";
document.body.appendChild(css);
qrform = document.getElementById("qr").getElementsByTagName("form")[0];
rcontainer = document.createElement('div');
rcontainer.setAttribute("id", "rb");
qrform.appendChild(rcontainer);
rcontainer.innerHTML = "<input id=\"uform\" type=\"text\" name=\"UUID\" placeholder=\"UUID\" readonly>";
rbutton = document.createElement('input');
rcontainer.appendChild(rbutton);
rbutton.setAttribute("type", "button");
rbutton.setAttribute("value", "generate");
rbutton.addEventListener('click', uuid);

function uuid() {
    milliseconds = Date.now();
    randomnumber = Math.floor(Math.random() * 365 * 86400000);
    document.getElementById("uform").value = milliseconds - randomnumber;
    document.getElementById("uform").readOnly=true;
}

A: What errors do you get when you click the button?
You might try defining the function before inserting the button. However, it's generally considered bad practice to use inline onclick like that. It's better to add an event handler.
var button = document.createElement('button')
button.addEventListener('click', uuid)


text:
Q: undefined reference glBindVertexArrayOES in eclipse All GLES2 i use compile but these errors wont go away

undefined reference to glBindVertexArrayOES
undefined reference to glBindVertexArrayOES
undefined reference to glGenVertexArraysOES
undefined reference to glBindVertexArrayOES
undefined reference to glBindVertexArrayOES

It seems as-if eclipse cannot find where these functions where defined which i dont understand since all other function are found perfectly, do i need to declare anything to make these work?
thanks

A: Have you tried to call this from native code (using JNI)? Android doesn't provide access to all OpenGL ES functions from Java. I use GLES20Fix (more info) in order to get access to missing OpenGL ES API. You can extend this JNI library with calls to GL ES API functions you need.
I've checked Android documentation and Java bindings doesn't have glBindVertexArrayOES function so it seems that you have to use JNI.


text:
Q: AWS DMS unable to pick Postgre Replication Slot with custom name I am creating a DMS task to load data from RDS postgre to AWS s3. The DMS is creating a replication slot by default having a long alpha numeric slot name . Both Full load and CDC works fine with it .
I want to provide a useful name to the slot so that I can identify for which table it is being used for ?
Now when I try to create a slot with the a custom name using the following query :
select  * FROM pg_create_logical_replication_slot('slotname', 'test_decoding');

It is getting created. But the active flag is false .
select * from pg_replication_slots

Is there any way to make it active ?
And provide the slotName in DMS Endpoint configuration in Extra connection attributes slotName=slotname


text:
Q: Some functions appear as undefined firebase/auth v9 I was rewriting my code from firebase v8 to v9, i was watching this tutorial
i try to use the signInWithRedirect() function followed by the getRedirectResult() function
i import them like i import my others functions but when i console.log() thoses i get undefined in my console
here is my code :
import { View } from "react-native";

import firebase, { initializeApp } from 'firebase/app';

import { GoogleAuthProvider, useDeviceLanguage, signInWithCredential, onAuthStateChanged, getAuth, signInWithRedirect, getRedirectResult } from "firebase/auth";

const LoginSceen = (props) => {

  console.log(signInWithRedirect) //return undefined
  console.log(getRedirectResult ) //return undefined

  console.log(getAuth) //return [Function getAuth]
  console.log(GoogleAuthProvider) //return [Function GoogleAuthProvider]

  return (
    <View style={{ flex: 1, backgroundColor: "#9297C4" }}>

    </View>
  );
}

export default LoginSceen;

PS : the error i get is TypeError: _auth.signInWithRedirect is not a function
firebase version in my package.json "firebase": "^9.6.0",
here the getAuth function detected by vscode IntelliSense
here the signInWithRedirect function who appear as undefined in my console but detected too by IntelliSense

A: There is no solution : since

React Native does not export the signInWIthPopup and
signInWithReactNative entrypoints since both of these functions
directly modify the DOM
by sam-gc

And here the response i get from the Firebase team on my github isue : https://github.com/firebase/firebase-js-sdk/issues/5837#issuecomment-1005038520


text:
Q: buildroot file system & cross compiling: dynamically linked application fails but static ok. How to link against uClibc I have a buildroot created file system, and I am trying to execute some c-code on lighttpd server.
I have created a simple C module that just prints out few lines of html. Code looks like this:
#include "stdio.h"

int main(void) {
  printf( "Content-Type: text/plain\n\n" );
  printf("testing C code\n");
  return 0;
}

I'm using compiler from Ubuntu repository, to compile it arm-linux-gnueabi-gcc -o test.cgi test.c. If I compile with -static flag, it will run just fine, and I can see the html displayed.
But compiling without the static flag, the execution fails like this:
# ./test.cgi
-sh: ./first.cgi: not found

I am wondering if the reason is wrong a c-library, and I should link against the uClibc that was compiled by buildroot.
In my buildroot folder output/host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib I can see following files:
-rwxr-xr-x 1 jlumme jlumme  25444 Jan 26 17:13 ld-uClibc-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     21 Jan 26 17:12 ld-uClibc.so.0 -> ld-uClibc-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme  13191 Jan 26 17:13 libcrypt-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     20 Jan 26 17:13 libcrypt.so.0 -> libcrypt-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     21 Jan 26 17:13 libc.so.0 -> libuClibc-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme  13383 Jan 26 17:13 libdl-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     17 Jan 26 17:13 libdl.so.0 -> libdl-0.9.33.2.so
-rw-r--r-- 1 jlumme jlumme    135 Jan 26 17:15 libgcc_s.so
-rw-r--r-- 1 jlumme jlumme 180152 Jan 26 17:15 libgcc_s.so.1
-rwxr-xr-x 1 jlumme jlumme  64555 Jan 26 17:13 libm-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     16 Jan 26 17:13 libm.so.0 -> libm-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme   4772 Jan 26 17:13 libnsl-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     18 Jan 26 17:13 libnsl.so.0 -> libnsl-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme  79059 Jan 26 17:13 libpthread-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     22 Jan 26 17:13 libpthread.so.0 -> libpthread-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme   4776 Jan 26 17:13 libresolv-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     21 Jan 26 17:13 libresolv.so.0 -> libresolv-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme  13927 Jan 26 17:13 librt-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     17 Jan 26 17:13 librt.so.0 -> librt-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 284451 Jan 26 17:13 libuClibc-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme   4955 Jan 26 17:13 libutil-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme     19 Jan 26 17:13 libutil.so.0 -> libutil-0.9.33.2.so

Is the libuClibc-0.9.33.2.so file that I'm looking for ?
How can I link my application against that ?
In my target board, I can see this in /usr/lib
lrwxrwxrwx    1 root     root            15 Jan 26  2013 libbz2.so -> libbz2.so.1.0.6
lrwxrwxrwx    1 root     root            15 Jan 26  2013 libbz2.so.1 -> libbz2.so.1.0.6
lrwxrwxrwx    1 root     root            15 Jan 26  2013 libbz2.so.1.0 -> libbz2.so.1.0.6
-rwxrwxr-x    1 root     root         57924 Jan 26  2013 libbz2.so.1.0.6
lrwxrwxrwx    1 root     root            16 Jan 26  2013 libelf.so -> libelf.so.0.8.12
lrwxrwxrwx    1 root     root            16 Jan 26  2013 libelf.so.0 -> libelf.so.0.8.12
-rwxr-xr-x    1 root     root         69924 Jan 26  2013 libelf.so.0.8.12
lrwxrwxrwx    1 root     root            16 Jan 26  2013 libpcre.so -> libpcre.so.1.0.0
lrwxrwxrwx    1 root     root            16 Jan 26  2013 libpcre.so.1 -> libpcre.so.1.0.0
-rwxr-xr-x    1 root     root         88804 Jan 26  2013 libpcre.so.1.0.0
lrwxrwxrwx    1 root     root            19 Jan 26  2013 libpcrecpp.so -> libpcrecpp.so.0.0.0
lrwxrwxrwx    1 root     root            19 Jan 26  2013 libpcrecpp.so.0 -> libpcrecpp.so.0.0.0
-rwxr-xr-x    1 root     root         27436 Jan 26  2013 libpcrecpp.so.0.0.0
lrwxrwxrwx    1 root     root            21 Jan 26  2013 libpcreposix.so -> libpcreposix.so.0.0.0
lrwxrwxrwx    1 root     root            21 Jan 26  2013 libpcreposix.so.0 -> libpcreposix.so.0.0.0
-rwxr-xr-x    1 root     root          5576 Jan 26  2013 libpcreposix.so.0.0.0
lrwxrwxrwx    1 root     root            19 Jan 26  2013 libsqlite3.so -> libsqlite3.so.0.8.6
lrwxrwxrwx    1 root     root            19 Jan 26  2013 libsqlite3.so.0 -> libsqlite3.so.0.8.6
-rwxr-xr-x    1 root     root        516472 Jan 26  2013 libsqlite3.so.0.8.6
lrwxrwxrwx    1 root     root            19 Jan 26  2013 libstdc++.so -> libstdc++.so.6.0.14
lrwxrwxrwx    1 root     root            19 Jan 26  2013 libstdc++.so.6 -> libstdc++.so.6.0.14
-rwxr-xr-x    1 root     root        418936 Jan 26  2013 libstdc++.so.6.0.14
-rw-r--r--    1 root     root          2422 Jan 26  2013 libstdc++.so.6.0.14-gdb.py
lrwxrwxrwx    1 root     root            16 Jan 26  2013 libxml2.so -> libxml2.so.2.8.0
lrwxrwxrwx    1 root     root            16 Jan 26  2013 libxml2.so.2 -> libxml2.so.2.8.0
-rwxr-xr-x    1 root     root       1063556 Jan 26  2013 libxml2.so.2.8.0
drwxrwxr-x    2 root     root          4096 Jan 26  2013 lighttpd
-rw-r--r--    1 root     root           195 Jan 26  2013 xml2Conf.sh

A: To build your application, you have to use the cross-compiler that Buildroot has generated, located in  output/host/usr/bin/<name-of-architecture>-gcc.
Here, you're using the Ubuntu ARM cross-compiler, that targets a system that uses the eglibc C library. But the system generated with Buildroot uses the uClibc C library. Therefore, there is absolutely no chance for a binary built with the Ubuntu ARM cross-compiler to run on this Buildroot generated system.
Just use the cross-compiler Buildroot has generated for you.


text: Q: iOS9 Split Screen iPad app communication I've just updated my iPad app to support iOS9 split screen. Currently I have my app on the left and safari on the right. When I click on a share extension in safari on the right can I trigger an event in my app on the left?


text:
Q: Using map2_dfr to bind_cols of data together I have two lists called 5 and 6 which look like the following:
df1:
$`5`
$`5`$`2016-01-01`
            [,1]
 [1,] -0.8357399
 [2,]  0.7793535
 [3,]  1.2425095
 [4,]  1.0564501
 [5,]  0.7351215
 [6,] -0.1976808
 [7,]  0.1692951
 [8,] -0.4280740
 [9,] -0.5507262
[10,]  1.0437385

$`5`$`2016-01-02`
             [,1]
 [1,]  0.68302631
 [2,]  1.16508889
 [3,]  1.04583836
 [4,]  0.71979517
 [5,] -0.14236742
 [6,]  0.07792941
 [7,] -0.41616267
 [8,] -0.49082834
 [9,]  1.09706485
[10,]  1.06911635

Which are some predictions. I also have another list which looks like:
df2:
$`5`[[3]]
         date      wind     temp
1  2010-01-03  1.387097 42.09677
2  2010-01-04  3.225806 45.16129
3  2010-01-05  4.192308 47.34615
4  2010-01-06  8.083333 39.83333
5  2010-01-07  8.774194 33.29032
6  2010-01-08  9.709677 32.25806
7  2010-01-09 12.419355 31.16129
8  2010-01-10  1.290323 27.54839
9  2010-01-11  2.258065 31.06452
10 2010-01-12  4.967742 33.83871

$`5`[[4]]
         date      wind     temp
1  2010-01-04  3.225806 45.16129
2  2010-01-05  4.192308 47.34615
3  2010-01-06  8.083333 39.83333
4  2010-01-07  8.774194 33.29032
5  2010-01-08  9.709677 32.25806
6  2010-01-09 12.419355 31.16129
7  2010-01-10  1.290323 27.54839
8  2010-01-11  2.258065 31.06452
9  2010-01-12  4.967742 33.83871
10 2010-01-13  4.129032 40.70968

Which consists of some original data. I want to join the df1 up with the df2 so it will look something like:
$`5`[[3]]
         date      wind     temp   prediction
1  2010-01-03  1.387097 42.09677  -0.8357399
2  2010-01-04  3.225806 45.16129   0.7793535
3  2010-01-05  4.192308 47.34615   1.2425095
4  2010-01-06  8.083333 39.83333   1.0564501
5  2010-01-07  8.774194 33.29032   0.7351215
6  2010-01-08  9.709677 32.25806  -0.1976808
7  2010-01-09 12.419355 31.16129   0.1692951
8  2010-01-10  1.290323 27.54839  -0.4280740
9  2010-01-11  2.258065 31.06452  -0.5507262
10 2010-01-12  4.967742 33.83871   1.0437385

and
$`5`[[4]]
         date      wind     temp   prediction
1  2010-01-04  3.225806 45.16129   0.68302631
2  2010-01-05  4.192308 47.34615   1.16508889
3  2010-01-06  8.083333 39.83333   1.04583836
4  2010-01-07  8.774194 33.29032   0.71979517
5  2010-01-08  9.709677 32.25806  -0.14236742
6  2010-01-09 12.419355 31.16129   0.07792941
7  2010-01-10  1.290323 27.54839  -0.41616267
8  2010-01-11  2.258065 31.06452  -0.49082834
9  2010-01-12  4.967742 33.83871   1.09706485
10 2010-01-13  4.129032 40.70968   1.09706485

Then finally I would like to bind all these lists together in a long format such as:
       date      wind     temp   prediction  ID
 2010-01-03  1.387097 42.09677  -0.8357399    5
 2010-01-04  3.225806 45.16129   0.7793535    5
 2010-01-05  4.192308 47.34615   1.2425095    5
 2010-01-06  8.083333 39.83333   1.0564501    5
 2010-01-07  8.774194 33.29032   0.7351215    5
 2010-01-08  9.709677 32.25806  -0.1976808    5
 2010-01-09 12.419355 31.16129   0.1692951    5
 2010-01-10  1.290323 27.54839  -0.4280740    5
 2010-01-11  2.258065 31.06452  -0.5507262    5
 2010-01-12  4.967742 33.83871   1.0437385    5
 2010-01-04  3.225806 45.16129   0.68302631   6
 2010-01-05  4.192308 47.34615   1.16508889   6
 2010-01-06  8.083333 39.83333   1.04583836   6
 2010-01-07  8.774194 33.29032   0.71979517   6
 2010-01-08  9.709677 32.25806  -0.14236742   6
 2010-01-09 12.419355 31.16129   0.07792941   6
 2010-01-10  1.290323 27.54839  -0.41616267   6
 2010-01-11  2.258065 31.06452  -0.49082834   6
 2010-01-12  4.967742 33.83871   1.09706485   6
 2010-01-13  4.129032 40.70968   1.09706485   6

Which is a large single data frame with the ID column being the list names.
I have tried with the following code:
library(purrr)
map2_dfr(df1, df2, ~map2_dfr(.x, map(.y, "date"), ~cbind(.x, date = .y)))

Which doesn't give what I am after.
# A tibble: 40 x 4
   `2016-01-01` `2016-01-02` `2016-01-03` `2016-01-04`
          <dbl>        <dbl>        <dbl>        <dbl>
 1       -0.836       0.683        1.12          0.935
 2        0.779       1.17         1.02          0.754
 3        1.24        1.05         0.776        -0.146
 4        1.06        0.720       -0.188         0.160
 5        0.735      -0.142        0.0884       -0.465
 6       -0.198       0.0779      -0.283        -0.543
 7        0.169      -0.416       -0.453         1.10
 8       -0.428      -0.491        1.06          1.03
 9       -0.551       1.10         1.03          0.976
10        1.04        1.07         1.06          1.29
# … with 30 more rows

Data:
df1 <- list(`5` = list(`2016-01-01` = structure(c(-0.835739850997925,
0.779353499412537, 1.24250948429108, 1.0564501285553, 0.735121548175812,
-0.197680771350861, 0.169295132160187, -0.42807400226593, -0.550726175308228,
1.04373848438263), .Dim = c(10L, 1L)), `2016-01-02` = structure(c(0.683026313781738,
1.16508889198303, 1.04583835601807, 0.719795167446136, -0.142367422580719,
0.0779294073581696, -0.416162669658661, -0.490828335285187, 1.09706485271454,
1.06911635398865), .Dim = c(10L, 1L)), `2016-01-03` = structure(c(1.12009644508362,
1.01791954040527, 0.775721669197083, -0.187799870967865, 0.0883594155311584,
-0.283172011375427, -0.452982068061829, 1.06388020515442, 1.02800369262695,
1.06038355827332), .Dim = c(10L, 1L)), `2016-01-04` = structure(c(0.935240745544434,
0.753606081008911, -0.145884394645691, 0.160260230302811, -0.464599192142487,
-0.543198347091675, 1.10469722747803, 1.03225469589233, 0.976013004779816,
1.28949522972107), .Dim = c(10L, 1L))), `6` = list(`2016-01-01` = structure(c(-1.05108523368835,
0.831294775009155, 1.0468602180481, 1.4151725769043, 0.89024829864502,
-0.23750251531601, 0.0968895554542542, -0.447583615779877, -0.885086059570312,
1.16484880447388), .Dim = c(10L, 1L)), `2016-01-02` = structure(c(0.898594379425049,
1.03132367134094, 1.43809175491333, 1.05361354351044, -0.204488694667816,
0.0889829993247986, -0.42036372423172, -0.906104445457458, 1.16317582130432,
1.13032007217407), .Dim = c(10L, 1L)), `2016-01-03` = structure(c(0.99635636806488,
1.5137802362442, 0.92145836353302, -0.218990564346313, 0.147298634052277,
-0.466208696365356, -0.896591305732727, 1.18873286247253, 1.10375666618347,
1.59670341014862), .Dim = c(10L, 1L)), `2016-01-04` = structure(c(1.45108199119568,
0.860665202140808, -0.299971401691437, 0.0754360556602478, -0.460747301578522,
-0.947231769561768, 1.06433939933777, 1.13789772987366, 1.70162570476532,
2.04307699203491), .Dim = c(10L, 1L))))

df2 <- list(`5` = list(structure(list(date = structure(c(14610, 14611,
14612, 14613, 14614, 14615, 14616, 14617, 14618, 14619), class = "Date"),
    wind = c(19.72, 3.19354838709677, 1.38709677419355, 3.2258064516129,
    4.19230769230769, 8.08333333333333, 8.7741935483871, 9.70967741935484,
    12.4193548387097, 1.29032258064516), temp = c(41.6, 41.9677419354839,
    42.0967741935484, 45.1612903225806, 47.3461538461538, 39.8333333333333,
    33.2903225806452, 32.258064516129, 31.1612903225806, 27.5483870967742
    )), row.names = c(NA, 10L), class = "data.frame"), structure(list(
    date = structure(c(14611, 14612, 14613, 14614, 14615, 14616,
    14617, 14618, 14619, 14620), class = "Date"), wind = c(3.19354838709677,
    1.38709677419355, 3.2258064516129, 4.19230769230769, 8.08333333333333,
    8.7741935483871, 9.70967741935484, 12.4193548387097, 1.29032258064516,
    2.25806451612903), temp = c(41.9677419354839, 42.0967741935484,
    45.1612903225806, 47.3461538461538, 39.8333333333333, 33.2903225806452,
    32.258064516129, 31.1612903225806, 27.5483870967742, 31.0645161290323
    )), row.names = c(NA, 10L), class = "data.frame"), structure(list(
    date = structure(c(14612, 14613, 14614, 14615, 14616, 14617,
    14618, 14619, 14620, 14621), class = "Date"), wind = c(1.38709677419355,
    3.2258064516129, 4.19230769230769, 8.08333333333333, 8.7741935483871,
    9.70967741935484, 12.4193548387097, 1.29032258064516, 2.25806451612903,
    4.96774193548387), temp = c(42.0967741935484, 45.1612903225806,
    47.3461538461538, 39.8333333333333, 33.2903225806452, 32.258064516129,
    31.1612903225806, 27.5483870967742, 31.0645161290323, 33.8387096774194
    )), row.names = c(NA, 10L), class = "data.frame"), structure(list(
    date = structure(c(14613, 14614, 14615, 14616, 14617, 14618,
    14619, 14620, 14621, 14622), class = "Date"), wind = c(3.2258064516129,
    4.19230769230769, 8.08333333333333, 8.7741935483871, 9.70967741935484,
    12.4193548387097, 1.29032258064516, 2.25806451612903, 4.96774193548387,
    4.12903225806452), temp = c(45.1612903225806, 47.3461538461538,
    39.8333333333333, 33.2903225806452, 32.258064516129, 31.1612903225806,
    27.5483870967742, 31.0645161290323, 33.8387096774194, 40.7096774193548
    )), row.names = c(NA, 10L), class = "data.frame")), `6` = list(
    structure(list(date = structure(c(14610, 14611, 14612, 14613,
    14614, 14615, 14616, 14617, 14618, 14619), class = "Date"),
        wind = c(19.72, 3.19354838709677, 1.38709677419355, 3.2258064516129,
        4.19230769230769, 8.08333333333333, 8.7741935483871,
        9.70967741935484, 12.4193548387097, 1.29032258064516),
        temp = c(41.6, 41.9677419354839, 42.0967741935484, 45.1612903225806,
        47.3461538461538, 39.8333333333333, 33.2903225806452,
        32.258064516129, 31.1612903225806, 27.5483870967742)), row.names = c(NA,
    10L), class = "data.frame"), structure(list(date = structure(c(14611,
    14612, 14613, 14614, 14615, 14616, 14617, 14618, 14619, 14620
    ), class = "Date"), wind = c(3.19354838709677, 1.38709677419355,
    3.2258064516129, 4.19230769230769, 8.08333333333333, 8.7741935483871,
    9.70967741935484, 12.4193548387097, 1.29032258064516, 2.25806451612903
    ), temp = c(41.9677419354839, 42.0967741935484, 45.1612903225806,
    47.3461538461538, 39.8333333333333, 33.2903225806452, 32.258064516129,
    31.1612903225806, 27.5483870967742, 31.0645161290323)), row.names = c(NA,
    10L), class = "data.frame"), structure(list(date = structure(c(14612,
    14613, 14614, 14615, 14616, 14617, 14618, 14619, 14620, 14621
    ), class = "Date"), wind = c(1.38709677419355, 3.2258064516129,
    4.19230769230769, 8.08333333333333, 8.7741935483871, 9.70967741935484,
    12.4193548387097, 1.29032258064516, 2.25806451612903, 4.96774193548387
    ), temp = c(42.0967741935484, 45.1612903225806, 47.3461538461538,
    39.8333333333333, 33.2903225806452, 32.258064516129, 31.1612903225806,
    27.5483870967742, 31.0645161290323, 33.8387096774194)), row.names = c(NA,
    10L), class = "data.frame"), structure(list(date = structure(c(14613,
    14614, 14615, 14616, 14617, 14618, 14619, 14620, 14621, 14622
    ), class = "Date"), wind = c(3.2258064516129, 4.19230769230769,
    8.08333333333333, 8.7741935483871, 9.70967741935484, 12.4193548387097,
    1.29032258064516, 2.25806451612903, 4.96774193548387, 4.12903225806452
    ), temp = c(45.1612903225806, 47.3461538461538, 39.8333333333333,
    33.2903225806452, 32.258064516129, 31.1612903225806, 27.5483870967742,
    31.0645161290323, 33.8387096774194, 40.7096774193548)), row.names = c(NA,
    10L), class = "data.frame")))

EDIT:
I liked both solutions by @tmfmnk and @akrun.
(Some reasoning - mostly for me for coming back to this question at a later date)
On my full sample, I obtain the error Error: Argument 2 must be length 2995920, not 2998110. When I apply:
map2_dfr(map(df1, ~ bind_rows(.) %>%
              pivot_longer(everything(), values_to = "prediction") %>%
              select(-name)),
         map(df2, bind_rows),
         bind_cols, .id = "ID")

I narrowed the error down to the fact that:
map(df1, ~bind_rows(.) %>%
      pivot_longer(everything(), values_to = "prediction") %>%
      select(-name))

Creates 2 lists consisting of 2995920 observations. I also run separately;
map(processed_analysis, ~bind_rows(.))

Which creates 2 lists consisting of 2998110. The difference of these two figures is 2190 (which I understand makes sense only to me but its significant since 2190 is the length of one of the list of lists or number of observations of one of the list of lists).
2998110 / 2190 = 1369 where the 1369 is the number of list of lists I have in each of the lists (5 and 6) in this example.
@akrun's solution:
imap_dfr(df2, ~ bind_rows(.x) %>%
        mutate(ID = .y)) %>%
    mutate(prediction = unlist(df1)) %>%
    as_tibble

Gives me a data frame consisting of 5996220 observations. Which is the same as 2998110 + 2998110 or the number of observations each list 5 or 6 contains when the 1369 list of lists have been rbind'd.
The difference between @akrun solution of 2998110 and @tmfmnk solution of 2995920 is 2190 which is exactly the length of the number of rows of one of the 1369 list of lists for 5 and 6.
2998110 / 1369 = 2190 which is correct whereas 2995920 / 1369 = 2188..44 Which doesn't align with the data.
I do not understand why the two solutions seem to work perfectly on the data provided here and slightly differently on the full data I have.

A: One option could be:
map2_dfr(map(df1, ~ unlist(.) %>%
              enframe(value = "prediction") %>%
              select(-name)),
         map(df2, bind_rows),
         bind_cols, .id = "ID")

   ID    prediction date        wind  temp
   <chr>      <dbl> <date>     <dbl> <dbl>
 1 5         -0.836 2010-01-01 19.7   41.6
 2 5          0.779 2010-01-02  3.19  42.0
 3 5          1.24  2010-01-03  1.39  42.1
 4 5          1.06  2010-01-04  3.23  45.2
 5 5          0.735 2010-01-05  4.19  47.3
 6 5         -0.198 2010-01-06  8.08  39.8
 7 5          0.169 2010-01-07  8.77  33.3
 8 5         -0.428 2010-01-08  9.71  32.3
 9 5         -0.551 2010-01-09 12.4   31.2
10 5          1.04  2010-01-10  1.29  27.5
# … with 70 more rows

A: Here is another option with imap.  As the list elements are of the same number of rows, it would be easier to unlist the first dataset and create a column 'prediction' after we bind the rows of the 'df2'
library(purrr)
library(dplyr)
imap_dfr(df2, ~ bind_rows(.x) %>%
        mutate(ID = .y)) %>%
    mutate(prediction = unlist(df1)) %>%
    as_tibble
# A tibble: 80 x 5
#   date        wind  temp ID    prediction
#  <date>     <dbl> <dbl> <chr>      <dbl>
# 1 2010-01-01 19.7   41.6 5         -0.836
# 2 2010-01-02  3.19  42.0 5          0.779
# 3 2010-01-03  1.39  42.1 5          1.24
# 4 2010-01-04  3.23  45.2 5          1.06
# 5 2010-01-05  4.19  47.3 5          0.735
# 6 2010-01-06  8.08  39.8 5         -0.198
# 7 2010-01-07  8.77  33.3 5          0.169
# 8 2010-01-08  9.71  32.3 5         -0.428
# 9 2010-01-09 12.4   31.2 5         -0.551
#10 2010-01-10  1.29  27.5 5          1.04
# … with 70 more rows

Or with base R, we can use Map with lapply
lst1 <- lapply(df2, do.call, what = rbind)
transform(do.call(rbind, c(Map(cbind, lst1, ID = names(lst1)),
  make.row.names = FALSE)), prediction = unlist(df1, use.names = FALSE))
#         date      wind     temp ID  prediction
#1  2010-01-01 19.720000 41.60000  5 -0.83573985
#2  2010-01-02  3.193548 41.96774  5  0.77935350
#3  2010-01-03  1.387097 42.09677  5  1.24250948
#4  2010-01-04  3.225806 45.16129  5  1.05645013
#5  2010-01-05  4.192308 47.34615  5  0.73512155
#6  2010-01-06  8.083333 39.83333  5 -0.19768077
#...


text:
Q: Difference between the pairings $\text{Tr}(xy)$ and $\text{Tr}(x^t y)$ Let $\mathfrak{g}$ be the tangent space to $GL_n(\mathbb{C})$ at the identity.
What is the difference between the two maps? Any subtle geometric or algebraic difference between the two pairings
$$
\mathfrak{g}\times \mathfrak{g}\rightarrow \mathbb{C}, \hspace{4mm} (x,y)\mapsto \text{Tr}(xy)
$$
versus
$$
\mathfrak{g}\times \mathfrak{g}\rightarrow \mathbb{C}, \hspace{4mm} (x,y)\mapsto \text{Tr}(x^t y),
$$
where $x^t$ denotes the transpose of $x$ and $\text{Tr}(x)$ denotes the trace of the matrix $x$?

A: Probably the most important difference is that the first one is invariant under conjugation by an arbitrary matrix $P$, while the second is only invariant by conjugation under orthogonal maps $P^t P = I$.


text:
Q: Mount a CIFS client/connection with sys/mount I am trying to make a CIFS connection between my Ubuntu client desktop and my Windows 10 server Desktop, so I can share folders and files though a local network.
My code is the following:
#include <sys/mount.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <string>

using namespace std;

int main()
{
  string src = "//xxx.xxx.x.xxx/shared_folder"; //xxx.xxx.x.xxx should be replaced by the server IP. shared_folder is my folder shared on the server side
  string dst = "/opt/share";//My shared folder on Linux
  string fstype = "cifs";

  printf("src: %s\n", src.c_str());

  if( -1 == mount(src.c_str(), dst.c_str(), fstype.c_str(), MS_MGC_VAL | MS_SILENT , "username=myemail@hotmail.com,password=mypassword") )
  {
      printf("mount failed with error: %s\n",strerror(errno));
  }
  else
      printf("mount success!\n");
  return 0;
}

But it always returns:
src: //xxx.xxx.x.xxx/shared_folder
mount failed with error: Operation not permitted
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-fmryivr5.02p" 1>"/tmp/Microsoft-MIEngine-Out-zfdhv3x2.zc5"

Any clue, please?


text:
Q: Core Data Relationships Binding in IB I have a simple program that stores purchase information in a core data store. The model is similar to the following.
Entities:
Student(lastName,firstName) relationship to (BoughtPackage)
BoughtPackage relationship to (Payment) and (Package)
Payment(type,amount)
Package(name,price)
Structure looks like

I would like to first display the list of students in a table, then format the purchases made my that individual student in a details table.
So far, I have been able to create an NSArrayController to hold the data of the Student entity, but cannot figure out how to propagate the purchase detail table. How would I accomplish this using IB alone, or is it possible? If so, how would I do it programmatically?

A: Yes it is possible to do this mostly in IB without writing any code. But thats too broad a question for a SO answer
You really need to read
https://developer.apple.com/library/mac/#documentation/cocoa/conceptual/cocoabindings/cocoabindings.html
and theres a tutorial in the docset titled

Introduction to Developing Cocoa Applications Using Bindings: A
  Tutorial

which i can't find a web link for. Just search the title.
But sort out your model too. It looks like all your relationships are one-to-one
For example. I would expect that a Student may have many BoughtPackages hence a one-to-many relationship there and the same with BoughtPackage to Payment.
Good luck


text:
Q: BNG Locator ArcGIS does not work I am trying to use the bng locator in ArcGIS Desktop. Unfortunately, I am not very successful. I follow following steps:
ArcGIS Desktop - ArcMap

*

*Open the Catalog window

*Expand the GIS Servers Folder and select Add ArcGIS Server

*In the wizard, choose Use GIS Services

*Click Next

*Enter https://datahub.esriuk.com/arcgis/services or http://datahub.esriuk.com/arcgis/services (no authentication details are required)

*Click Finish

*Select the new server and choose a locator from the list.

I can add the server to ArcCatalog and I can see it in the Address Locator list. Unfortunately, after entering for example: SE338191 I get information that no address has been found.
What am I doing wrong?


text:
Q: Deleting an Object in c++ implies deletion of its members? I am quite new to c++ and I have a question.
If I have a class containing a (pointer to a) vector:
class myClass {
public:
    int* direction;
    myClass(int d){direction=new int[d];}
}

When I create an object and delete it in the main:
int main(){
    int d;
    myClass* myvec;
    myvec = new myClass(d);
    delete myvec;
}

Also the destructor for myvec->direction has been coherently called and the memory freed? Or do I have to write an apposite method for that?
I hope the question is clear...

A: If you've allocated memory with new you need to delete it too, like this:
class myClass {
      int* direction;
public:
      myClass(int d) : direction(new int[d]) {}
      ~myClass() {
          delete[] direction;
      }
}

But you'd also need to write a copy constructor and copy assignment operator, and in C++11 and later also a move constructor and move assignment operator, for this to be working good. Otherwise, you'd risk the default versions of those copying the raw pointer when you use instances of this class.
Take a look at the rule of three/five/zero.
You'd be much better off using a std::vector<int> instead of a raw pointer.


text:
Q: Cron job failing - wrong PHP version? Works on local WAMP
php artisan schedule:run works as expected on my local WAMP.
Error: When running on web hosted server
When I run php artisan schedule:run on my webhosting server it crashes. Error log:

Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/sites/p/mysite.com/delayed/artisan on line 30

What I think it is: PHP version issue
Believe it is a php version error issue (cron job on hosted server is 5.3 and L5 requires 5.5.9...)
http://laravel.io/forum/06-10-2015-laravel-5-error-on-installation
Simple fix does not work
I implemented the solution to add #!/usr/bin/php-5.6/php-cli at the top of my artisan file in accordance with http://laravel.io/forum/03-03-2015-console-command-fails-when-executed-by-cpanel
But it does not 'bite', when runnning php-5.6 artisan schedule:run on the shell it generates

Running scheduled command: 'usr/local/bin/php' 'artisan' download:delays > 'var/sites/p/mysite.com/delayed/storage/logs/cron.log' 2>&1

That means it will fire the 'standard' php, which unfortunately for my web provider is 5.3 on cronjobs..
QUESTION: HOW DO I GET CRON JOB TO FIRE PHP 5.6?
Any ideas on how to get the artisan to fire php5.6 rather than server default?

A: The answer is to apply -cli at the end of the php for the cron job.
Changed:
/usr/bin/php-5.6 /var/sites/p/mysite.com/delayed/artisan schedule:run
to:
/usr/bin/php-5.6-cli /var/sites/p/mysite.com/delayed/artisan schedule:run
Thanks Mr Llama and Bogdan for sending me in the right direction!
Hope this helps someone else with a similar problem in the future.


text:
Q: Heroku CLI "No command specified for process type web" when releasing container I am deploying a .Net Core application using Docker Containers.
I was able to push the image successfully using heroku container:push web
But calling heroku container:release web returns No command specified for process type web.
I'm a bit stumped I've tried adding heroku.yml
setup:
  addons:
    - plan: heroku-postgresql
      as: DATABASE
build:
  docker:
    web: Dockerfile
  config:
    ASPNETCORE_ENVIRONMENT: development
run:
  web: dotnet Api.dll

On the root directory but still no luck.
I can confirm that the image was created I'm seeing this in docker
REPOSITORY                                     TAG                 IMAGE ID            CREATED             SIZE
registry.heroku.com/immense-temple-11020/web   latest              5cb62a9af317        16 minutes ago      272MB

If anyone could point me to the right direction, it would be much appreciated. Thanks!

A: Did you have a CMD directive specified at the end of your Dockerfile? If not, that was likely causing the problem, which you then worked around by using heroku.yml and heroku stack:set container.
Heroku is unclear on this in their documentation. I was able to get my container to run locally without a CMD directive, likely as you were. But if you read Heroku docs here or here you'll pick up that Heroku takes for granted that the Dockerfile will specify a CMD to run.
I had the same problem until I added the CMD directive at the end of my Dockerfile. I'm still working though what exactly I should put as my CMD directive but I no longer get the No command specified for process type web error.
Since you switched to using heroku.yml you were able to get around the CMD by using
run:
  web: dotnet Api.dll

Heroku docs say "If you don't include a run section, Heroku uses the CMD specified in the Dockerfile."

A: I figured out the reason after searching for hours.
Apparently if forgot to call
heroku stack:set container.
Now I'm able to deploy and release!


text:
Q: In Flex, what's the difference between 'creationComplete' and 'addedToStage'? I want to count (via google analytics) the times a pop-up is displayed to the user. Which event should I use to deduce that the pop-up is being displayed to the user?

A: If a new pop up is created every time you display one, it doesn't matter which one you use as both events will be fired upon creating. If you are reusing the same object, you should use addedToStage as creationComplete is dispatched only once per UIComponent.

*

*creationComplete is dispatched when the component, and all of its child components, and all of their children, and so on have been created, laid out, and are visible.

*addedToStage is dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained.

So if you are reusing the same object, you will get an addedToStage every time you display it.

A: Someone commented about not having to use both addedToStage and creationComplete (I needed 50 rep to respond so making a new post)
Looks like there is a case where you need to use both.  For instance, when you need to update something every time a view is visited and the view is displayed on a state change.  The first time the view is seen, it is the creationComplete event which fires.  Using addedToStage at this point runs the risk of a child component being null.  Consecutive times that the view is displayed, it will not dispatch creationComplete, only addedToStage

A: From my own testing, it looks like using either would work. But it would be nice to know which is the more 'correct' one to use, and just what the difference is between the two.

A: The first addedToStage event occurs before creationComplete so if you need to access child components you'll need to use both.


text:
Q: Problem w/Apache2.2+psycopg2.2.2+mod_wsgi on Ubuntu So I'm having a problem similar to others I've seen people complain about on Windows, but it appears theirs is a Windows only problem being fixed in a new version of psycopg2.
Basically, I am trying access my deployed application only to get the following in the logs.
[Fri Feb 25 16:29:26 2011] [error] [client 5.7.0.205] TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.postgresql_psycopg2' isn't an available database backend.
[Fri Feb 25 16:29:26 2011] [error] [client 5.7.0.205] Try using django.db.backends.XXX, where XXX is one of:
[Fri Feb 25 16:29:26 2011] [error] [client 5.7.0.205]     'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
[Fri Feb 25 16:29:26 2011] [error] [client 5.7.0.205] Error was: cannot import name utils

I seem to have everything properly install, using buildout to retrieve dependencies and such.  I was also able to successfully run syncdb against my database and see the tables get created.
Why is it having problems dealing with the fact that I have configured it to use postgresql_psycopg2?  It doesn't even make it to doing anything special.  I can request "myserver/" or "myserver/admin" or "myserver/whothehellcares" and I constantly get the same 500 error.
As far as Apache goes, I used the basic site already configured and simply added the one line WSGIScriptAlias pointing to my wsgi file.  I've even tried using WSGIDaemonProcess to target a specific user (www-data) for running the processes but that didn't have any effect.
Any thoughts or help is appreciated.

A: On non Windows systems, can be a 32 vs 64 bit problem.
Create a WSGI hello world script as described in:
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
Once you have the hello world script working, add at the start of it imports for the psycopg2 module you wish to use and validate that it can be imported. Ensure the import you use forces the import of the C extension .so for the pyscopy2 client module.
If it fails you may get a better error in the Apache error logs. Django can sometimes mask the real error.


text:
Q: check max characters in textbox I have textboxes where i only want signed a max number of characters in. an then I'll hear how i could check it easily in c#

A: Just set the MaxLength property of the textbox.

A: You can set the MaxLength Property of the textbox as you want.
E.g: if you want MaxLength as 10. give MaxLength - 10

A: TextBox.MaxLength maybe?

A: Alternatively you could add a jQuery plugin


text:
Q: Android: Programmatically triggering phone checkin From within my Android application, I need to make the phone 'checkin' with Google for Market updates.  This can be done manually by the user by opening the dialer and typing '*#*#CHECKIN#*#*'.  My app needs the ability to do the same thing.
I'm positive this done using an Intent.  Some digging shows that the Alarm Manager has this pending intent waiting:
  RTC_WAKEUP #5: Alarm{44b1ee18 type 0 com.google.android.server.checkin}
    type=0 when=1277981220358 repeatInterval=40212000 count=0
    operation=PendingIntent{44b256c0: PendingIntentRecord{44c26a80 com.google.android.server.checkin broadcastIntent}}

Now the question is, how do I get my app to broadcast this same type of Intent?  I tried this.sendBroadcast(myIntent) in the activity with no luck, so I'm rather stumped at the moment.
Any thoughts?

A: collinodell,
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:*%23*%232432546%23*%23*")));

I got it today by hex encoding the #, and calling the dialer. Root66 gave me the tip
jcase

A: You shouldn't rely on this functionality. This is an undocumented API, and it's undocumented for a reason.
This can (and likely will) change in future releases of the Android Market app. Since your application is relying on this functionality, this means your application will break.


text:
Q: How to get the font style of a blank cell of excel in Java, Apache POI? I would like to capture the font (include font-size, font-family,  font-color, font-weight, etc.) of a blank cell in excel with Java.
  In other words, the blank cell has a certain font format (Not default font format), and i want setCellValue(theblankcell) without font format been changed.
  Because the cell is a blank cell, when i use getCellSytle(), it throws java.lang.NullPointerException runtime exception.
  I am using Apache POI 3.14. How can I do?
  Here is my code:
    Sheet sheet1 = wb.getSheet("Sheet1");
    CellStyle cellstyle = sheet1.getRow(2).getCell(0).getCellStyle();
    Cell cell = null;
    if (sheet1.getRow(2) != null){
        Row row = sheet1.getRow(2);
        if (row.getCell(0) != null) {
            cell = row.getCell(0);
        }
        else {
            cell = row.createCell(0);
        }
    }
    else{
        Row row = sheet1.createRow(2);
        if (row.getCell(0) != null) {
            cell = row.getCell(0);
        }
        else {
            cell = row.createCell(0);
        }
    }
    cell.setCellValue("test");
    cell.setCellStyle(cellstyle);


text:
Q: Import CSV Line Break Woes I'm using a BASH script to run a LOAD DATA INFILE to MySQL.  My issue is trying to terminate a line correctly. After running my script I notice every other line is skipped. Here's some example data:
CSV File Reads:
"COMP","POL","STATUS","TYPE","CODE","MODE","NUMBER"
"220","1243918,"TGI","NA","AS-T5","M6","793930""
"220","1653912,"TGS","NA","NON","M6","793975""
"220","1471618,"TGS","NA","AS-T6","M6","793915""

Here's my BASH SCRIPT to Import CSV FILE:
mysql -u$User -p$Pass -D$Db<<EOFMYSQL
LOAD DATA INFILE '$InputFile' INTO TABLE $Table
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(comp,pol,status,type,code,mode,number);
EOFMYSQL

But here's what my rows looks like in my database:
220  1243918  TGI  NA  AS-T5  M6 793930""220
220  1471618  TGS  NA  AS-T6  M6 793915""220

Notice the last field NUMBER in the database has two sets of quotes and the first field of the next row in the CSV file. The 2nd row is skipped.
I have tried many different LINES TERMINATED BY options but just can't figure out how to designate the line break correctly?!
Any suggestions would be greatly appreciated!
Basher

A: You can check if your file has weird Windowsy carriage returns in it by running:
cat -vet yourfile

and looking for "^M"
You can remove them by doing
tr -d '\r' < WindowsFile > UnixFile

or by using "dos2unix"
EDITED
From your comments, you appear to have two sets of adjacent double quotes at the end of the lines - is that correct? If so, you can replace two lots of quotes at the end of the line with a single set using this:
sed 's/""$/"/' YourFile > NewFile


text:
Q: Autofac and Nancy The following program using Autofac in conjunction with Nancy does not launch the default Nancy server correctly.
using Autofac;
using Nancy.Hosting.Self;
using System;

namespace NancyExample
{
    class Program
    {
        static void Main(string[] args)
        {
            var builder = new ContainerBuilder();
            builder.Register(c => new NancyHost(new Uri("http://localhost:8080"))).SingleInstance();

            using (var container = builder.Build())
            {
                NancyHost host = container.Resolve<NancyHost>();

                // this fails with:
                // Exception thrown: 'System.Net.HttpListenerException' in System.dll
                // Exception thrown: 'System.Net.HttpListenerException' in System.dll
                // Exception thrown: 'System.InvalidOperationException' in System.dll
                // Exception thrown: 'System.InvalidOperationException' in System.dll

                // this works:
                // NancyHost host = new NancyHost(new Uri("http://localhost:8080"));

                host.Start();
            }

            Console.ReadLine();
        }
    }
}

When resolving NancyHost via Autofac, it appears that an error comes deep within .NET's HttpListener. There doesn't seem to be good details on this exception. Visiting http://localhost:8080 results in no connection.
Instantiating NancyHost myself works fine.
Using:

*

*Autofac 4.3

*Nancy 1.4.3

*Nancy.Hosting.Self 1.4.1

A: Because your code "is waiting" on Console.ReadLine(); and it is outside the using, the Autofac container is already disposed . Move Console.ReadLine(); inside using to make it work.


text:
Q: Closing parenthesis as delimiter not matched when breaklines=true I want code in parentheses and in brackets to appear in different colors. In the following document, the words brackets again appear in green as intended, and outside again is black as intended, but stretches into the margin of the page.
If I uncomment the line ,breaklines=true, the line is broken between brackets and again, however, these words and the following are red, i.e. as if a (-)-delimited section was detected but then the closing ) was ignored.
What is going on here?
Addition: The problem occurs also if there is no line break present, e.g. if I shorten all words in the text to their first letter. The problem goes away in any case if I pick any other kind of delimiter instead of (), e.g. {}.
\documentclass{article}
\usepackage{color}
\usepackage{listings}

\lstdefinelanguage{new}{
    moredelim=*[s][\color{red}]{(}{)},
    moredelim=*[s][\color{green}]{[}{]},
  }
\lstset{
  language=new
  %,breaklines=true
  }

\begin{document}

\begin{figure}
\begin{lstlisting}
outside(in paren) [in brackets (paren+brackets) brackets again] outside again
\end{lstlisting}
\end{figure}

\end{document}

A: You might have come across a bug arising from the special treatment of the right parenthesis by the line-breaking algorithm of the listings package. In fact, when the SelectCharTable hook used by the listings package is executed and line breaking is enabled ) is defined as a macro, namely by
\lst@Def{`)}{\lst@breakProcessOther)}

where
\lst@Def=macro:
#1->\lccode `\~=#1\lowercase {\def ~}.

Unfortunately, this means that ) is not recognized as a delimiter any more, which eventually leads to your observation.
I've put some effort in finding a fix for this bug, but haven't succeeded so far. (My TeX programming skills are still limited.) So, the only thing I can provide right now is a workaround in the form of a patch that simply cancels the special treatment of ) by the line-breaking algorithm:
\documentclass{article}

\usepackage{color}

\usepackage{listings}

\lstdefinelanguage{new}{
  moredelim=*[s][\color{red}]{(}{)},
  moredelim=*[s][\color{green}]{[}{]},
}

\lstset{
  language=new,
  breaklines=true
}

\usepackage{etoolbox}

\makeatletter

\patchcmd{\lsthk@SelectCharTable}{%
  \lst@ifbreaklines\lst@Def{`)}{\lst@breakProcessOther)}\fi
}{%
}{
}{
}

\makeatother

\begin{document}

\begin{lstlisting}
outside (in paren) [in brackets (paren+brackets) brackets again] outside again
\end{lstlisting}

\end{document}

The resulting output is:

A: A simple workaround would be, instead of using closing parenthesis ')', one can use another character e.g ']' and replace it with closing parenthesis ')'.
\begin{lstlisting[literate={(}{{\textbf{(}}}1
                           {]}{{\textbf{)}}}1]
(In text I'm closing using]
\end{lstlisting}


text:
Q: how to get checkout cart specific item totat price? I have a custom html I want to implement this html into checkout cart page . I have implement it but i cant get cart item total price , eg. I have 5 item in cart . I have updated only one specific item in the cart then I don't get these specific item total price .
default item $50 *1 =$50
After Update quantity
item price : $50 * 2 = ??(I want to get total of this specific item ).
Thanks

A: You can calculate the price as:
<?php
    $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
    foreach($items as $item) {
       $qty = $item->getQty();
       $price = $item->getPrice();
       $totalPrice =  $qty * $price;
    }
?>

A: To get cart item specific details, you can use :
$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllItems() as $item){
   $qty = $item->getQty() ;
   $price = $item->getPrice();
   $totalPrice =  $qty * $price;
}

A: i am using default magento functionality to get specific item price in magento chekout cart page
<?php if ($canApplyMsrp): ?>
    --
<?php else: ?>
    <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
        <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition()); ?>
    <?php else: ?>
        <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()) ?>
    <?php endif; ?>
<?php endif; ?>


text:
Q: Move an element up in the list using Comparator I have an ArrayList in Java :

{"PatMic", "PatientDoc", "Phram", "Patnet", "PatientA"}

All the elements have a number assigned : PatMic = 20, PatientDoc = 30, Phram = 40, Patnet = 50, PatientA = 60.
And my current Comparator :
Comparator<String> comparator = new Comparator<String>() {

    @Override
    public int compare(final String o1, final String o2) {
        final int numbr1 = getElementNumber(); //Returns element's number in a list
        final int numbr2 = getElementNumber();
        if (numbr1 > numbr2 ) {
            return 1;
        } else if (numbr1 < numbr2 ) {
            return -1;
          }
            return 0;
    }
};
Collections.sort(strings, comparator);

I do not want to change the assigned numbers to each element but would want to move the element PatientA in between PatMic and PatientDoc so the modified list should look like :

{"PatMic", "PatientA" "PatientDoc", "Phram", "Patnet"}

Could someone please suggest how to achieve this? I tried many ways to modify the existing Comparator logic but in vain. Thank you.

A: You are trying to sort based on some inherent value associated with a String. Therefore, sorting on a String itself is probably not correct. What you probably want to use is either a custom object (implement equals, hashCode and the interface Comparable), or an enum type. This will allow you to change the internal state of these objects explicitly, which will manifest itself naturally when using a Comparator. For example, using a class:
class MyClass implements Comparable
{
    private String name;
    private int value;

    //Constructor
    public MyClass(String s, int v)
    {
        name = s;
        value = v;
    }

    //Getters and setters

    //Implement comparing method
}

Then you can use these objects in place of your Strings:
//...
MyClass patMic = new MyClass("PatMic", 20);
// So on..

A: First, you should give you comparator sufficient knowledge about what it should do. I mean you should have some data available to comparator that says something like "okay, sort them all by associated number except this one - place it right here". "Right here" could be anything that points exact position, I gonna choose "before that element".
So here we go
public void sortWithException(List<String> data, final Map<String, Integer> numbers, final String element, final String next) {
    Collections.sort(data, new Comparator<String>() {
        @Override
        public int compare(String first, String second) {
            if (first.equals(element) || second.equals(element)) { //the exception
                Integer nextNumber = numbers.get(next);
                Integer firstNumber = numbers.get(first);
                Integer secondNumber = numbers.get(second);
                if (first.equals(element)) {
                    if (next == null) // placing the exception after ANY element
                        return 1;
                    return secondNumber >= nextNumber ? -1 : 1; //placing the element before next and after all next's predecessors
                } else { // second.equals(element)
                    if (next == null)
                        return -1;
                    return firstNumber >= nextNumber ? 1 : -1;
                }
            } else { //normal sort
                return numbers.get(first) - numbers.get(second);
            }
        }
    });
}

and call it like sortWithException(data, numbers, "PatientA", "PatientDoc")
Note that i used Map for associated numbers, you should probably use your own method to get those numbers.


text:
Q: Conditional "Or" Statements in MATLAB I am under the impression that || is the "or" statement in MATLAB. Perhaps someone can explain the confusing behaviour I am seeing:
a = 2;

a == 2        %returns ans = 1 (true)

a == 2 || 3   %returns ans = 1 (true)

a == 3 || 4   %returns ans = 1 (true)??!!

What am I missing here? 'a' is neither 3 or 4, so shouldn't
a == 3 || 4

return ans = 0 (false)?

A: The expression
a == 3 || 4

is evaluated that way :
a == 3     => false
then
false || 4 => true

if you want to check whether a is equal to 3 or 4 you should write
(a == 3) || (a == 4)

which is evaluated that way
a == 3         => false
then
a == 4         => false
then
false || false => false

A: Thomas's answer is an excellent explanation of what's going on here; another way that you can compare a variable to multiple answers is using the any() function.
solutions = [3 4];
any(a==solutions);

The a==solutions line creates a matrix the same size as solutions, which contains 1's in indecies which where the conditional is true, and 0's where it is false.
A few more examples:
any(isprime([17:24])); %returns true; 17, 19 and 23 are prime
any(isinteger(sqrt([17:24]))); %(test for square number) returns false; no square numbers in this range
any(mod(magic(3)(:),6)==3); %returns true; 9 mod 6 == 3. Note (:) inserted so that any is evaluated against all entries of the square matrix created by magic

A:
a == 3 || 4   %returns ans = 1 (true)??!!

The reason for the above behaviour is due to the fact that any real number other than '0' in MATLAB is always evaluated to true.
So what is happening here is

*

*The expression a == 3 is evaluated first and found to be false.

*Next, expression false || 4 is evaluated.

*Since '4' is a real number other than zero, the resulting expression is false || true which is evaluated to true.

To get a desire result use (a == 3) || (a == 4) which is evaluated as false || false which returns false.


text:
Q: Elastic collision with one moving object hitting a stationary object In an elastic collision, I understand that momentum is conserved and kinetic energy is conserved. If billiard ball of silver (with velocity $v_{(Ag)}$ impacts a stationary billiard ball of aluminum, I am trying to calculate the velocity of the aluminum ball after the collision, $v_{(Al)}$. After an elastic collision, the impactor is at rest and the impactee has the motion.
Using momentum, $= m \cdot v$
$$m_{(Ag)} \cdot v_{(Ag)} = m_{(Al)} \cdot v_{(Al)}$$
Assuming silver is 4x denser than aluminium, then using momentum, the aluminium ball should have velocity
$$v_{(Al)} = 4\cdot v_{(Ag)}$$
But if we use kinetic energy, $1/2 m \cdot v^2$
$$\frac12m_{(Ag)}\cdot v_{(ag)}^2=\frac12m_{(Al)}\cdot v_{(Al)}^2$$
$$v_{(Al)}^2=\frac{m_{(Ag)}}{m_{(Al)}}\cdot v_{(Ag)}^2$$
$$v_{(Al)}=\left(\frac{m_{(Ag)}}{m_{(Al)}}\right)^{\frac12}\cdot v_{(Ag)}$$
$$v_{(Al)}=2\cdot v_{(Ag)}$$
Somewhere I have lost some neuron connections in my brain because I cannot resolve this conflict. This is a perfectly elastic collision so both momentum and kinetic energy should be conserved.

I have read multiple threads including:
When is energy conserved in a collision and not momentum?
How to calculate velocities after collision?
How can I calculate the final velocities of two spheres after an elastic collision?
Calculating new velocities of $n$-dimensional particles after collision
Velocities in an elastic collision
Summation of the velocities before and after an elastic collision

A: If the objects have different masses, then there isn't a way to start the collision with object 1 moving and object 2 at rest and then end the collision with object 1 at rest and object 2 moving while also having the collision be elastic. You have over-constrained your system, and so you will find contradictions like the one you found here.
Using the equations from this answer in one of your linked questions, if we are setting $v_{A,f}=v_{B,i}=0$, then we end up with the system of equations
$$0 = \dfrac{m_A - m_B}{m_A+m_B} v_{A,i}$$
$$v_{B,f} = \dfrac{2m_A}{m_A+m_B} v_{A,i}$$
Which you can see is only consistent if $v_{A,i}=v_{B,f}=0$ for $m_A\neq m_B$ (which is the case of no collision), or if $m_A=m_B$.

A: If a small mass collides elastically with a larger one which was at rest, the smaller one will bounce back, not stop.

A: You say...
 After an elastic collision, the impactor is at rest and the impactee has the motion.

That is only true if the masses of the two balls are equal. Clearly they will not be equal if one is made of silver and the other aluminium.


text:
Q: How to use the local variable of one class in another class? I want to use the variable data's value from the following method in another class and this method handles the run button in one window and the other class handles the buttons which are located in another window.  I have tried a few ways to do that but none of them worked, so I would be grateful if anyone could help me with it.
public class Test{

@FXML
private TextField sqlTextField;
@FXML
private TableView table;
@FXML
private Button save;
@FXML
private Button run;
@FXML
private Button delete;

public ObservableList<ObservableList> data = FXCollections.observableArrayList();

 public void handleRunButton() throws SQLException {

        run.setDisable(true);
    try {
        ConnectionClass connectionClass = new ConnectionClass();
        Connection connection = connectionClass.getConnection();
        String sql = sqlTextField.getText() + ";";
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);

        for (int i = 0; i < resultSet.getMetaData().getColumnCount(); i++) {
            final int j = i;
            TableColumn col = new TableColumn(resultSet.getMetaData().getColumnName(i + 1));
            col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ObservableList, String>, ObservableValue<String>>() {
                public ObservableValue<String> call(TableColumn.CellDataFeatures<ObservableList, String> param) {
                    return new SimpleStringProperty(param.getValue().get(j).toString());
                }
            });

            table.getColumns().addAll(col);
            System.out.println("Column [" + i + "] ");
        }

        /********************************
         * Data added to ObservableList *
         ********************************/
        while (resultSet.next()) {
            //Iterate Row
            ObservableList<String> row = FXCollections.observableArrayList();
            for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
                row.add(resultSet.getString(i));
            }
            data.add(row);
            System.out.println("Row [1] added " + row);
        }
        System.out.println(data);
        //FINALLY ADDED TO TableView
        table.setItems(data);

        System.out.println("data =" + data);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Error on Building Data");
    }
    ObservableList tableText = table.getItems();
    System.out.println("tableText=" + tableText);
    boolean disableButton2;
    if (tableText.size() > 0) {
        disableButton2 = false;
    } else {
        disableButton2 = true;
    }
    save.setDisable(disableButton2);
    System.out.println(disableButton2);
    delete.setDisable(disableButton2);
    System.out.println("data==>" + data);
}


text:
Q: Oracle Apex 4.2 interactive report with lookup tables I have created a table Called  NAMES inside that I have a column called Status.
On STATUS, I created a lookup table  and this created a new table called Status_lookup Which has 2 column  (STATUS_ID and Status)
So the NAMES table column changed to STATUS_ID
when I do interactive reports, the data do come through from STATUS_ID which is number, I need the text that is stored in the Status.
Could some please explain how I do this. This I thought would be pretty easy but I can't see how to do it.
I am not Newbie to Oracle applications so a step by step would be helpful

A: Example: select * from emp
I want DEPTNO to display the DNAME which can be found in DEPT
What I usually do is:
Go to "Shared Components > Lists of Values", and create a new one from scratch, type dynamic.
I'm calling my LOV "DEPARTMENTS", and it has this SQL:
select dname d, deptno r
from   dept
order by 1

To then map this to the column in the IR, go to the page with the IR and edit it. Go to the report attributes. From there you can see the columns in the IR and edit their attributes by clicking the pencil icon.

In the column attributes you can then change the display type of the column. Set it to "Display as Text (based on LOV, escape special characters)".
Then go to the "List of Values" section, and select the LOV from the "Named List of Values" select list. (In my example this is "DEPARTMENTS").
Apex will then map the values in the IR sql to that of the display value of the LOV.

Alternatively, you could of course also just change the SQL of the report to map a display value, for example:
SELECT empno, ename, depto, (select dname from dept where deptno  = e.deptno) dname
from emp


text:
Q: Java Entity Beans are not deleting rows from database; only from JTable I am using Entity bean in NetBeans, to develop some master/detail forms.  When I run the forms, I click the Delete JButton, and the row dissapears from the JTable.
But when I click on "Reload", the supposedly deleted row shows up again.  I don't know why is this happening; why does the Entity doesn't erase all the way to the database table, and just deletes it out of the JTable?

A: This sort of issue sounds like it's related to the separation of the data (the model) from the view. I don't have specific knowledge regarding your technologies used, but hopefully I can provide some insight into what is the root of your problem.
In your case, it sounds like when you "Delete" you're only removing it from the view; you're not actually manipulating the data in any way (i.e. the model is not aware of this deletion).
Therefore once you "Reload" - which usually means that the view asks the model for what data to present - your "deletion" is lost since the model hasn't changed at all, and thus provides the exact same data to the view.
This sort of behavior is likely to occur when you're manipulating the data (i.e. deleting things) via the JTree itself or even the contained TreeNode objects, rather than the underlying TreeModel.
Hopefully this information helps you, sorry I don't have a more specific answer.

A: The JTable when reloaded, brought the record deleted because it had a foreign key link and couldn't deleted it at database level.


text:
Q: `window` is not defined - Angular CLI I need to use the global window object in an Angular 2 module, but the server side rendering done by Angular CLI means that window is undefined when the module is being processed.
How do I ensure that this particular module is processed on the client side, when window is available?
Thanks

A: Please check if $window resolves the issue, it's a reference to the global window object - here is the doc link.


text:
Q: Updating to Ember 3: Expecting 'CLOSE', got 'OPEN_BLOCK_PARAMS' Before upgrading Ember, the following code worked:
{{each invitation in model itemViewClass="invitation" itemController="invitation"}}

However, due to the Ember.JS changes, (see http://emberjs.com/deprecations/v1.x/#toc_code-in-code-syntax-for-code-each-code), I had to change it to:
{{each invitation itemViewClass="invitation" itemController="invitation" as |model|}}

Now I get the error:
"Expecting 'CLOSE', got 'OPEN_BLOCK_PARAMS'"

A: I'm guessing you are upgrading to 2.0 and itemController and itemViewClass were deprecated in 1.13.  That being said, the each helper in a non-block form without those two properties likely wouldn't be useful, so likely doesn't support non-block anymore.
http://emberjs.com/blog/2015/06/12/ember-1-13-0-released.html#toc_notable-deprecations-in-1-13
You'll want to convert the itemController and itemViewClass into a component and use a block each
{{#each model as |invitation|}}
   {{invitation-thingy invitation=invitation}}
{{/each}}


text:
Q: Android How to judge the performance of CPU ? Our game needs to konw the performance of an android phone,and I collect some useful performance parameters. e.g. memerory,cpu core numbers,cpu max frequency.
Howerver, these parameters can not represent the CPU performance fully.  I found some questions talk about this just in general terms and didn't go into details.
Here are 2 links related to the topic  How to detect android cpu speed?   (To be honest ,I do not Know how SystemClock.uptimeMillis() can test the cpu )& How to check if device is *fast* enough
Is there any parameter can represent how fast is the device  exactly?
Any link to documentations on this will be highly appreciated.

A: I find a simple way. https://developer.android.com/reference/android/os/Build.html#SUPPORTED_ABIS
Besides what I described in the topic, we can get CPU architecture as a supplement.
String abi = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    abi = Build.CPU_ABI;
} else {
    abi = Build.SUPPORTED_ABIS[0];
}

arm64-v8a means high quality cpu so far,thus according to the value of abi,we can get another cpu performance parameter.


text:
Q: Assuming literally no other traffic, is channel 1 or 11 better for 2.4 GHz Wi-Fi networks? I've been reading a lot about channels lately. I understand everything about congestion and wanting to use the channels that have the least traffic. I get it. One thing I'm trying to grok is this -- assuming there is literally no other Wi-Fi network anywhere near you (which is unrealistic most of the time), what are the pros/cons of channels 1 and 11?
I pick 1 and 11 as they're the lowest and highest frequency. Not because they're non-overlapping like 1, 6, and 11 are (remember, we're in a desert of Wi-Fi signals, we don't care about "overlapping"). I pick them because they're the highest/lowest.
My naive guess is that it is somewhat like switching from 2.4 GHz to 5 GHz network, only much more minute. I would guess that channel 1 has more range indoors than channel 11 in the same way that 2.4 GHz has more range indoors than 5 GHz due to being a lower frequency and being better able to pierce walls. (In the same way lower frequency sounds can better pierce walls.)
My second guess, but I'm more unsure about this, is that channel 11 being at a higher frequency will allow faster speeds in the same way 5 GHz has faster speeds than 2.4 GHz. I'm more unsure about this though as I think the speed increase has more to do with the standard than the frequency.

Some background: I have seen (but not sure where) that channel 1 is "the best" assuming you're able to get it. I realize that's kind of a silly statement because 99% of the time the true answer is "it depends." I was thinking that lower channels were faster but then I realized that lower channels are lower frequencies and 5 GHz is faster and at a higher frequency. So when I began to really question why channel 1 is "the best" I realized that that's not necessarily true.

A: If an advantage to one or the other could be reliably empirically measured, I'm sure it would have been reported by now.
One thing I can definitely say is false is the notion that a higher frequency channel allows faster performance. It's the width of the channel that matters, not its center frequency. The 5GHz band is so much wider than the 2.4GHz band, that the 5GHz band allows for channels that are 2x, 4x, and 8x as wide as the 20MHz-wide channels you're stuck with in 2.4GHz.
If I had to speculate on which channel you're most likely to get the best rates at various ranges, I would guess channel 6. Because if you look at the internal power tables in the firmware/ROMs for Wi-Fi chipsets, you'll see that channel 6 is usually allowed to use a little bit more power than the band-edge channels of 1 and {either 11 or 13}. This is because the regulatory certification rules are strict about out-of-band emissions, so the band-edge channels, which are more likely to "leak" a little out of band, often have to have their power trimmed back a little to meet regulatory limits. I'm still not sure you'd be able to measure that difference in your own home.

A:
My naive guess is that it is somewhat like switching from 2.4 GHz to 5
GHz network, only much more minute. I would guess that channel 1 has
more range indoors than channel 11 in the same way .....

Actiontec article

In the U.S., the 2.4 GHz range is divided into 11 channels and you can
use any of these channels for your wireless network. Channel 1 uses
the lowest frequency band and each subsequent channel uses a slightly
higher frequency.

The difference in channel frequency is not all that great so that is not a large determining factor.
Here is a screen shot from Inssider Office showing a wide usage of channel numbers right near me. My routers use Channel 6.

A: In some countries, certain channels have higher power limits, so if you're devices are far from your own router, then it makes sense to use higher-power channels if the router and devices are capable of higher power.
As for interference, use an application such as Nirsoft's WiFi Info View to view currently active channels in your area, as shown below.


text:
Q: How to get the number/alphabet index pattern in an alphanumeric string in R? Say I have a string like this:
xyz45kpt793rsdwq1
I need to compute its equivalent alphabet & number sequence pattern like this as output:
3a2n3a3n5a1n
Where,
"a" represents alphabet
"n" represents number
and the numeric value tells the count of the continuous piece of either alphabets or numbers
Here is what I tried:
strsplit("xyz45kpt793rsdwq1", "(?=[A-Za-z])(?<=[0-9])|(?=[0-9])(?<=[A-Za-z])", perl=TRUE)

I get the output as:
[[1]]
[1] "xyz"   "45"    "kpt"   "793"   "rsdwq" "1"

Then I identified whether each of the above values is a set of alphabets or numbers by doing the following (for which I get output as FALSE if it's a set of numbers, and TRUE if it's a set of alphabets):
x <- strsplit("xyz45kpt793rsdwq1", "(?=[A-Za-z])(?<=[0-9])|(?=[0-9])(?<=[A-Za-z])", perl=TRUE)[[1]][2]
grepl("^[A-Za-z]+$", x, perl = T)

I did this for each of the 6 elements. Here I've shown the code for the 2nd element addressed as [[1]][2] as an example.
Next, I found the length of each of the above by nchar(x).
Now I can combine these to create the output 3a for the 1st element, 2n for the 2nd element and so on..
Eventually I can combine all of these to get the desired pattern output as 3a2n3a3n5a1n
But this approach I've tried seems a bit of an overkill and too lengthy. And it would get too complicated to do the same if I have an entire column of strings in a dataframe - for each of which I need to compute this pattern.
Can anyone help with a line of code which can do this in a much efficient manner?

A: You can use gsubfn here:
library(gsubfn)
x <- "xyz45kpt793rsdwq1"
gsubfn("(\\d+)|(\\p{L}+)", function(x,y) ifelse(nzchar(x), paste0(nchar(x),"n"), paste0(nchar(y),"a")), x, perl=TRUE)
# => [1] "3a2n3a3n5a1n"

The PCRE regex (the perl=TRUE enables the PCRE regex) - (\d+)|(\p{L}+) - matches and captures into Group 1 (x) any one or more digits, or captures any one or more letters into Group 2 (y). If Group 1 matches (nzchar(x)), the replacement is the length of the match (nchar(x)) and n. Else, Group 2 matched, and the replacement is the length of the group  + a.

A: A solution without using libraries. I don't think your approach is too lengthy, you could just take your existing logic and put it in a function and apply it to a data frame column:
x <- data.frame(strings = c("xyz45kpt793rsdwq1", "abs12345djf"), stringsAsFactors = FALSE)

my_fun <- function(strings) {
  matches <- sapply(strings, strsplit, "(?=[A-Za-z])(?<=[0-9])|(?=[0-9])(?<=[A-Za-z])", perl=TRUE)
  sapply(matches, function(x) {
    y <- ifelse(substr(x, 1, 1) %in% letters, paste0(nchar(x), "a"), paste0(nchar(x), "n"))
    paste(y, collapse = "")
  })
}

x$new_strings <- my_fun(x$strings)
x

Output:
            strings  new_strings
1 xyz45kpt793rsdwq1 3a2n3a3n5a1n
2       abs12345djf       3a5n3a


text:
Q: React environment variables working in development, not in deployment to netlify Everything works fine on my PC, but after I deploy to netlify, my environment variable is undefined.
This is what I have in the state.
let apikey;

if(process.env.NODE_ENV !== 'production') {
    apikey = process.env.REACT_APP_APIKEY;
    console.log(apikey);
} else {
    apikey = process.env.APIKEY;
    console.log(apikey);
}

Netlify settings
Yet still getting undefined :)
Console.log telling me the variable is undefined

A: In netlify you won't be able to access environment variables for the client unless you have built them into your scripts during a build. That is why you should not store secret keys in the builds of your client scripts.
There is no server side on Netlify, except when using functions. If you are using Netlify functions (lambda-functions) then there is not an issue accessing environment variables setup through the admin UI.

Only the build environment knows about and can use environment
  variables in most cases, since they are set in the shell during build,
  but your code is not served from the build environment - it is served
  without modification after build.

Store your REACT_APP_APIKEY in the Netlify build environment variables and build the .env using a script prior to running the build command.
scripts/create-env.js
const fs = require('fs')
fs.writeFileSync('./.env',`REACT_APP_APIKEY=${process.env.REACT_APP_APIKEY}`)

Run the script as part of your build
node ./scripts/create-env.js

A: Click to see image example
Just add your keys/variables manually here (i.e. the same ones in your .env file). Then rebuild the app.