text:
Q: using spawn to restart NODE server if error happened I'm trying this code to restart the node server if it stopped accidentally,  in this example "x" is not defined, so should give an error and re-start, but actually the server completely exit.
var http = require('http');
var spawn = require('child_process').spawn;

var server = http.createServer(function (request, response) {
   console.log(x);
});

server.listen(8125, 'localhost', function(err) {
    if(err) spawn('node',['./server.js']);
});

console.log('Server running at http://127.0.0.1:8125/');

A: The problem in your code is that you can't catch the error in server.listen, you should add an event handler to your main process,  so when an exception or an error occurred the event handler will manage this exception, the code below is an example of handling an error in node.js script.
var http = require('http');

var server = http.createServer(function (request, response) {
   console.log(x);
});

server.listen(8125, 'localhost');

process.on('uncaughtException', function(err) {
    // Add some code here to process the excpetion
    console.log('I m here');
});

console.log('Server running at http://127.0.0.1:8125/');

A: You need forever.js which will restart your process should it crash. Just make sure there aren't any bugs that will keep crashing each instance (basically, make sure your app works so forever doesn't keep trying to restart a broken app).


text:
Q: Google Analytics User-Id view isn't picking up GTM userId I cant see any data in my created View, I've tested with:

*

*ga('create', 'Tracking Id', 'auto');

*ga('set', 'userId', 'email@test.com');

*

`ga('create', 'Tracking Id', 'auto', {
  userId: "email@test.com"
});`

But none of above works

redpajama_set_name: RedPajamaStackExchange


text:
Q: Is it okay if "had" only agrees with the second item (and not the first)? Okay, this is a little hard to explain. So here's an example:

My cousin became a Catholic. My relatives were shocked, since neither they or their ancestors had belonged to that religion.

As you can see, "had" here only agrees with the second item:

My cousin became a Catholic. My relatives were shocked, since they didn't belong to that religion.
My cousin became a Catholic. My relatives were shocked, since their ancestors hadn't
belonged to that religion.

Is the first example common in English? (Structuring a sentence to only agree with the second item). Or there's a better way to structure sentences like these?

A: One of the uses of Perfect tenses is to describe repetitive event or action in the past:

I've often thought I'd enjoy answering questions on StackExchange.
  He mentioned that he had visited his aunt weekly before she passed.

Relatives and their ancestors' belonging to a religion could be considered repetitive because there are (usually) numerous ancestors and each of them likely belonged to some kind of religion.
Since the narration is in the Past tense ("relatives were shocked"), the author justifiedly used Past Perfect tense to refer to a repetitive act/event.
I would probably have used "nor" instead of "or" in the second sentence.

A: Generally, verb tenses should match.  So, either "had" applies to both or the sentence should be reworded.  A sentence with different verb tenses is okay in certain situations, such as when an event in the past effects a later event, but they would need to be in separate clauses (better explained in this article: Grammar Girl).

The example would be a little less complicated if "neither" was removed by changing "that" to "another":

My cousin became a Catholic. My relatives were shocked, because they and their ancestors had belonged to another religion.

Then, the separate scenarios are easier to analyze:

My cousin became a Catholic. My relatives were shocked, because they belonged to another religion.
My cousin became a Catholic. My relatives were shocked, because their ancestors had belonged to another religion.

My first suggestion would be to drop the "had" altogether:

My cousin became a Catholic. My relatives were shocked, because they and their ancestors belonged to another religion.

I realize though that this is just an example, so if in some other case you absolutely need to use the past perfect tense, then the verb tenses should match. If using the same verb tense doesn't make sense, then, in my opinion, the sentence should be reworded (or even split into separate sentences), e.g.:

My cousin became a Catholic. My relatives were shocked, because they belonged to another religion, just as their ancestors had.


text:
Q: How to return multiple row counts with conditions? I have a database named DT with 2 columns.
ID    IMP

01    365
02    289
03    602
04    745
05    100
06    1
07    231
08    903
09    555
10    400

I would like to return a table like that
NUM_ID_UNDER_300    NUM_ID_BETWEEN_301_AND_600   NUM_ID_ABOVE_601
        4                         3                      3

Any ideas?
Thank you!

A: You can do as
SELECT SUM(CASE WHEN IMP <= 300 THEN 1 ELSE 0 END) NUM_ID_UNDER_300,
       SUM(CASE WHEN IMP >= 301 AND IMP <= 600 THEN 1 ELSE 0 END) NUM_ID_BETWEEN_301_AND_600,
       SUM(CASE WHEN IMP >= 601 THEN 1 ELSE 0 END) NUM_ID_ABOVE_601
FROM
(
  VALUES
  (01,    365),
  (02,    289),
  (03,    602),
  (04,    745),
  (05,    100),
  (06,    1),
  (07,    231),
  (08,    903),
  (09,    555),
  (10,    400)
) T(ID, IMP);


text:
Q: Memory issues in R. Can I clear memory with rm(list=ls()) and .rs.restartR() while rendering a site in rmarkdown? I have a Rmd file with 3 sections, a, b and c. I can run everything up till the end of section b just fine with an output html document generated.
However, when I get to the section c I encounter memory issues. I am able to run this 3rd section on it's own.
So, I added a line before section c in my script starts with rm(list=ls()). However, this doesn't solve the problem which is confusing since this section will run on it's own if there is no code beforehand.
I found a suggestion for .rs.restartR() over here but presumably restarting R will interupt my Rmd file being rendered.
Is there a prescribed approach here?
Some older SO posts mention calling gc() but that did not help.
If I can run sections a and b on their own and then section c on it's own, can I not somehow render the whole Rmd document, sections a through c by clearing memory before the code in section c runs?


text:
Q: missing SQLite data provider in VS 2015 can you tell me how to add SQLite to VS 2015.

I already installed : http://system.data.sqlite.org/downloads/1.0.101.0/sqlite-netFx46-setup-bundle-x86-2015-1.0.101.0.exe
without any success.
can you help me please? Thanks in advance

A: Since you mentioned that the Visual Studio is Express Edition:
As per the Readme file provided with setup.

Visual Studio design-time Support, works with all versions of Visual Studio 2005/2008/2010/2012/2013/2015. You can add a SQLite database to the Servers list, design queries with the Query Designer, drag-and-drop tables onto a Typed DataSet, etc.
Due to Visual Studio licensing restrictions, the Express Editions can no longer be supported.

As per the website FAQ:

What versions of Visual Studio are supported?
Currently, Visual Studio 2005, 2008, 2010, 2012, 2013, and 2015 are supported, including the "Express" editions; however, in order to build the entire solution, including the necessary native code, the "Professional" edition (or higher) is required. It may be possible to install both Visual C# Express and Visual C++ Express and then build the corresponding sub-projects via their respective integrated development environments (IDE); however, this configuration has not been tested. The design-time components are no longer supported for the Express editions due to licensing restrictions.


text:
Q: No sections in MS Powerpoint "Outline" view? edit: The answer seems to be no, and there is a votable enhancement request for this.

In Powerpoint (2010, 2019), there is a sectioning feature with folding and there is an outline view. Given that sections are visible in both "Normal" view and the Slide sorter, I would expect them to be visible in the Outline View too, but they are not.
Is it possible to have sections displayed in the Outline view?
Or if that isn't possible, is there any other way to have only sections and slide titles in the sidebar? (Default is sections + thumbnails).


text:
Q: Apparent SQL syntax error, updating multiple rows from form using PHP (PDO) scratching my head over this one, I have a form displaying all rows from a table, and the whole table is to be updated on form submit. The context is that this is the site navigation.
Error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = '1' WHERE ID = '1' LIMIT 1' at line 1' in (path) Stack trace: #0 (path): PDOStatement->execute(Array) #1 {main} thrown in (path) on line 65
Form:
<form action="<?=$PHP_SELF?>" method="POST">
    <?php
    $navstmt = $dbh->prepare("SELECT *
    FROM `navlinks`
    ORDER BY `order` ASC
    LIMIT 0 , 30 ");

    $navstmt->execute();

    $result = $navstmt->fetchAll();
    echo "

ID	Display Title	    Page Name (URL)	Order	Delete
";

foreach($result as $row)
    {
    echo '
<input type="text" name="ID[]" size="4" value="'.$row['ID'] . '">	<input type="text" name="title[]" value="'.$row['title'] . '">	<input type="text" name="url[]" value="'.$row['url'] . '">	<input type="text" name="order[]" size="4" value="'.$row['order'] . '">
';
    }
echo '
';
?>

<input type="submit" name="button" value="Save Changes">

Save to database:
<?php
if($_POST['title']){

$size = count($_POST['title']);
$size = count($_POST['url']);
$size = count($_POST['order']);

$i = 0;
while ($i < $size) {

$title = $_POST['title'][$i];
$url = $_POST['url'][$i];
$id = $_POST['ID'][$i];
$order = $_POST['order'][$i];

$sql = "UPDATE navlinks SET title = :title, url = :url, order = :order WHERE ID = :id LIMIT 1";
$q = $dbh->prepare($sql);
$q->execute(array(':title' => $title, ':url' => $url, ':order' => $order, ':id' => $id));

echo '
All done! The navigation has been  updated.
';
++$i;

}
}
?>

It is probably something really obvious I am sure, but any help would be greatly appreciated!


text:
Q: NULLReference Exception C# ASP.Net (Variable Populated yet i get the exception) oQual is a class variable which is assigned to one of the parameters as show in the code below, the problem is if watch this variable at runtime it is already populated with the correct values yet i am getting the NULLReference Exception on the commented line.
    Programme oPrograme;
    private Qualification oQual;

    public ProgrammeList(Qualification oQualification)
    {
        oPrograme = new Programme();
        oQual = new Qualification();
        oQual = oQualification;

        this.tQID.Text = oQual.getQualficationID().ToString(); //oQual is already populated yet i am getting null reference expection on this line
        this.tProgName.Text = oQual.getQualificationName();
        this.tProg_Saqa_reg_no.Text = oQual.getQualificationNqfLevel();
        this.tProg_nqf_level.Text = oQual.getQualificationSaqaNo();

    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

enter image description here


text:
Q: How can I clean up this OpenLayers code by correctly doing a transform or projection, for an array of features? I have some features I've created via some Kml data.
Now, to display these features on a Google Map, I need to project them from 'EPSG:4326' to 'EPSG:3857'. This works great.
Now, i need to convert this to WKT 4326. When I do that, i re-transform the features but the google map doesn't display them any more because the features are in the wrong projection.
Can anyone suggest a way to clean up my code so I can keep the features in 4326 format, but when I need to display these features on my Layer, it's smart enough to transform it into 3857.
Here's my full javascript code ... but here's the important bits in there...
// Converts some Kml string data into an array of Features.
function convertKmlToFeatures(kml) {
    var kmlFormat = new OpenLayers.Format.KML();
    var features = kmlFormat.read(kml);
    for (var i = 0, l = features.length; i < l; i++) {
        features[i].geometry.transform('EPSG:4326', 'EPSG:3857');
    }
    return features;
}

.....
// Display features.
// NOTE: (This will be as 3857 .. but i wish i can leave this as 4326 and
//        just transform on the fly, here).
map.layers[1].addFeatures(features);

.....
// Finally Output the features as WKT. This needs to be as 4326.
// Right now, it's still as 3857.
var wktFormat = new OpenLayers.Format.WKT();
return wktFormat.write(features);

A: I think you should extend your Layer with custom protocol option.
var options_proj = {
    'internalProjection': new OpenLayers.Projection("EPSG:3857"),
    'externalProjection': new OpenLayers.Projection("EPSG:4326")
   };

new OpenLayers.Format.WKT({
    protocol: new OpenLayers.Protocol.HTTP(
        { url: "kml path",
          format: new OpenLayers.Format.WKT(options_proj)})
    //... other options
});

Therefore,when layer is loaded,it converts kml objects directly to features between projections you specified without writing extra conversion code.


text:
Q: Probability of index at which sequence stops decreasing
Let $X_1,X_2, \dots $ be a sequence of independent and identically
  distributed continuous random variables. Let $N \ge 2$  be such that
  $X_1 \ge  X_2 \ge X_{N-1} < X_N$.  That is, $N$ is the point at which
  the sequence stops decreasing. Find $P\{N \ge n\}$. (Hint: show $E[N] = e$).

My approach to this problem has been to say that the event $\{ N \ge n \}$ is the same as the event $\{X_1 \ge X_2 \dots \ge X_{n-1} \ge X_n\}$. If this is correct (although please correct me if I'm mistaken), then it is not so obvious to me what the probability of that event is. So I was going to find the probability of small subsets of the event first. For example, find  $P\{X_1 \ge X_2 \}$,  or $P\{X_{j-2} \ge X_{j-1} \ge X_{j} \}$. But I am not so sure about the answer to these simple cases either. Is $P\{X_1 \ge X_2 \} = \frac{1}{2}$? How would you reason to find  $P\{X_{j-2} \ge X_{j-1} \ge X_{j} \}$?
Or, how else would you think about this problem to find $P\{N \ge n \}$?

A: You are correct that the event ${N\geq n}$ is the same as the event ${X_1 \geq X_2 \geq \cdots \geq X_{n-1}}$.  Since the random variables are continuous, the probability that any two $X_i$ are equal is $0$, so with probability $1$, all of $X_1, X_2, \ldots, X_{n-1}$ are different.  So from now on we'll suppose that they are all different.
Since the variables are independent and identically distributed, each of the $(n-1)!$ orderings of $X_1, X_2, \ldots, X_{n-1}$ are equally likely by symmetry.  It follows that $P(N\geq n) = \frac{1}{(n-1)!}$.


text:
Q: create new unit test project never appears when creating a new project Does anyone know why it happens?!
I'm using Visual Studio 2010.
I choose mvc project, and when i click on the next dialog, I should have "choose unit test project" writing with a checkbox..but the whole thing is grayed out..why
I think the culprit is the registry, but i am not sure,,,
Here is the key in my regestry Editor undter testprojectTemplates:
AdditionalInfo http://go.microsoft.com/fwlink/?LinkID=178318

Path CSharp\Test

Template  MvcWebApplicationTestProjectTemplatev3.01.cs.zip

TestFrameworkName  Visual Studio Unit Test

A: I just ran into this and found your post here...
Which project template do you have selected? You can only create a unit test project with the wizard if you are selecting a template other than 'Empty' (e.g. 'Internet Application', 'Intranet Application', other installed templates):


text:
Q: How should I load a memory-intensive helper object per-worker in dask distributed? I am currently trying to parse a very large number of text documents using dask + spaCy. SpaCy requires that I load a relatively large Language object, and I would like to load this once per worker. I have a couple of mapping functions that I would like to apply to each document, and I would hopefully not have to reinitialize this object for each future / function call. What is the best way to handle this?
Example of what I'm talking about:
def text_fields_to_sentences(
    dataframe:pd.DataFrame,
    ...
)->pd.DataFrame:
  # THIS IS WHAT I WOULD LIKE TO CHANGE
  nlp, = setup_spacy(scispacy_version)

  def field_to_sentences(row):
    result = []
    doc = nlp(row[text_field])
    for sentence_tokens in doc.sents:
      sentence_text = "".join([t.string for t in sentence_tokens])
      r = text_data.copy()
      r[sentence_text_field] = sentence_text
      result.append(r)
    return result
  series = dataframe.apply(
    field_to_sentences,
    axis=1
  ).explode()
  return pd.DataFrame(
      [s[new_col_order].values for s in series],
      columns=new_col_order
  )

input_data.map_partitions(text_fields_to_sentences)

A: You could create the object as a delayed object
corpus = dask.delayed(make_corpus)("english")

And then use this lazy value in place of the full value:
df = df.text.apply(parse, corpus=corpus)

Dask will call make_corpus once on one machine and then pass it around to the workers as it is needed.  It will not recompute any task.


text:
Q: How do I scan a sentence into an array of strings? I have a text file where two types of format occur. After scanning through the first format type and putting it into an array, the second format is encountered:
$$$$$$$
I have a big tree full of money
How do I ignore the line of $$$$$$$ and scan the sentence into a new array where each element is a word in the sentence:
`char sentence[MAX_SENTENCE_LENGTH]`

I have tried to use:
for (i = 0; i < MAX_SENTENCE_LENGTH; i++){
        if (scanf(" $$$$$$$ %s", sentence[i]) !=1){
                break;

But this doesn't account for the fact that the $$$$$$$ only occurs once before the sentence. It also returns a formatting warning:
format specifies type 'char *' but the argument has type 'int' [-Wformat]

A: The main issue in your program is that you expect to read in an array of strings, but your data structure is a single string. Your compiler should actually have warned you.
Then, scan the first element with " $$$$$$$ %s" format, the following ones with "%s" only:
const int MAX_SENTENCE_LENGTH = 30;
const int MAX_NR_OF_SENTENCES = 30;

char sentence[MAX_NR_OF_SENTENCES][MAX_SENTENCE_LENGTH];

int i=0;
if (scanf(" $$$$$$$ %29s", sentence[i]) == 1) {
    i++;
    while (i < MAX_NR_OF_SENTENCES) {
        if (scanf("%29s", sentence[i]) !=1){
            break;
        }
        i++;
    }
}


text:
Q: Exit script with Python I've got a Python script for ArcGIS that I'm working on, and I'd like to have the ability to have the script quit if it doesn't have the necessary data available.  I tried a straight up sys.exit() but that would give an exception in ArcMap that I'd like to avoid.  I found This thread that suggests using a try block, so I made this function:
def quit_script(message):
log_msg(message) # already defined; writes a message to a file
if log_loc:
    output.close() # close the file used with log_msg()
try:
    sys.exit()
except SystemExit:
    pass

Unfortunately, that didn't work either.  Well, it doesn't make that error on ArcMap anymore, but it also doesn't, well, quit.  Right now, I have the bulk of my code in an if/else statement, but that's ugly.  Anybody have any other suggestions?
Thanks!
Brian

A: No, the try/except block you will want do have the 'catch' get your exit call; so in your try you would do something like this:
try:
    if arcpy.Exists(parcelOutput):
    arcpy.AddMessage("Calculating Parcel Numbers")
except:
    raise sys.exit("Error: " + arcpy.GetMessages(x))

This will file if your 'if' statement fails.


text:
Q: Tailwind CSS technique for a horizontal line with words in the middle I'm trying to make a horizontal rule with some text in the middle. For example:
----------------------------------- my title here -----------------------------

Is there a way to do that in Tailwind CSS?.


text:
Q: How to handle asynchronous operations in REST I need to understand what approaches there are to handle asynchronous operations in REST and what their advantages and disadvantages are. Some approaches I found:

*

*Resource Based: Where the status of an operation is modeled as a status. User makes an async REST call (PUT, POST etc.) gets Accepted or In-Progress response (202). Further a status URI is polled repeatedly via GET to check status/progress/messages from operation execution.
Question: How long should this resource be active at Server? If the client polls in large intervals where in between the operation completes, how do we return the status? Seems like persisting the execution status would work. But how long to persist, when to archive/delete, is this kind of standard approach?

*Callback Based: Where an async request is required to have a callback URI. The request gets processed asynchronously and upon completion makes a call to the callback URI with the operation status/result.
Question: This seems more elegant and involving less overhead at the server side. But how to handle scenarios where the callback server is intermittently down, not responding, etc.? Implement a typical retries where the callback URI provides retries configuration as well? Is there any other downside to this approach?

*Servlet 3.0 Asynchronous support: Where an HTTP client makes a connection to a Java Servlet, which remains open until it is explicitly closed and until closed client and server can communicate asynchronously over it.
Question: Since its Servlet 3.0 spec, I think Jersey, the Spring REST implementation, doesn't utilize this approach as of now. Is there any specific REST implementation which utilizes a similar approach or pointer on ways to make it possible?

*Any other approaches, maybe commercial ones?

A: Spring 3.2+ supports the async features of Servlet 3.0. From the Spring Blog:

you can make any existing controller method asynchronous by changing it to return a Callable. For example a controller method that returns a view name, can return Callable instead. An @ResponseBody that returns an object called Person can return Callable instead. And the same is true for any other controller return value type.

Jersey 2+ also supports asyncronous servers. See the Asynchronous Services and Clients chapter in the reference docs.

A: I think, the approach depends on time gap between initial request and the end of operation.

*

*For short-time operations ( < 10s ) I would just keep the request open and return response when operation finished;

*For long operations ( < 30m ) I would use servlet 3.0 or Comet model;

*For extremely long operations ( hours, days ) good enough way, as for me, is just client-based polling or Comet with big timeouts.

A: I'm dealing now with the same situation and found the common approach of using Location header response to give a resource that can be monitored to check status (by polling of course). That seems to be the best, but in my case, I'm not creating a resource so I don't have a location to check the status (my async process is just to build a cache page).
You can always use your own headers to give an estimated time to complete the operation. Anyway I'm thinking of using Retry-After header to give an estimated time. What do you guys think?

A: I know this is old but I thought I'd chime in here to say that if what you want is something that can scale out in a stateless environment then you should go with your first option. You can perform the underlying operation anywhere and if you put the result in something like redis it will not matter to what web server the client makes subsequent polling requests. I'll usually put the polling interval in the response I sent to the client. When there a result is ready I will return the client a SEE OTHER that includes the id of the result in the URI.


text:
Q: Problem getting the full path of the file uploaded using HTML inputfile type to read the content of the file I would like to use HTML input file type in my aspx page to allow user to browse for a excel file and then read the content of the excel sheet programmatically.If I want to read the excel sheet I need the full path of the file to connect to the excel sheet using asp.net.I do not understand how can I get the full path of the file.
I know I can get the filename using postedFile.FileName property.But I need the full path of the file.
Could someone please help me with that.
Thanks.

A: There's no such notion as full path of the file. The server has no way of knowing where the file is stored on the client computer. All that you can know in your ASP.NET application is the filename and the contents of the uploaded file.

A: You can use the OpenXml SDK (http://msdn.microsoft.com/en-us/library/dd608815(office.14).aspx) to open the Excel sheet programatically, directly from the stream of the fileupload.
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;

FileUpload fu = (FileUpload)Page.FindControl("fuExcel");
using (SpreadsheetDocument uploadedWorkbook =
SpreadsheetDocument.Open(fu.FileContent, true))
{
    //interrogate the file here
}

The FileUpload control doesn't provide any information regarding the path where the file was uploaded from.  You get:

*

*The file's name (that is, abc.xyz,
stripped of any path information), as FileName

*A stream of the file content as FileContent

*An array of bytes in the file as FileBytes


text:
Q: (Codeigniter) next_prev_url calendar with ajax or j-query i want my next_prev_url calendar become to ajax
so if i press the next or prev link my calendar will process in ajax...
this is my controller
$this->load->model('tasks_koord_model');
    $prefs = array (
        'show_next_prev'    => TRUE,
        'next_prev_url'     => site_url('kalender_koord_controller/index'),
        'template'          =>'{table_open}
{/table_open}
    {week_day_cell}{week_day}	{/week_day_cell}
    {cal_cell_content}
{day}
{/cal_cell_content}
    {cal_cell_content_today}
{day}
{/cal_cell_content_today}
    {cal_cell_no_content}{day} {/cal_cell_no_content}
    {cal_cell_no_content_today}
{day}
{/cal_cell_no_content_today}'
    );
    $this->load->library('calendar',$prefs);

please help me...

A: I hope this is what you're looking for. https://thecodingmaniac.blogspot.com/ see attached file below. Hope this helps.


text:
Q: SVG Animate Planes Around Globe CodePen Here
I am trying to get this plane animation so that the planes fly around the globe:

I have added the globe to the code using a <circle> element, but I am not sure how to mask the backside of the planes so that they appear to be flying "around" the globe.

I have tried using position:relative together with z-indexes in order to achieve that the globe has a "closer" position than the back of the plane, but I have not been able to pull this off.
Any help is appreciated, thank you.
CODE
<svg width="300px" height="300px">
  <defs>
    <path id="svg-half-plane"
          d=" M 0,-5
             A 1,1 0 0 1 1,-4
             L 1,-1 5,1 5,2 1,1 1,3 2,4 2,5 0,4
             Z"
          ></path>

    <symbol viewBox="0 0 10 10" id="svg-plane" overflow="visible">
      <use xlink:href="#svg-half-plane"></use>
      <use xlink:href="#svg-half-plane" transform="scale(-1, 1)"></use>
    </symbol>
  </defs>
  <g class="sky" transform="translate(150, 150)">

    <circle class="globe" cx="0" cy="0" r="100" />

    <g class="plane-container" transform="rotate(289)">
      <use class="plane" xlink:href="#svg-plane" width="50" height="50"></use>
    </g>

    <g class="plane-container" transform="rotate(129)">
      <use class="plane delay-1" xlink:href="#svg-plane" width="50" height="50"></use>
    </g>

    <g class="plane-container" transform="rotate(37.5)">
      <use class="plane delay-2" xlink:href="#svg-plane" width="50" height="50"></use>
    </g>

    <g class="plane-container" transform="rotate(57.5)">
      <use class="plane delay-3" xlink:href="#svg-plane" width="50" height="50"></use>
    </g>

    <g class="plane-container" transform="rotate(-37.5)">
      <use class="plane delay-4" xlink:href="#svg-plane" width="50" height="50"></use>
    </g>

  </g>
</svg>

CSS
body, html {
  padding: 0;
  margin: 0;
  border: 0;
  height: 100%;
  background: #222;
  display: flex;
  justify-content: center;
  align-items: center;
}

svg {
  display          : block;
  background-color : #555;
  shape-rendering  : crispEdges;
}

.plane-container {
  -webkit-perspective : 900px;
  -ms-perspective     : 900px;
  perspective         : 900px;
  z-index:            : 3;
}

@-webkit-keyframes flyaround {
  0% {
    -webkit-transform : rotateX(0deg) translateZ(140px) scale3d(1, 1, 1);
    transform         : rotateX(0deg) translateZ(140px) scale3d(1, 1, 1);
    fill              : #eee;
    opacity           : 1.0;
  }

  50% {
    -webkit-transform : rotateX(180deg) translateZ(140px) scale3d(0.5, 0.5, 0.5);
    transform         : rotateX(180deg) translateZ(140px) scale3d(1, 1, 1);
    fill              : #eee;
    opacity           : 0.5;
  }

  100% {
    -webkit-transform : rotateX(360deg) translateZ(140px) scale3d(1, 1, 1);
    transform         : rotateX(360deg) translateZ(140px) scale3d(1, 1, 1);
    fill              : #eee;
    opacity           : 1.0;
  }
}

@keyframes flyaround {
  0% {
    -webkit-transform : rotateX(0deg) translateZ(140px) scale3d(1, 1, 1);
    -ms-transform     : rotateX(0deg) translateZ(140px) scale3d(1, 1, 1);
    transform         : rotateX(0deg) translateZ(140px) scale3d(1, 1, 1);
    fill              : #eee;
    opacity           : 1.0;
  }

  50% {
    -webkit-transform : rotateX(180deg) translateZ(140px) scale3d(0.5, 0.5, 0.5);
    -ms-transform     : rotateX(180deg) translateZ(140px) scale3d(0.5, 0.5, 0.5);
    transform         : rotateX(180deg) translateZ(140px) scale3d(1, 1, 1);
    fill              : #eee;
    opacity           : 0.5;
  }

  100% {
    -webkit-transform : rotateX(360deg) translateZ(140px) scale3d(1, 1, 1);
    -ms-transform     : rotateX(360deg) translateZ(140px) scale3d(1, 1, 1);
    transform         : rotateX(360deg) translateZ(140px) scale3d(1, 1, 1);
    fill              : #eee;
    opacity           : 1.0;
  }
}

.plane {
  fill              : none;
  -webkit-animation : flyaround 2500ms infinite linear;
  animation         : flyaround 2500ms infinite linear;
}

.delay-1 { -webkit-animation-delay: 123ms; animation-delay: 123ms; }
.delay-2 { -webkit-animation-delay: 2023ms; animation-delay: 2023ms; }
.delay-3 { -webkit-animation-delay: 773ms; animation-delay: 773ms; }
.delay-4 { -webkit-animation-delay: 1123ms; animation-delay: 1123ms; }

A: This is difficult without some extra elements or javascript I think.
You could do this, by adding a 2nd mirror element, one created earlier in the DOM that the circle, so it appears behind it. At the same time, make the front plane vanish when trying to give the appearance it is behind.
So to make the front plane vanish...

@keyframes blink {
  0% { opacity: 1.0; }
  50% { opacity: 0.0; }
  100% { opacity: 1.0; }
}
@-webkit-keyframes blink {
  0% { opacity: 1.0; }
  50% { opacity: 0.0; }
  100% { opacity: 1.0; }
}
.blink {
  animation: blink 2500ms step-start 0s infinite;
  -webkit-animation: blink 2500ms step-start 0s infinite;
  -webkit-animation-delay: 400ms;
  animation-delay: 400ms;
}

...

    <g class="plane-container" transform="rotate(0)">
      <use class="plane" xlink:href="#svg-plane" width="50" height="50"></use>
    </g>

    <circle class="globe" cx="0" cy="0" r="100" />

    <g class="plane-container blink" transform="rotate(0)">
      <use class="plane" xlink:href="#svg-plane" width="50" height="50"></use>
    </g>

codepen
Just check browser support that you need, especially in IE for svg+css3 transform support

A: I think dummy loop and relative timing is helpful. See How to make SVG Loop Animation?

<svg>
  <rect>
    <animate id="o1" begin="0;o1.end" dur="10s"
    attributeName="visibility" from="hide" to="hide"/>
  </rect>
  <circle fill="orange" cx="-50" cy="100" r="20">
    <animate begin="o1.begin"
    attributeName="cx" from="250" to="50" dur="5.05s"/>
  </circle>
  <circle fill="blue" cx="150" cy="100" r="50" />
  <circle fill="orange" cx="-50" cy="100" r="20">
    <animate begin="o1.begin+5s"
    attributeName="cx" from="50" to="250" dur="5.05s"/>
  </circle>
</svg>


text:
Q: Aws database error php mysql I have connected my appication with aws rds with the script below:
function db_connect() {
   $result = new mysqli($_SERVER['RDS_HOSTNAME'], $_SERVER['RDS_USERNAME'], $_SERVER['RDS_PASSWORD'], $_SERVER['RDS_DB_NAME'], $_SERVER['RDS_PORT']);
   if (!$result) {
     throw new Exception('Could not connect to database server');
   } else {
     return $result;
   }
}

It was working fine then i had to change it due to a new feature which someone else wrote the code for:
$dbOptions = array(
    'db_host' => 'RDS_HOSTNAME',
    'db_user' => 'RDS_USERNAME',
    'db_pass' => 'RDS_PASSWORD',
    'db_name' => 'RDS_DB_NAME'
);

I didn't add the port because he didn't and i never connected to database with an array and key like this, how do i go about adding port like at what position.

A: I was forgetting the $_SERVER variable:
$dbOptions = array(
'db_host' => $_SERVER['RDS_HOSTNAME'],
'db_user' => $_SERVER['RDS_USERNAME'],
'db_pass' => $_SERVER['RDS_PASSWORD'],
'db_name' => $_SERVER['RDS_DB_NAME']

);


text:
Q: Optimize mysql table to avoid locking How do I optimize mysql tables to not use locking? Can I alter table to 'turn off' locking all the time.
Situation:
I have app which use database of 15M records. Once weekly scripts doing some task (insert/update/delete) for 20 hours, and app servers that feed data to front end (web server), and that is fine, very small performance loss I see during that time.
Problem:
Once monthly I need to optimize table, since huge number of records is out there it take 1-2 hours to finish this task (starting optimize from mysql command line, or phpMyAdmin, same) and in that period mysql DOESN'T SERVE data to front end (I suppose it is about locking tables for optimize)
Question:
So how to optmize tables to avoid locking, since there is only reading of data (no insert or update) so I suppose 'unlocking' while optimize, in this case can't make any damage?

A: In case your table engine is InnoDB and MySQL version is > 5.6.17 - the lock won't happen. Actually there will be lock, but for VERY short period.

Prior to Mysql 5.6.17, OPTIMIZE TABLE does not use online DDL.
  Consequently, concurrent DML (INSERT, UPDATE, DELETE) is not permitted
  on a table while OPTIMIZE TABLE is running, and secondary indexes are
  not created as efficiently.
As of MySQL 5.6.17, OPTIMIZE TABLE uses online DDL for regular and
  partitioned InnoDB tables. The table rebuild, triggered by OPTIMIZE
  TABLE and performed under the cover by ALTER TABLE ... FORCE, is
  performed in place and only locks the table for a brief interval,
  which reduces downtime for concurrent DML operations.

Optimize Tables Official Ref.
Just better prepare free space that is > than the space currently occupied by your table, because whole table copy can happen for index rebuild.


text:
Q: User-specific settings page for managing boolean inputs 1:1 for each field in a dynamic describe of fields? There is a managed app on the Appexchange and it solves a limitation by employing a "Track History" concept to give admins a boolean setting specific to each datafield on User object (for the purpose of tracking its field history).  , This allows admin(s) to define/manage a common set of preferences for Tracking History on User fields.
How would we modify the concept of "Track History" from the image above to build a visualpage that allows the user to manage TRUE or FALSE settings specific to each field in a dynamic fields describe call for a given custom object?
The page must "remember" (persist between page loads) the user's boolean selections for all fields in a custom object.
Unlike the "Track History" example, i dont need to track any field history.  I just need to build a visualforce page that reads/writes boolean inputs ("settings") to a user-specific  cache or object where each input is specific to a dynamic list of fieldnames. I believe hierarchical custom settings are the way forward here.  Another reason I'm choosing hierarchical custom settings in this design is because it is possible for users to read/write their own custom settings via visualforce
My guess is that the page needs to dynamically describe field names, then query the user's existing hierarchical settings (where they may have indicated boolean preferences for fields), then construct the input booleans on the page according to their settings or defaulting to some default in the case of no found settings record for the given field.
Has anyone tried this with any success?
Thank you community!


text:
Q: R testthat package: How can I see output from message() when using test_file() I am using the excellent testthat package in R. My issue is that I cannot see any output from the message() function in the code being tested when using test_file. for example, say I have following code in a file called test_message.R
f <- function() {
    message ("Message: Hello world")
    cat ("Cat: Hello world\n")
    return (1)
}

test_that ("message shows up", {
     expect_equal(f(), 1)
 })

I run test_file as follows and get the output below
> test_file("test_message.R")
Cat: Hello world
.

So I am not seeing the text from message().
However, when I run the code on its own I do see it:
> f()
Message: Hello world
Cat: Hello world
[1] 1

I know that by default, message() writes to stderr and cat writes to stdout and I'm guessing that test_file "intercepts" stderr to test for the text in warnings and errors. Is there any way I can configure things so I see message() text on the console?

A: You can't do this, at least not without modifying the source code of testthat. This is the part that runs the code of the test: https://github.com/hadley/testthat/blob/0af22cfc7c7f6b13b02537f0d37d96d72d8a98b7/R/test-that.r#L65 If you remove the suppressMessages from the test_code function, then the messages will be displayed.
Btw. testthat does not capture standard output or error AFAIK, so if you write to it using cat or some other way, that will also displayed.

A: This is my inaugural post to SO, on a language I just started learning two weeks ago, so be gentle.
I believe the following is what you're looking for:
test_that ("message shows up", {
  expect_message(f(), "^Message: Hello world\\n")
})

Also, see the documentation for shows_message & expect_message on page 23 of testthat.pdf (For future reference: published 2014-02-22 00:25:04 for v0.8.1).
And full credit to GSee for https://stackoverflow.com/a/24476491/3811916 which is the second post after this one that I turned up when looking to test for this same issue.
I just discovered evaluate_promise (also in the pdf linked above). So here's an alternative that will test for the message and print the output:
test_that ("message shows up", {
  result <- evaluate_promise(f(), print = TRUE)
  expect_that(result$message, equals("Message: Hello world\n"))
  print(result$output)
})


text:
Q: Flip a view in ViewPager Is it possible to flip a view in ViewPager.Basically i want to put several views as in hompage and a view behind every view i.e user must be able to flip the view too.

A: Yes Very Much Possible.
You need Rotation Animation
Look here
How to make a smooth image rotation in Android?
and
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.html
I used the above and implemented successfully what you are asking.
Look for its example in api demo of android


text:
Q: Print contents of a folder Here is my example.
Ex:
I have a folder that contains another 3 folders (FoldA, FoldB, and FoldC), a .txt file, and a .png file.
I have the following working code which works to print the contents a folder or directory.
import pathlib

rd = pathlib.Path("E:\\Location\\MainFolder")

for td in rd.iterdir():
    print(td)

The output is:
E:\Location\MainFolder\FoldA
E:\Location\MainFolder\FoldB
E:\Location\MainFolder\FoldC
E:\Location\MainFolder\image.png
E:\Location\MainFolder\text.txt

Does anyone know a quick way to only print the folders and not any other file type (.txt, .bmp, .png, etc.)? I've tried using .is_dir but it still prints everything.
Thanks in advance!

A: probably you did if td.is_dir with is a function, so you need to execute it like this:
import pathlib

rd = pathlib.Path(".")

for td in rd.iterdir():
    if td.is_dir():
        print(td)

Kinda common problem with pathlib at beginning :)


text:
Q: How to extract part of numpy array? I am trying to extract part of an array using numpy. I look it up and it seems that there are plenty of ways to do so either (for example np.delete()). However, I can't manage to make it work for my problem.
I have a big array with a shape(80,2,100,100,3) I want to divide this array into two sliding part using a loop:
for i in range(0, len(data), len(data)//2):
     part_1 = data[i:i+len(data)//5] #Initial selection
     part_2 = data[0:i::i+len(data)//5:] #Selection of the rest of the initial data

for i in range (0, len(data), len(data)//2):
    part_1 = data[i:i+len(data)//5]
    part_2 = np.delete(data, obj=part_1, axis=0)

Both solutions don't work. Does anyone have an idea?
Kind regards,
Unic0

A: I found a way to do that by splitting the problem in two parts:
for i in range(0,len(data),len(data)//5):

        part_1 = data[i:i+len(data)//5]

        temp0 = data[0:i]
        temp1 = data[i+len(data)//5:]
        part_2 = np.concatenate((train_images0, train_images1), axis=0)

However, I am certain there would be a better way to do that in one step.
If anyone has any suggestions, it would be more than welcome.
Regards,
Unic0


text:
Q: Spring Boot Kotlin - EndPoint no devuelve respuesta en formato Json Dado el siguiente ENDPOINT:
@RequestMapping(value = ["/public/v1/users/players/actives"], method = [RequestMethod.GET])
fun getAllActives(){
        playerService.obtainAllActives()
            .map { ResponseEntity(it, HttpStatus.OK) }
            .logEither(
                { error("getAllActives: no se pudo obtener toda la lista de jugadores activos") },
                { info("getAllActives: se obtuvo toda la lista de jugadores activos") }
            )
}

Teniendo en cuenta que tengo la anotación @RestController, no logro obtener respuesta en formato json.
Cabe destacar que tengo la dependencia
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")


text:
Q: can't display images from localhost dev server in react native I'm trying to render images in react native from my local dev server, but I'm not able to shoe images. The image URI I'm getting from the server is a proper one I checked that with copying and pasting it to the chrome tab and it opens up with a new tab showing the image.
http://localhost:4001/f931a2c2-4268-4bd8-8f6f-c0bab923a374.jpeg, this is the example of the URI, and this is my image component code.
export const LogoImage: React.FC = ({ logo }) => {
  return (
    <View style={styles.wrapper}>
      <Image
        source={{
          uri: "http://localhost:4001/${logo}",
        }}
        style={styles.image}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  image: {
    height: "100%",
    width: "100%",
    resizeMode: "cover",
  },
  wrapper: {
    height: 200,
    width: 200,
  },
});

Any idea and suggestion would be appreciated.

A: Try replacing the keyword localhost with you own IPv4-address. You can get it by executing ipconfig in cmd. I also found a similar question here.


text:
Q: Interpreting mortality trends shown as relative hazard I am analysing trends in survival. I was recommended to use the following package and parameterization.
I have a model as follows (done with rms package):
survobj12 = with(data, Surv(time_12months,status_12months))

model2 = cph(survobj12 ~ rcs(time_to_diagnosis_in_years, 4), data=data,x=TRUE ,

y=TRUE)

Result
Cox Proportional Hazards Model

 cph(formula = survobj12 ~ rcs(time_to_diagnosis_in_years, 4), data = data,
     x = TRUE, y = TRUE)

                     Model Tests       Discrimination
                                          Indexes
 Obs     11491    LR chi2      0.56    R2       0.000
 Events   3534    d.f.            3    Dxy      0.009
 Center 0.0343    Pr(> chi2) 0.9048    g        0.013
                  Score chi2   0.56    gr       1.013
                  Pr(> chi2) 0.9053

                          Coef    S.E.   Wald Z Pr(>|Z|)
 time_to_diagnosis_in_years    0.0145 0.0330  0.44  0.6597
 time_to_diagnosis_in_years'  -0.0271 0.0946 -0.29  0.7741
 time_to_diagnosis_ine_years''  0.0741 0.2853  0.26  0.7952

This is the plotted result:
#plot
ggplot(Predict(model2), vnames = "names")+
xlab("Time from diagnosis in years")+

This seems really nice; however, how should I interpret the plot? Is relative hazard equal to hazard ratios? The interpretation of hazard ratios is quite simple: e.g. HR = 2 means that females have two times higher risk for dying than males during a certain time period. However, my plot does not have a reference category at all.
So, are these two estimates (Relative Hazard and Hazard Ratio) equal to each other and what is the reference on my plot/analysis?

A: The most important point in this example is that your model isn't different from a null model. The p-values for both the likelihood-ratio (LR) and score tests for the model are very high, over 0.9. With a 4-knot restricted cubic spline you are estimating coefficients for the equivalent of 3 predictors, with no values significantly different from zero here.
For the plot itself, it's important to learn about what your software tools are doing; see the manual page for the rms Predict and datadist functions. An example on the manual page for Predict shows that the reference value for a continuous predictor is taken from the second value in the limits vector for that predictor in the datadist summary of the data. Resetting that value allows you to choose any reference value that you want; in that manual page example:
ddist$limits$age[2] <- 30

resets the reference value for a variable age to 30. If you don't specify your own reference, the manual page for datadist shows that the median value is chosen for a continuous predictor:

Adjustment values are 0 for binary variables, the most frequent category (or optionally the first category level) for categorical (factor) variables, the middle level for ordered factor variables, and medians for continuous variables.

That adjustment/reference value is shown in this example as the time value at which the "log Relative Hazard" crosses 0. The plot then shows changes in "log Hazard" relative to that reference time value as you go to lower or higher times. If your model had more predictors, the 0 reference for the "log Relative Hazard" would also be based on the reference values for all the other predictors, so depending on the data and the model this type of plot might never cross 0.


text:
Q: Python - How to generate a binning index for a list? I have a 10 bins:
    bins = [0,1,2,3,4,5,6,7,8,9]

I have a list of 25 values:
    values = [10,0,0,14,14,123,235,0,0,0,0,0,12,12,1235,23,234,15,15,23,136,34,34,37,45]

I want to bin the values sequentially into the bins so each value is grouped into its bin:
binnedValues = [[10,0],[0,14,14],[123,235],[0,0,0],[0,0],[12,12,1235],[23,234],[15,15,23],[136,34,34],[37,45]]
As you can see, the number of values in the bin is not always the same, (as len(values) != len(bins))
Also, I have lots of different values lists that are all different sizes. So I need to do this a number of times for the same number of bins, but different lengths of values lists. The above is an example - the real bin size is 10k, and the real len(values) is from ~10k to ~750k..
Is there a way to do this consistently? I need to maintain the order of the values, but split the values list evenly so there is a 'fair' and 'even' number of the values range distributed to each of the bins.
I think I can use numpy.digitize, but having had a look, I can't see how to generate the 'binned' list

A: Are you trying to split the list into lists of alternating size between 2 and 3 elements? That's doable, then.
from itertools import cycle

values = [10,0,0,14,14,123,235,0,0,0,0,0,12,12,1235,23,234,15,15,23,136,34,34,37,45]
splits = cycle([2,3])
bins = []
count = 0

while count < len(values):
    splitby = splits.next()
    bins.append(values[count:count+splitby])
    count += splitby

print bins

Edit:
Ah, I see what you're requesting... sort of. Something more like:
from itertools import cycle
from math import floor, ceil
values = [10,0,0,14,14,123,235,0,0,0,0,0,12,12,1235,23,234,15,15,23,136,34,34,37,45]
number_bins = 10
bins_lower = int(floor(len(values) / float(number_bins)))
bins_upper = int(ceil(len(values) / float(number_bins)))

splits = cycle([bins_lower, bins_upper])
bins = []
count = 0

while count < len(values):
    splitby = splits.next()
    bins.append(values[count:count+splitby])
    count += splitby

print bins

If you want to more variety in bin size, you can add more numbers to splits
Edit 2:
Ashwin's way, which is more concise without being harder to understand.
from itertools import cycle, islice
from math import floor, ceil

values = [10,0,0,14,14,123,235,0,0,0,0,0,12,12,1235,23,234,15,15,23,136,34,34,37,45]
number_bins = 10
bins_lower = int(floor(len(values) / float(number_bins)))
bins_upper = int(ceil(len(values) / float(number_bins)))

splits = cycle([bins_lower, bins_upper])

it = iter(values)
bins = [list(islice(it,next(splits))) for _ in range(10)]
print bins


text:
Q: Separating the hamiltonian for a superlattice -- is it this easy? I've been banging my head against a wall trying to figure out what I'm sure is a very simple problem. I want to solve the Kronig Penney model for a superlattice, which is just a normal periodic 1D potential, except the potential wells extend into all space in the directions perpendicular to the perodicity, like so:

I know how to solve a normal 1D KP model. In extending it to 3D, the wave function is now $\psi(r,z) = \psi(z) \psi(r)$, where $r = \{x,y\}$. In the x and y directions, the wave functions are just plane waves, so you can write $\psi (r) = A e^{i\vec k \cdot \vec r}+B e^{-i\vec k \cdot \vec r}$.So, the Hamiltonian applied to the wavefunction gives:
$$\frac{-\hbar^2}{2m}[\frac{\partial^2}{\partial x^2}+\frac{\partial^2}{\partial x^2}+\frac{\partial ^2}{\partial z^2}]\psi(z) \psi(r) + V(z)\psi(z) \psi(r) = E\psi(z) \psi(r)$$
and
$$\frac{\hbar^2 k_\parallel^2}{2m}\psi(z) \psi(r) + \psi(r)\frac{-\hbar^2}{2m}\frac{\partial ^2}{\partial z^2}\psi(z) + V(z)\psi(z) \psi(r)= E\psi(z) \psi(r)$$
(where $k_\parallel = \{k_x,x_y\}$.)
But now is it really so simple to just divide the whole thing by $\psi(r)$ and subtract the parallel kinetic energy terms, and define a new $z$ energy?
$$\frac{-\hbar^2}{2m}\frac{\partial ^2}{\partial z^2}\psi(z) + V(z)\psi(z)= (E-\frac{\hbar^2 k_\parallel^2}{2m})\psi(z) = E_z \psi(z)$$
This is just the regular old KP model problem, but with an energy that has two parameters. So for an electron traveling at an angle away from the normal, once you specify that angle, it's just the 1D problem again. Is it this simple or am I missing something?
Thank you!

A: I'm don't have high enough reputation to comment yet, so here's a half answer - half comment...
It is indeed possible to separate the problem, as you say, into $\psi(x,y,z) = \chi(x,y)\zeta(z)$ and the total energy of the state is then
\begin{equation}
  E = E_z + \frac{\hbar^2 k_{\parallel}^2}{2m^*_{\parallel}}
\end{equation}
Now, read on if you would like to make the problem a little harder to solve... :-p
Since your diagram refers to a semiconductor heterostructure, you need to use the effective mass of the appropriate energy band rather than the free-electron mass.  Also, if you want your model to be accurate, you must account for the large mismatch in effective mass between GaAs and AlAs.  In other words, the effective mass is a function of $z$, and can be denoted $m^*(z)$.  This should be accounted for first when you find $E_z$ and $\psi_z(z)$ using an appropriate solution to the Kronig-Penney model.  See for example, P. Harrison, "Quantum Wells, Wires and Dots" 3rd Ed., Wiley (2009) if your model doesn't account for this effect yet.
Next, you need to find an appropriate in-plane effective mass that accounts for the spatial variation in $m^*(z)$.  A reasonable approach would be to take the expectation value of the effective mass in the growth direction... this, then depends on which $\psi_z(z)$ state your in-plane dispersion is based upon:
\begin{equation}
  \frac{1}{m^*_{\parallel}(E_z)} = \left\langle\psi_z\right|1/m^*(z)\left|\psi_z\right\rangle
\end{equation}
Therefore, the complete solution would be to (i) find the $z$-component (ii) compute the expectation value of the effective mass (iii) use this to compute the $r$-component.
If you want to make things even harder, then note that the energy bands in a semiconductor are not parabolic, and hence the effective mass will become a function of both energy and $z$-position.  This makes the Schroedinger equation a nonlinear eigenvalue problem, which would be even more challenging to solve... I don't know if there is an analytical solution in that case!


text:
Q: Where can I find documentation for Ember 0.9.8? I have a client from years ago that wants a few changes to an Ember app that was written in ember-0.9.8. I haven't used ember since then, and I know a lot has changed. But, I still need to refer to the old documentation, and the website seems to only go back as far as 1.10.

A: Ember v0.9.8 was release on May 21, 2012.   This is a little before any of their git repos for the guides.
The guides back then were within the emberjs repo and had to be built manually.
Download the release: https://github.com/emberjs/ember.js/releases/tag/v0.9.8
The README.md file has instructions for building the documentation.

Building API Docs
The Ember.js API Docs provide a detailed collection of methods,
  classes, and viewable source code.
NOTE: Requires node.js to generate.
See http://emberjs.com/ for annotated introductory documentation.
Preview API documenation

*

*run rake docs:preview

*The docs:preview task will build the documentation and make it available at http://localhost:9292/index.html
Build API documentation

*

*run rake docs:build

*HTML documentation is built in the docs directory

You can give it a try, but good luck - it might be tough.

A: As mentioned by Lux the API documentation is in the code and that one is on GitHub. You could find the ember code at that point of time by tag. The readme contains information about how to generate the API docs. If you are lucky it will still work.
v0.9.8.1 was released on 23 May 2012. That's quite a long time for a web application to run without any major refactoring. Ember has changed hardly since then.


text: Q: Adding Flags to Metadata using Zendesk API I'm creating Zendesk tickets using the API in PHP, and I want to add flags:[3] to the metadata so that it shows that the ticket requester was not signed in when the ticket was created. However, I have yet to find a way to edit the metadata in this way; all of the ways that I've found to edit the metadata when creating a ticket have just added it to the 'custom' field, as opposed to actually adding this flag. Was wondering how I would go about doing this? Thanks!


text:
Q: Load data incrementally in azure data factory I am still wondering if there is any way to copy the data from one data lake folder to another data lake folder using copy activity or dataflow activity in the Azure data factory.
Suppose, I have a file in my input folder that says input/employee.csv which has data till March 21 and I have loaded that data into my datalake in the output folder output/employee.csv.
Now, from the next run onwards, I only want to pull data that got modified in the last 7 days. For doing that I queried the source system and I got that 7 days of data in a file and now, I need to check that 7 days of data against my sink and merge the data accordingly to sink (update/insert/delete).
I checked upsert if in dataflow but it looks like to work on this we need sink as a DB, but here my sink is datalake even my source is the file present in datalake.
I think I can use merge file behaviour or hashing as well, but not sure what will be the more optimized approach?
Please suggest

A: There is a source property in both Copy & Data flow for "last modified date/time". You can also use the pipeline incremental pattern with waterlines or hashing techniques.
https://www.youtube.com/watch?v=GACpvMjOJgE
https://learn.microsoft.com/en-us/azure/data-factory/tutorial-incremental-copy-overview


text:
Q: txt file with braces convert to dataframe i have a txt file which i got from zoom api. I want to transform it to a dataframe for later cleaning. But there is a column that comes with curly braces, it doesn't read it like a dictionary
open = pd.read_csv("registrados111.txt", sep = " ")
open.columns = ["page_size","total_records","next_page_token","registrants"]
open.head(1)

enter image description here
strong text
I want to be able to clean up that smear, but it won't allow me the square brackets. when I select what type is the dataframe I get pandas.core.frame.DataFrame. and when I only select the "registrants" column I get pandas.core.series.Series
I would like to have an idea of how to display that column in several others. Because I have more than 6000 thousand records that appear like this.
The output should be a dataframe like in the image
enter image description here
I've thought about using methods like explode or using split to cut it but it doesn't allow me to read the subscripts it generates later.
df = pd.DataFrame(union['registrants']).explode('custom_questions').reset_index(drop=True)

pe= pd.json_normalize(json.loads(ap.explode("custom_questions").to_json(orient="records")))

I would really appreciate anyone who could help me or give me a guide.
These are some records that I get from the txt file
300 6139 4D1YdjmRScmpymp "{'id': '6ciHOSm4Rw', 'first_name': 'yumi', 'last_name': 'napanga', 'email': 'yu@hotmail.com', 'address': '', 'city': '', 'country': 'PE', 'zip': '', 'state': '', 'phone': '', 'industry': '', 'org': '', 'job_title': '', 'purchasing_time_frame': '', 'role_in_purchase_process': '', 'no_of_employees': '', 'comments': '', 'custom_questions': [{'title': 'Departamento/ Región', 'value': 'Lima'}, {'title': 'Género', 'value': 'Femenino'}, {'title': 'Edad', 'value': 'De 18 a 35 años'}, {'title': 'Nivel de estudio', 'value': 'Secundaria'}], 'status': 'approved', 'create_time': '2022-11-24T19:57:18Z'}"
300 6139 4D1YdjmRScmpy "{'id': 'DgyhfejIug', 'first_name': 'Artur', 'last_name': '', 'email': 'ads@gmail.com', 'address': '', 'city': '', 'country': 'CL', 'zip': '', 'state': '', 'phone': '', 'industry': '', 'org': '', 'job_title': '', 'purchasing_time_frame': '', 'role_in_purchase_process': '', 'no_of_employees': '', 'comments': '', 'custom_questions': [{'title': 'Departamento/ Región', 'value': 'CL'}, {'title': 'Género', 'value': 'Masculino'}, {'title': 'Edad', 'value': 'De 18 a 35 años'}, {'title': 'Nivel de estudio', 'value': 'Técnico / Superior'}], 'status': 'approved', 'create_time': '2022-11-24T17:22:44Z'}"

A: This should do the trick - assuming df is your input dataframe:
import json

df["Registrant_formatted"] = df["Registrant"].str.replace("'", "\"").apply(json.loads)

Then you can navigate through the json using str handler - for example
>>> df["Registrant_formatted"].str["custom_questions"].str[0].str["title"]
0    Departamento/ Región
Name: Registrant_formatted, dtype: object

A: you can use:
import ast
df['registrants']=df['registrants'].apply(ast.literal_eval)# to avoid getting this error: JSONDecodeError: Expecting property name enclosed in double quotes

df = df.join(pd.json_normalize(df['registrants'])) #normalize registrants column
dfx = pd.json_normalize(df.pop('registrants'),record_path=['custom_questions']).set_index('title').T.reset_index(drop=True) #custom questions column. Convert questions to column.
final = df.drop(['custom_questions'],axis=1).join(dfx)
print(final)
'''
|    |   page_size |   total_records | next_page_token   | id      | first_name   | last_name   | email        | address   | city   | country   | zip   | state   | phone   | industry   | org   | job_title   | purchasing_time_frame   | role_in_purchase_process   | no_of_employees   | comments   | status   | create_time          | Departamento/ Región   | Género    | Edad            | Nivel de estudio   |
|---:|------------:|----------------:|:------------------|:--------|:-------------|:------------|:-------------|:----------|:-------|:----------|:------|:--------|:--------|:-----------|:------|:------------|:------------------------|:---------------------------|:------------------|:-----------|:---------|:---------------------|:-----------------------|:----------|:----------------|:-------------------|
|  0 |         300 |            6139 | 4D1YdjmRScmpymp   | DvJh6zm | Artur        |             | ad@gmail.com |           |        | CL        |       |         |         |            |       |             |                         |                            |                   |            | approved | 2022-11-24T17:22:44Z | Colombia               | Masculino | De 18 a 35 años | Universitario      |
'''


text:
Q: Cant login to this Expense Manager found In GitHub I was searching for an expense manager that handles income and expense of my shop finally I got one from the GitHub but I imported the database and I installed it in the local server but when I try to log in I cannot login to the system, Even I try to change the code in user login session some way I just logged in by disabling a method in profile function on user controller but after login I can only see the account and about section this is the gitHub link of that project
is there anyone that used this code from GitHub or fixed the error?? of login please help
this is the image of expense manager while I logged in
Anyone, please help!!

A: https://github.com/web-project-builder/expense-management-codeigniter-adminlte-php/issues
This is the best place to find answers about this software.
Edit the index.php file found in the ExpenseManager software's root directory and place session_start(); at the top, inside the <?php tag, before the comments, just like this:
<?php
session_start();

Also see this Evernote entry, as it may help you with what is happening for you:
HOWTO Fix Expense Management CodeIgniter PHP from Github


text:
Q: SQLite3 syntax error when trying to update to a specific record. How do I give command both to choose the record and update the values? Here is a functioning block of code that illustrates my database.
Problems arise with trying to edit a record using UPDATE with data in a list.  I can create records from a list, but that doesn't include the 'WHERE oid = ? ' command to select which record to update.
import sqlite3

oid = 1

inpts = list()
inpts.append('Breadname')
inpts.append('33')
inpts.append('Flour')
inpts.append('Mix and Bake!')

edits = list()
edits.append('Brodname')
edits.append('25')
edits.append('Flower')
edits.append('Mix a lot and Bake!')

def make_SQL():          # create SQL file and a table named 'brods'
    conn = sqlite3.connect('formulas.sqlite')
    cur = conn.cursor()
    cur.execute("""CREATE TABLE IF NOT EXISTS brods
    (fname TEXT, msr1 TEXT, ngr1 TEXT, notes TEXT)""")
    conn.commit()
    conn.close()

def fill_SQL(inpts):
    conn = sqlite3.connect('formulas.sqlite')
    cur = conn.cursor()
    cur.execute("""INSERT INTO brods
    (fname, msr1, ngr1, notes)
    VALUES (?,?,?,?)""",(inpts))
    conn.commit()

def save_edits_SQL(edits,oid):
    conn = sqlite3.connect('formulas.sqlite')
    cur = conn.cursor()
    cur.execute("""UPDATE brods
    (fname, msr1, ngr1, notes)
    VALUES (?,?,?,?) WHERE oid = ? """,(edits,oid))
    conn.commit()

def get_formula(oid):
    f_data = ()
    conn = sqlite3.connect('formulas.sqlite')
    cur = conn.cursor()
    cur.execute('SELECT * FROM brods WHERE oid = ?', (oid,))
    conn.commit()
    for row in cur:
        f_data = row
    conn.commit()
    conn.close()
    print('fdata',f_data)
    conn.close()
    return (f_data)

make_SQL()
fill_SQL(inpts)
save_edits_SQL(edits,oid)
get_formula(1)

running save_edits_SQL produces the following error message:
Traceback (most recent call last):
  File "/Users/patrickscott/PycharmProject/PY4EveryoneTutorial/Ch 3 Conditional Execution/Bakers Formulas/sandbox.py", line 62, in <module>
    save_edits_SQL(edits,oid)
  File "/Users/patrickscott/PycharmProject/PY4EveryoneTutorial/Ch 3 Conditional Execution/Bakers Formulas/sandbox.py", line 40, in save_edits_SQL
    cur.execute("""UPDATE brods
sqlite3.OperationalError: near "(": syntax error

A: That's not how update statements work.
You need to use SET, e.g something like this:
cur.execute("""UPDATE brods
               SET fname = ?,
                   msr1 = ?,
                   ngr1 = ?,
                   notes = ?
               WHERE oid = ?""",
            (*edits, oid))

or
cur.execute("""UPDATE brods
               SET (fname, msr1, ngr1, notes) = (?, ?, ?, ?)
               WHERE oid = ?""",
            (*edits, oid))

I also changed (edits, oid) to (*edits, oid) here to make sure we get a flat tuple instead of a nested one. You could use edits + [oid] instead if you prefer.
Compare:
>>> ((1, 2, 3), 4)
((1, 2, 3), 4)
>>>
>>> (*(1, 2, 3), 4)
(1, 2, 3, 4)
>>>
>>> [1, 2, 3] + [4]
[1, 2, 3, 4]


text:
Q: Mass criteria query I have an Access query. I need a mass 'like' criteria.
Normally it's "Like "Apple" or "Orange"". However, I have over 400 words.
How do make this happen without manually typing in a Like formula by hand with the 400 words?
Is there a way to do this by referencing a table or form?

A: As for "referencing a table", you can actually do a join using LIKE instead of =.
SELECT
  t.*
FROM
  target t
INNER JOIN
  SearchList s
ON t.name LIKE '%' + s.term '%'

In this case, SearchList is a table you create just for this task with just 1 column containing the terms you want to search for.

A: You can use in clause , sub query to get result, the query in Access can have 64000 characters so your 400 words X 5 chars in each approximate , 2000 chars + 50 chars SQL statement, should be OK,
Select * from tblVitalInfo where ObjectName in ('Apple','Banana','Pitch')
But I will recommend following better way of doing same,

*

*Assume the table tblVitalInfo(ID, ObjectName) , and searching ObjectName

I would create a table tblWordList(ID autonumber primary key, SearchString Text(200)) . Write Insert statement to add all the words to search e.g. Insert into tblWordList(SearchString) values('Apple') ; execute these queries in Access. OR you can open the table to add data  , easier than insert statement.

*Run the following query
Select  * from tblVitalInfo where ObjectName in (Select SearchString tblWordList)


text:
Q: How to install GStreamer plugin having "MPEG-2 Transport Stream demuxer" element on windows I have installed GStreamer on windows using .msi files from the following link -
gstreamer-1.0-x86-1.2.0.msi
and
gstreamer-1.0-devel-x86-1.2.0.msi

I can run the following command and play .webm video files without any problem.gst-launch-1.0 playbin uri="file:///D:/gstreamer_sample_media/sintel_trailer-480p.webm"
But when I try to play a test .mts file using the following command:
gst-launch-1.0 playbin uri="file:///D:/MyTestMedia/Test1.mts"

The following error comes out:
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Missing element: MPEG-2 Transport Stream demuxer
WARNING: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: No dec
oder available for type 'video/mpegts, systemstream=(boolean)true, packetsize=(i
nt)192'.
Additional debug info:
gsturidecodebin.c(930): unknown_type_cb (): /GstPlayBin:playbin0/GstURIDecodeBin
:uridecodebin0
ERROR: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecode
Bin:decodebin0: Your GStreamer installation is missing a plug-in.
Additional debug info:
gstdecodebin2.c(3896): gst_decode_bin_expose (): /GstPlayBin:playbin0/GstURIDeco
deBin:uridecodebin0/GstDecodeBin:decodebin0:
no suitable plugins found
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

I know that to be able to play .mts file I have to install gst-plugins-bad-1.2.0 plugins and have missing "MPEG-2 Transport Stream demuxer" element.
The problem is I don't know how to do it in windows 7 or windows 8 OS (32 or 64 bit versions).
I downloaded the following files
gst-plugins-base-1.2.0,
gst-plugins-good-1.2.0,
gst-plugins-bad-1.2.0,
gst-plugins-ugly-1.2.0.
But the precompiled .dll files for windows were not inside them. Also I tried to compile them for windows, but just was able to do so for some projects in gst-plugins-base and it seems compiling gst-plugins-bad requires a lot of effort and I was unable to do so by now.
Is there any link to download pre-build .dlls of gst-plugins-bad for windows? And if we download them where they has to be copied so that gst-launch-1.0.exe can recognize them? Are they just need to be copied in E:\gstreamer\1.0\x86\bin where gstreamer is installed?
Thank you in advance.

A: You probably did a 'typical' install of the gstreamer SDK.
Reinstall and make sure you select the 'complete' features before installing. This should include the gst-plugins-bad packages.

A: Have you considered using gstreamer-sdk? It can be found on GStreamer.com. The official releases are 0.10 only, but you can easily find builds for 1.x on the mailing lists: here for 1.2


text:
Q: KafkaStreams multiple streams in same application I'm trying to make a practical design decision based on convention and plausibility with KafkaStreams.
Let's say that I have two different events that I want to place into KTables. I have a producer sending these messages to a KStream that is listening to that topic.
From what I can tell I cannot use conditional forwarding for messages using KafkaStreams, so if the stream is subscribe to many topics (one for each of the above messages, for example) I can only call stream.to on a single sink topic - otherwise, I would have to do something like call foreach on the stream and send messages with a KProducer to the sink topics.
The above suggests using a single stream. I thought I could set up multiple streams in the same app, each listening to a topic, mapping and forwarding to a table sink, but everytime I try to create two instances of KafkaStreams, only the first initialized subscribes to its topic - the other gets a warning from the client that its topic has no subscriptions.
Can I set up multiple streams in the same app? If so, are there any special requirements?
    class Stream(topic: String) {
      val props: Option[Map[String, String]] = Some(TopicProps.get(topic))
      val streamsBuilder = new StreamsBuilder
      val topics = new util.ArrayList[String]
      topics.add(props.get("topic"))

      val stream: KStream[String, String] = configureStream(streamsBuilder, topics, props.get("sink"))

      def configureStream(builder: StreamsBuilder, topics: java.util.List[String], sink: String): KStream[String, String] = {
        builder.stream[String, String](
          topics,
          Consumed.`with`(String(), String())
        )
      }

      def init(): KafkaStreams = {
        val streams = new KafkaStreams(streamsBuilder.build(), KafkaConfig.streamConfig)

        streams.start()

        streams
      }
    }

    class Streams() {

      val eventStream = new Stream("first_event") //looking good!
      val eventStream2 = new Stream("second_event") // no subscribers
      //if I switch the other of these, eventStream2 is subscribed to and eventStream is dead in the water
      val streams: KafkaStreams = eventStream.init()
      val streams2: KafkaStreams = eventStream2.init()

    }

stream config
    val streamConfig: Properties = {
        val properties = new Properties()
        properties.put(StreamsConfig.APPLICATION_ID_CONFIG, "stream-application")
        properties.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, BrokerHost)
        properties
    }

I'd also love any alternatives suggested

A: When you are creating your KafkaStreams you need to pass property with different application.id, for example:
    props.put(StreamsConfig.APPLICATION_ID_CONFIG,"APP1");
    StreamsBuilder builder = new SteamsBuilder();
    KStream stream1 = builder.stream("topic1");
    KafkaStreams streams = new KafkaStreams(builder, props);
    streams.start();

And then you should create another stream:
    props.put(StreamsConfig.APPLICATION_ID_CONFIG,"APP2");
    StreamsBuilder builder = new SteamsBuilder();
    KStream stream2 = builder.stream("topic2");
    KafkaStreams streams2 = new KafkaStreams(builder, props);
    streams2.start();

A:
From what I can tell I cannot use conditional forwarding for messages

Do you know about KStream#split() (KStream#branch() in order versions)? It basically the same as conditional forwarding.

I thought I could set up multiple streams in the same app, each listening to a topic, mapping and forwarding to a table sink,

This should work as follows:
StreamsBuilder builder = new SteamsBuilder();
KStream stream1 = builder.stream("topic1");
KStream stream2 = builder.stream("topic2");

stream1.to("table1-topic");
stream2.to("table2-topic");

but everytime I try to create two instances of KafkaStreams, only the first initialized subscribes to its topic - the other gets a warning from the client that its topic has no subscriptions.

Not sure. This should work. Maybe you can share your code?


text:
Q: Custom extended dijit/_TemplatedMixin throws "Invalid template Error" Here is a simplified example of what I am trying to do:
https://jsfiddle.net/1c5qpke9/2/
require([
  'dojo/_base/declare',
  'dijit/_WidgetBase',
  'dijit/_TemplatedMixin',
  'dojo/domReady!'
], function(declare, _WidgetBase, _TemplatedMixin) {

    var _CustomTemplatedMixin = declare([_TemplatedMixin], {

    _stringRepl: function() {
      console.log('_stringRepl');
      this.inherited(arguments);
    },

    _fillContent: function() {
      console.log('buildRendering');
      this.inherited(arguments);
    }

  });

  var CustomWidget = declare([_WidgetBase, _CustomTemplatedMixin], {

    templateString: '
Custom Widget "${testName}"
',
    testName: 'TestName'

  });

  new CustomWidget({}, 'MyWidget');

});

If I execute this, I get the following error:

Error: Invalid template: Custom Widget
  "${testName}"

When I use _TemplatedMixin instead of _CustomTemplatedMixin in my CustomWidget Class. It works without errors.

A: That is because _stringRepl returns a value, since you are subclassing it it should also return a value so return the inheritance value
ex.
  _stringRepl: function() {
  console.log('_stringRepl');
  return this.inherited(arguments);
},


text:
Q: Display grid is stretching the height of the children elements to fill the screen when their is no new data I'm working with display grid in my app. If the data doesn't fill the grid, the items are square - which is how I want it to work. However, when there are enough rows and columns to reach the data length, the grid items become vertically stretched to fill 100% of the component height.
I've looked into this problem and I can't figure it out. I tried adding padding-top: 100% to the child divs that the grid is positioning. I've also tried applying aspect-ratio: 1/1 to the child divs. Neither of these worked.
I'll share my code for this part of the app below, if anyone could help, I'd really appreciate it.
Styled component containing display: grid:
const StyledAlbums = styled.div`
  height: calc(100% - 5rem);
  width: calc(100% - 8rem);
  margin: 1rem 4rem;
  h3 {
    font-size: 1.6rem;
  }

  // grid things
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  grid-column-gap: 8rem;
  grid-row-gap: 8rem;

Child div display: grid is positioning
const StyledRecord = styled.div`
  height: 100%;
  width: 100%;
  aspect-ratio: 1/1;
  img {
    border-radius: 1rem;
    height: 100%;
    width: 100%;
    object-fit: cover;
  }

// this is positioned below the div
  h3 {
    margin-top: 0.5rem;
    font-size: 1.6rem;
    font-weight: 500;
    letter-spacing: 0.63%;
    color: ${(props) => (props.theme === "light" ? "#343434" : "white")};
  }
`;

JSX returning the parent and children elements
  return (
<StyledAlbums
  screenHeight={screenHeight}
  screenWidth={screenWidth}
  rowCountOne={rowCountOne}
  rowCount={rowCount}
  ref={albumsRef}
>
  {albumData.map((album) => (
    <Record
      key={album.id}
      mainImg={album.album_photo}
      title={album.album_name}
    />
  ))}
</StyledAlbums>
);

Thanks.

A: I removed the defined height, and this fixed it!


text:
Q: How to change a value in a dataframe using multiple conditions with loc? I want to change a value from a row/column of a dataframe as follows:
Within the interval, when it found a value which is different equal to 1, then it should put 2.
The example:
initial df:
index                      event
2019-12-07 18:30:16         0
2019-12-07 19:30:16         0
2019-12-07 20:30:16         0
2019-12-07 21:30:16         0
2019-12-07 22:30:16         1

wanted df:
index                      event
2019-12-07 18:30:16         0
2019-12-07 19:30:16         0
2019-12-07 20:30:16         0
2019-12-07 21:30:16         0
2019-12-07 22:30:16         2

The following code works but I cannot change the value:
mask = (df.index > start_dates) & (df.index <= end_dates)

for k in range (0, len(df.loc[mask])):
    if df.loc[mask].event[k] == 1:
        df.loc[mask].loc[df.loc[mask].event == 1, "event"] = 2

I cannot change the value from 1 to 2 in the last line of code.
I also tried this...:
df.loc[mask].loc[df.loc[mask].event == 1, "event"] = 2
df.loc[mask].event[df.loc[mask].event == '1'] = 2
df.loc[mask].event[k] = 2

But none of the above lines works.
Please help me. :( Any help is highly appreciated!

A: The three lines you tried at the end are what pandas calls "chained loc calls", which will fail every time if you want to use them to assign new values. One .loc is enough for what you want
df.loc[mask] = 2
 # or
df.loc[mask, :] = 2
# both will assign two to all columns if you have more

# or also
df.loc[mask, 'event'] = 2

There is no need for the loop, .loc will select the rows you want with the boolean mask.
Edit
You can include a third condition to your mask
mask = (df.index > start_dates) & (df.index <= end_dates) & (df.event ==1)

Or leave your mask as it is and combine the conditions inside .loc
df.loc[mask & (df.event ==1), 'event'] = 2

A: Maybe you want to try this:
Lets say you have a dataframe like this:
df = pd.DataFrame(data={"index":[1,2,3,4], "val":[0,0,1,0],"event":[0,0,0,0]})

And you want to increase the val value, when val is 1. Then you just simply do:
df.loc[df['val'] == 1, 'val'] = 2


text:
Q: how to echo tab delimited in csh script I have a csh script and no matter what I do it never echoes the right tab space.
This is what i want:
header 1    header 2    header 3    header 4

Case 1:
echo header 1 header 2 header 3 header 4 | tabify

Output: It will replace all spaces to tab
Case 2:
echo "header 1\\theader 2\\theader 3\\theader 4"

or
echo header 1\\theader 2\\theader 3\\theader 4

Output: header 1\\theader 2\\theader 3\\theader 4
Case 3:
echo -e "header 1\\theader 2\\theader 3\\theader 4"

Output: -e header 1\\theader 2\\theader 3\\theader 4
Help? T.T

A: CShell sucks, but printf will save the day once more.
$ printf 'header 1\theader 2\theader 3\n'
header 1    header 2    header 3

(Please ignore Stack Overflow's inability to show tabs)


text:
Q: how to get just first image on laravel i already tried (i tried) (Laravel 5.2 - show first image from database)
but i got value "rumahnya= n  rumahnya= t  rumahnya= I" on photo_rumah
controller
public function index()
    {
        //
        $data   = $this->dataRumah();
        // dd($data);
        return view('panelD.data_rumah',[
            'data' => $data,
        ]);
    }
    // get data
    public function dataRumah(){
        $data = DB::table('datarumah')->get();
        foreach($data as $keys => $value){
            $photoRumah = DB::table('photorumah')->where('id_rumah', '=', $value->id_rumah)->get();
            $value->DataPhoto   = $photoRumah;
        }
        return $data;
    }

blade

     photo_rumah[0])}}" alt="">
       //when i echo i just got value "rumahnya= n  rumahnya= t  rumahnya= I" on photo_rumah


text:
Q: Confusion with gradient and divergence of vector fields and scalar fields In a proof, my teacher used the following assumption for an approximation:
$$
|\nabla n(\boldsymbol{r}, t)| \ll\left|\nabla \partial_{t} \boldsymbol{\tilde{r}}(\boldsymbol{r}, t)\right|
$$
where $n$ denotes electron density and $\tilde{\boldsymbol{r}}=\boldsymbol{r}_{0} e^{i \boldsymbol{k} r-i \omega t}$ is the temporal derivative of electron position. However, since $n$ is a scalar quantity (for each $\mathbf{r},t$) it is a scalar field. The gradient of a scalar field is undefined. I then thought he might mean the divergence. But the divergence of a scalar field is a vector field, while the gradient of a vector field (right-hand side of the equation) is a tensor quantity. How can the equation above ever make sense when $n$ is a scalar field and $\boldsymbol{\tilde{r}}$ a vector field?


text:
Q: Solving a system of four non-linear differential equation Could someone help me with my problem? I've been scratching my head over this for a day now. I can't write the right code to solve this non-linear differential equation system:
x1'[t] = (2 x2^2 Cos[(2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))])[t]] +
x1 (-1 + x1^2 + x2^2 -
   2 x2 Sin[(2 n \[Pi] -
        2 ArcTan[(-2 psi2 x1 x2 +
           Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
              x2^2)^2] +
           psi1 (x1^4 + x2^2 + x2^4 +
              x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 +
              x2^2) +
           psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
              x2^2))])[t]]))/(1 + x1^2 + x2^2 -
2 x1 Cos[(2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))])[t]] -
2 x2 Sin[(2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))])[t]])
x2'[t] = (x2 (-1 + x1^2 + x2^2 -
   2 x1 Cos[(2 n \[Pi] -
        2 ArcTan[(-2 psi2 x1 x2 +
           Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
              x2^2)^2] +
           psi1 (x1^4 + x2^2 + x2^4 +
              x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 +
              x2^2) +
           psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
              x2^2))])[t]]) +
2 x1^2 Sin[(2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))])[t]])/(1 + x1^2 + x2^2 -
2 x1 Cos[(2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))])[t]] -
2 x2 Sin[(2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))])[t]])
psi1'[t] - ((psi1 (-1 + x1^4 + 4 x2^2 + x2^4 + 2 x1^2 (2 + x2^2)) +
 4 psi2 x1 x2 Cos[
   2 t[2 n \[Pi] -
      2 ArcTan[(-2 psi2 x1 x2 +
         Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
            x2^2)^2] +
         psi1 (x1^4 + x2^2 + x2^4 +
            x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
         psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
            x2^2))]]] +
 4 (psi2 x1 - psi1 x2 (x1^2 + x2^2)) Sin[
   t[2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))]]] -
 4 Cos[t[2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))]]] (psi2 x2 + psi1 x1 (x1^2 + x2^2) +
    psi2 (x1 - x2) (x1 + x2) Sin[
      t[2 n \[Pi] -
        2 ArcTan[(-2 psi2 x1 x2 +
           Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
              x2^2)^2] +
           psi1 (x1^4 + x2^2 + x2^4 +
              x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 +
              x2^2) +
           psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
              x2^2))]]]))/(1 + x1^2 + x2^2 -
 2 x1 Cos[
   t[2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))]]] -
 2 x2 Sin[
   t[2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))]]])^2)
psi2'[t] = (-psi2 (-1 + x1^4 + 4 x2^2 + x2^4 + 2 x1^2 (2 + x2^2)) +
4 (-psi1 x2 + psi2 x1 (x1^2 + x2^2)) Cos[
  t[2 n \[Pi] -
    2 ArcTan[(-2 psi2 x1 x2 +
       Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
          x2^2)^2] +
       psi1 (x1^4 + x2^2 + x2^4 +
          x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
       psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
          x2^2))]]] +
4 psi1 x1 x2 Cos[
  2 t[2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))]]] +
4 (psi1 x1 + psi2 x2 (x1^2 + x2^2)) Sin[
  t[2 n \[Pi] -
    2 ArcTan[(-2 psi2 x1 x2 +
       Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
          x2^2)^2] +
       psi1 (x1^4 + x2^2 + x2^4 +
          x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
       psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
          x2^2))]]] -
2 psi1 (x1 - x2) (x1 + x2) Sin[
  2 t[2 n \[Pi] -
     2 ArcTan[(-2 psi2 x1 x2 +
        Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
           x2^2)^2] +
        psi1 (x1^4 + x2^2 + x2^4 +
           x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
        psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
           x2^2))]]])/(1 + x1^2 + x2^2 -
2 x1 Cos[
  t[2 n \[Pi] -
    2 ArcTan[(-2 psi2 x1 x2 +
       Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
          x2^2)^2] +
       psi1 (x1^4 + x2^2 + x2^4 +
          x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
       psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
          x2^2))]]] -
2 x2 Sin[
  t[2 n \[Pi] -
    2 ArcTan[(-2 psi2 x1 x2 +
       Sqrt[(psi1^2 + psi2^2) (-1 + x1^2 + x2^2)^2 (x1^2 +
          x2^2)^2] +
       psi1 (x1^4 + x2^2 + x2^4 +
          x1^2 (-1 + 2 x2^2)))/(-2 psi1 x2 (x1 + x1^2 + x2^2) +
       psi2 (x1 + x1^2 + (-1 + x2) x2) (x1 + x1^2 + x2 +
          x2^2))]]])^2

I need to find x1 and x2. Initial conditions is: x1(0)=0.8, x2(0) = 0, psi1(0)=1, psi2(0) = tau (-inf < tau < +inf). Also I need to plotting a graphic of this solutions. All my attempts to use DSolve/NDSolve have failed, my computer calculates these solutions and a half hours and eventually gives errors. Hope the community can help.


text:
Q: How to solve ERROR_USER_NOT_FOUND Unable to login or register
i tried to remove firebaseuser and changed to authresulths
  Future<String> SignIn(String email, String password) async{
    FirebaseUser user = (await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password)) as FirebaseUser;
    return user.uid;
  }
  Future<String> SignUp(String email, String password) async{
    FirebaseUser user = (await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password)) as FirebaseUser;
    return user.uid;
  }

flutter (31902): Error = PlatformException(ERROR_USER_NOT_FOUND, There is no user record corresponding to this identifier. The user may have been deleted., null)

A: Your SignUp method is calling the wrong API. It should call createUserWithEmailAndPassword, so:
Future<String> SignUp(String email, String password) async{
  AuthResult result = (await _firebaseAuth.createUserWithEmailAndPassword(email: email, password: password)) as AuthResult;
  return result.user.uid;
}


text:
Q: Passing arguments to a .NET exe file with _spawnv I am working with a software that uses the _spawnv and _spawnve functions to call other exe files. Now this works correctly if I call a C or C++ exe file, but when I try to call a .NET exe file (C#)  I always miss the first argument that I have passed to the exe file, as an example if I send these arguments
1.1.1.1, 20, i@domain.com, yes, no
in the .NET app it will log the arguments as
20, i@domain.com, yes, no
and I get an FormatException because of the email string. Now I can just add a dummy argument, but since I do not understand why this is happening I would rather not do it.
So the question is why am I missing the first argument in the .NET application.
cheers,
es


text:
Q: Getting occasional "Failed to validate a newly established connection" SQL Exception on a Spring JDBCTemplate in TomEE I have a small Spring (4.3.5) app running in TomEE (7.0.1), talking to an Oracle (11) db.
I have a single DAO class that can run two different queries.
I have two query processor tasks running these queries, on a scheduler, one every two minutes, one every three minutes.  When I first saw the problem I'm going to describe, I had a single scheduled task running both queries.
Both queries are similar, just returning different columns and aggregates on the same table.  The two queries are assembled in code, but they aren't really dynamic.  The components are relatively static.  I've verified that both queries are fine by running in the debugger and pasting the generated query into my SQL browser, and they both work fine.
When I start up the app, I get results from both queries a couple of times.  Then, I started to see the following in the log:
Jan 19, 2017 9:21:05 AM org.apache.tomcat.jdbc.pool.PooledConnection validate
WARNING: SQL Validation error
java.lang.NullPointerException
    at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:973)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1041)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
    at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
    at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
    at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
    at org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:509)
    at org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:443)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.testAllIdle(ConnectionPool.java:1049)
    at org.apache.tomcat.jdbc.pool.ConnectionPool$PoolCleaner.run(ConnectionPool.java:1371)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

Jan 19, 2017 9:21:05 AM org.apache.tomcat.jdbc.pool.PooledConnection validate
WARNING: SQL Validation error
java.sql.SQLException: Invalid SQL type: sqlKind = UNINITIALIZED
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:63)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
    at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
    at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
    at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
    at org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:509)
    at org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:443)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.testAllIdle(ConnectionPool.java:1049)
    at org.apache.tomcat.jdbc.pool.ConnectionPool$PoolCleaner.run(ConnectionPool.java:1371)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

This is clearly in pool validation, not in running my query.
My Datasource in tomee.xml looks like this:
      <Resource id="tst36" type="DataSource">
        testOnBorrow = true
        testOnReturn = true
        testWhileIdle = true
        logValidationErrors = true
        validationQuery = "select 1 from dual"
        JdbcDriver = oracle.jdbc.OracleDriver
        MaxActive = 10
        MinIdle = 2
        MaxIdle = 2
        MaxWait = 10000
        JdbcUrl = jdbc:...
        UserName = ...
        Password = ...
  </Resource>

What can I do here?

A: are you sure
validationQuery = "select 1 from dual"

is what you meant? Isn't it
validationQuery = select 1 from dual


text:
Q: How to detect real invoker's name in procedure defined with SQL SECURITY DEFINER characteristic in MySQL? In simplification, I have a MySQL procedure get_data(), which selects filtered data for users. Customized filter conditions are stored in database table. Procedure get_data() should gets conditions for current user and select only his data by adding a WHERE clause.
But when I defined procedure with SQL SECURITY DEFINER characteristic, detection current user (invoker) in procedure body is not possible because function current_user() returns definer's name, and when I defined procedure with SQL SECURITY INVOKER characteristic, the procedure failed because invoker haven't SELECT privileges on source table.
Is it possible to create a procedure in MySQL, which selects customized data for user from table not accessible for user?
Currently, I have defined views (one for each user), but the maintenance of this in a situation where conditions in queries are constantly changing is hard.

A: Have you tried using user() instead of current_user()?


text:
Q: How to keep the request header when Location header parameter is defined? I have a PHP script in my server that redirects the page using Location: $url entry in header.
But, the request header is not being transmitted to $url.
I see a minimum header defined with User-Agent, Connection, etc.
Let's suppose that I customize some header parameters. I would like to transmit them after redirection.
Is it possible? I would not like to use CURL for that.

A: This would be up to your HTTP client (web browser or API client?) not your web server. The request headers are, hint, the responsibility of the HTTP client. Your HTTP response with the Location header is the equivalent of your server strongly suggesting the HTTP client try again to the new location.
If you're using cURL, you can use the -L param, as in the following example:
$ curl -L [url]

This tells cURL to follow redirects, and there's a good write up of its usage on this blog post.


text:
Q: pouchDB distinct where column is I need equivalent of select distinct(toc.content) from table where acModel='7X';
Here is my Document -
{
    acModel : "7X",
    relYear : 2014,
    optId : 11046,
    optNum : "2.386.ADW0",
    content : "Interior",
    cutInFrom : 253,
    cutInTo : 9999,
    weight : "Standard"
}

Here are the javascript functions -
createIndex: function () {
    this.createDesignDoc('by_acModel', function (doc) {
        emit(doc.acModel, doc.content);
    });
},
getDistinctContent: function(acModel){
    var result=[];
    function map(opt) {
        emit(opt.acModel, {content: content});
    }
    this.db.query(map,
        function (err, response) {
            for (var i = 0; i < response.total_rows; ++i) {
                if (response.rows[i].key == acModel) {
                     //Over here I am not sure ... Short of handling it manually, I don't know if I can get pouchDB to give distinct
                }
            }
    });
},
createDesignDoc: function(name, mapFunction) {
    var ddoc = {
        _id: '_design/' + name,
        views: {
        }
    };
    ddoc.views[name] = { map: mapFunction.toString() };
    return ddoc;
}
};

A: You could use _count as your design doc's reducefunction, and then when you query with {reduce: true, group: true}, you will get each of the unique colBs as well as their counts.
var db = new PouchDB('mydb');

function createDesignDoc(name, mapFunction, reduceFunction) {
    var ddoc = {
        _id: '_design/' + name,
        views: {
        }
    };
    ddoc.views[name] = {
      map: mapFunction.toString(),
      reduceFunction: reduceFunction.toString()
    };
    return ddoc;
}

var ddoc = createDesignDoc(
  'myview',
  function (doc) { emit(doc.colB); },
  '_count')
);

return db.put(ddoc).catch(function (err) {
  if (err.status !== 409) { // 409 is conflict
    throw err;
  }
}).then(function () {
  return db.query('myview', {
    reduce: true,
    group: true
  });
});

You'll get something like:
{
  rows: [
    {
      key: 'foo',
      value: 3
    },
    {
      key: 'bar',
      value: 1
    },
  ]
}