text:
Q: Add  above submit button I currently have a small form where a user can select a series of files.  I have a submit button, and another button while creates another file element.  All I want to do is pop up each new file element above the submit button rather than below the submit button.  This is what I have thus far.

    <form action="<?php echo htmlspecialchars($_SERVER['PHP']);?>" method="post" enctype="multipart/form-data" name="upload_form" id="upload_form">

    <input type="file" name="file"/>
    <input type="button" onclick = 'javascript: add()' value="ADD ANOTHER FILE" />

    <input type="submit" id="submit" name="submit" value="SUBMIT" />
    </form>

Javascript:

A: You can use parentElement.insertBefore(newChild, existingChild):
This method will add the new elements above the "add button" instead of above the submit button like you specified.
HTML:
<input id="addbutton" type="button" onclick = 'javascript: add()' value="ADD ANOTHER FILE" />

Javascript:
    var form = document.getElementById("upload_form");
    var addButton = document.getElementById('addbutton');

    var br = document.createElement("br");
    form.insertBefore(br, addButton);

    form = document.getElementById("upload_form");

    input = document.createElement("input");
    input.type="file";
    input.name="file[]";
    form.insertBefore(input, addButton);

It looks like your form may have a few layout problems. It is also probably best not to use
 but instead a wrapper element for each row with CSS styling.  That way you can also only use insertBefore once (for the wrapper) and it is less confusing.
Also, if you aren't aware of it you should look into jQuery. This kind of DOM manipulation is once of its primary strengths.

A: You can use insertBefore, it inserts a node as a child, right before an existing child, which you specify.
As you want to insert before submit button, use this code
form = document.getElementById("upload_form");
var foo = document.getElementById("submit");
form.insertBefore(br,foo);


text:
Q: One out of two times my app crashes and freezes at splash page I'm still in development with my app and each time I "run" the app it crashes one out of two times. When it crashes the app freezes on the splash page and this is the error I get:
http://d.pr/i/rHjY
Could it be something to do with the splash page? It's just so odd that the app crashes one out of two times. Anyone got any idea?

A: If you're using slightly older tools it might be related to this:
http://www.tuaw.com/2013/06/05/devjuice-10-8-4-and-the-ios-simulator/

The issue occurs to a process race condition for debugserver. Instead
  of using GDB, you can alternatively kill your execution, wait a few
  seconds for the app to wrap up, and then run the next iteration.

The quick fix:

Update your scheme by selecting Product > Scheme > Edit Scheme, and
  choose the GDB debugger for your debug scheme.

But really you ought to just update your tools.

A: My standart debugging workflow - If error origin is unknown - comment out everything in AppDelegate methods  - mainly in  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
and in these also, if You have anything there:
- (void)applicationWillResignActive:(UIApplication *)application

- (void)applicationDidEnterBackground:(UIApplication *)application

- (void)applicationWillEnterForeground:(UIApplication *)application

- (void)applicationDidBecomeActive:(UIApplication *)application

Then - if You don't encounter crashing anymore, then start uncommenting stuff. Once You find  a code line (or code block)  that crashes, then look deeper in that.
Good luck!

A: Add an exceptions breakpoint to see where in your code it is crashing: https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html

redpajama_set_name: RedPajamaStackExchange


text:
Q: What do you think happens when a child process executes a chdir - does this effect the parent? int chdir(const char *path);

-chdir changes the current directory to that specified in path.
if I use this command on child / Does this effect the parent ?
Please explain why (Yes/No) ?

A: The child and the parent are separate processes. For the most part, resources for the child are copied from the parent's resources when the child is created, so they are separate resources, not shared resources.
When starting, the system creates an initial process. That processes creates additional system processes, to manage the user interfaces, to provide network services, and so on. When you log in (which may be automatic), one of those processes creates a process to manage your login session, including the desktop. When you open applications, that login/session process (or something else it creates) creates an application process.
If, when a child changed its current directory, the parent's directory also changed, then the parent's parent's directory would change, and so would its parents, and then all the system processes back up the line would be using a different directory. That is not appropriate; they should not use a particular user's directory. Each process has its own purposes for having a particular current working directory.

A: In linux if you call fork() what happens is the child process just becomes a copy of the parents address space. After the new address space is set up, they are just separate processes. So when you call chdir in one process, it wont affect the other. Hope that was helpful in some way.


text:
Q: SUM area of intersecting polygon and circle. Google Maps Suppose I have the following overlays drawn on a google map. I would like to get the area covered by B + C.

My plan is to use google overlays computeArea() method to get the area of the polygon, and just use the formula for area of a circle but how do I account for their intersection? Is there a way to do this in the google maps api?


text:
Q: Can I "lock" code files in Visual Studio to avoid accidents (NOT source control locking) I have a lot of common JavaScipt code in the solution that works hand in hand with the rest of the solution. Most of the time I open these files, just to see their API (function signature, etc.) to call them from somewhere else in the solution.
As you know, IntelliSense doesn't do much for JavaScript, so I have to open the file to see the API and IntelliSense doesn't complain if I accidentally edit and break JavaScript code.
I have many times accidentally edited or pasted random code into such Javascript files, and I wouldn't realize the problem until the thing raises an error. There were times where the errors were so ambiguous and unclear I had to spend hours before finding the accident. The common JavaScript code is the last thing I'd look in for errors as they have been working error-free for long.
Is there a way to somehow "lock" (or make "read-only") source files in Visual Studio?
Please note this is not related to source control.

A: You can set write protection in the Windows file system for the files you want to protect. Then you are not able to save something via Visual Studio to these files.


text:
Q: lazysizes is not lazy loading image lazysizes seems to simple to use, but I can't get it to actually lazy load an image with react... it loads the bottom image thats out of the viewport before it's scrolled into view, as you can see in this minimal codesandbox example.
const id = Math.floor(Math.random() * 500);

<img
 style={{ width: 500, height: 500 }}
 src={`https://picsum.photos/id/${id}/20`}
 data-src={`https://picsum.photos/id/${id}/1000`}
 className="lazyload blur-up"
 alt=""
/>

.blur-up {
  -webkit-filter: blur(30px);
  filter: blur(30px);
  transition: filter 400ms, -webkit-filter 400ms;
}

.blur-up.lazyloaded {
  -webkit-filter: blur(0);
  filter: blur(0);
}

(this code is copied almost exactly from the lazysizes docs)
What am I doing wrong?


text:
Q: How to compile scss to css on npm start I am unable to compile scss files to css once the application is run using npm start. Is there a way to live reload a sass to css like ts are compiled to js by utility tsc:w.So I have to stop the build and then do gulp watch or node-sass command to compile scss to css and then build solution again using npm start. I tried below approaches but none worked.
Here is the code in package.json:
Using gulp watch:
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" \"gulp\" ",
//also tried gulp watch and that did not work too.
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" \"gulp watch\" ",

here is my gulppfile.js in the root directory:
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
  gulp.src('./sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});
gulp.task('watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});

Using node-sass command:
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" \"npm run sass\" ",
"sass": "node-sass -w app/sass/ -o app/css/",

Could anyone pls tell what I am missing or what is the right way to do it? TIA

A: The solution to this issue has been explained in other threads, see: How to compile scss to css with node-sass
However, here's my solution using the run-watch program, nodemon:
npm install node-sass nodemon --save-dev

In package.json, add these to your "scripts":
 "build-css": "node-sass --include-path scss src/input.scss src/styles.css",
 "watch-css": "nodemon -e scss -x \"npm run build-css\" "

Then, in your "start" script, use this:
 "start": "concurrently \"node app.js\" \"npm run watch-css\" "

Next, we need to install the concurrently package:
npm install concurrently --save

To compile and serve your files,
npm start

Therefore, the "npm start" command triggers a build that starts the app and concurrently calls the "run watch-css" command which in turn calls "build-css" to compile scss to css in real-time through nodemon. It compiles and refreshes live when you edit any scss in your text editor.

A: Running gulp will run the default task which you haven't included in your gulpfile. You need to add this
gulp.task('default', ['sass','watch']);

A: Without gulp
  "start": "tsc && concurrently \"tsc -w\" \"lite-server\"  \"npm run build-css\"",
  "build-css": "node-sass resources/css/sass/style.scss resources/css/style.css",


text:
Q: How can I validate Items or Maps in a List when using Firebase's Firestore? I cannot find a solution for validating the contents of Lists in firestore. Is there any solution for doing this?
I don't want to use a new collection as it doesn't make sense for such a small amount of data (and will end up costing many more reads than necessary, and is much more convenient to keep the data under the original document).
Storing a few image details per document:
[
  {
    "filename": "example.png",
    "author": "example",
    "caption": "...",
  },
  ...
]

or, storing a few tags per document:
[
  "tag text 1",
  "tag text 2",
  ...
]

How can I access each item (or loop through?) to validate them, so that in the first example with the images, it can be validated so (for example):

*

*each item is a map,

*filename is a string,

*author is a string,

*caption is a string of a particular length

Or, for the tags example,

*

*each item is a string of a particular length?

Or is there a better solution to storing this sort of data in a document without creating a new collection or subcollection?

A:
How can I access each item (or loop through?) to validate them.

If you're asking about doing this in server-side security rules, then you've precisely hit the nail on the head: there is no ability to loop in Firebase's server-side security rules. See the reference documentation for the operations that can be performed on a List in a document. This limits what can be accomplished in security rules, and as far as I can see none of the use-cases you mention can be implemented with just security rules.
The simplest approach I can think of is by using Cloud Functions to implement the logic. You could either have the Cloud Function inspect the documents in place in the current collection, or you can have the client write to a different collection (of "pending" documents), have the Cloud Function validate the document, and move it to the actual collection.


text:
Q: Sharing pygrib object in multiprocessing How can I share a pygrib object <pygrib._pygrib.open object at 0x2b50ed103a78> between processes. The code looks like
import multiprocessing
import numpy as np
import pygrib
manager = multiprocessing.Manager()
rn = manager.list()
def get_val(grb,vt):
    var = grb.select(name='Total precipitation',typeOfLevel='surface',validityTime=vt)[0]
    precip, lats, lons = var.data(lat1=45,lat2=50,lon1=5,lon2=15)
    rn.append(precip)
infile='file.grib'
grb = pygrib.open(infile)
vtime1=0;vtime2=600
p1 = multiprocessing.Process(target=get_val,args=(grb,vtime1))
p2 = multiprocessing.Process(target=get_val,args=(grb,vtime2))


text:
Q: Auto-complete or auto-suggest from stored data in database I developing plugin MLM.So i want all user name as suggestion in parent-name input form.
So how can i code it?
Which jquery included?
I add this code following
$query = isset($_GET['query']) ? $_GET['query'] : FALSE;
if ($query) {
// escape values passed to db to avoid sql-injection
$depts = $wpdb->get_results( "SELECT * FROM wp_mlm_info WHERE user_name LIKE '".$query."%' ORDER BY user_id ASC" );

$suggestions = array();
$data = array();
foreach($depts as $row) {
    $suggestions[] = $row->user_name;
    $data[] = $row->user_id;
}
$response = array(
    'query' => $query,
    'suggestions' => $suggestions,
    'data' => $data,
);
echo json_encode($response);

Adding following jquery
wp_enqueue_script('newscript',plugins_url( 'js/jquery-1.10.2.js' , __FILE__ ),array( 'jquery' ));
wp_enqueue_script('newscript',plugins_url( 'js/jquery-ui.js' , __FILE__ ),array( 'jquery' ));
wp_enqueue_script('newscript',plugins_url( 'js/jquery.min.js' , __FILE__ ),array( 'jquery' ));
wp_enqueue_script('newscript',plugins_url( 'https://www.devbridge.com/projects/autocomplete/jquery/local/scripts/jquery.autocomplete.js/' , __FILE__ ),array( 'jquery' ));

but not working autosearch or auto suggestion field.
Javascript
$(document).ready(function(){
    $('#parent_name').autocomplete({
        serviceUrl:'/',
        // callback function:
        onSelect: function(value, data){ alert('You selected: ' + value + ', ' + data); },
});

});

Can you please help me for this problem?

A: First off, you're not quite enqueuing the scripts correctly.
The first argument should be a unique name for that script (not all 'newscript').
Also, you're enqueuing jquery twice.
I'm not certain where you're storing your files, but at least the last path is incorrect.
Finally, the third argument is to let WordPress know if the script that you're enqueuing is dependent on another script. jQuery UI and jQuery Autocomplete are dependent on jQuery, so you have those ones correct. The others are not needed.
In addition, WordPress already has jQuery, so you don't need to enqueue another copy of it.
This should get you a little closer anyway:
wp_enqueue_script('jquery'); //Because it ships with WordPress
wp_enqueue_script('jquery-ui', get_template_directory_uri() . 'js/jquery-ui.js',array( 'jquery' ));
wp_enqueue_script('autocomplete', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.devbridge-autocomplete/1.2.26/jquery.autocomplete.js',array( 'jquery' ));

WordPress also ships with parts of jQuery UI and other helpful scripts. You can see the whole list and how to enqueue them here: https://developer.wordpress.org/reference/functions/wp_enqueue_script/


text:
Q: Share iTunes playlist with another computer (Different account) I want to share my playlist with my friend. He can give me his apple ID. I have a big playlist on my computer. I have not made any changes in the Preferences yet. Help appleseeds?

A: Drag the individual tracks to a USB key etc - this will initially lose the playlist data & only copy the tracks themselves.
To add an importable playlist to that, go to File > Library > Export Playlist, then save as M3U format & add to the USB key. Your friend can then add the entire playlist by dragging just the M3U file to his iTunes - the tracks will be copied in automatically.
Alternatively, you can export a playlist by burning to CD/DVD
Right click the playlist title & click Burn Playlist to Disk.
I'm not certain whether this will carry playlist information or just the tracks - it's been too long since I did it.
BTW - passing around AppleID information is really not recommended.
It's the way to lose control of your own devices, if ever used maliciously.


text:
Q: Export pie chart to powerpoint using c# i am trying to Export a pie chart to powerpoint slide uisng c# but not found any similar article which can help me...
please provide me some example or provide some useful link which can help me in achieving this functionality easily...
thanks,
Aman

A: we are using hipdf library but this is paid and we are converting html to image first and then showing this image on ppt slide. You can also do it by using inkscape exe file

A: In button_click event write following code.
GridView1.AllowPaging = false; //write this code only if paging is enabled.
GridView1.DataBind(); //write this code only if paging is enabled.

Response.Clear();

Response.AddHeader("content-disposition", "attachment;filename=FileName.ppt");//for text file write FileName.txt

Response.Charset = "";

// If you want the option to open the Excel file without saving than comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.ContentType = "application/vnd.ppt";\\for text file write vnd.txt

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();

GridView1.AllowPaging = true; //write this code only if paging is enabled.

GridView1.DataBind();//write this code only if paging is enabled.

You will have to override function of VerifyRenderingInServerForm like this
public override void VerifyRenderingInServerForm(Control control)
{
    //Keep it empty
}

And to avoid exception you have to set property of
<%@ Page Language="C#" EnableEventValidation="false" %>


text:
Q: forms showing in runtime as soon as they are created In runtime when the forms are being created, 2 forms constantly keep appearing when I haven't programmed them to show as soon as they are created, and my system runs. I was wondering why this happened and whether there is anything to solve this? I don't think I need to show my code here since it's pretty basic and there is none for the OnCreate event.

A: From the main menu, use Project->Options->Forms, and remove the forms you don't want to see from the Auto-create list. (Click the >> button to move them from the left side to the right side.)
(It's worth mentioning that you can also affect the order in which any autocreated forms or datamodules are created from that dialog by just dragging them up or down in the list. Note that the first form to be created becomes the application main form, so when it is closed the application will close as well; this means that the only thing above your main form in the autocreate list should be datamodule(s) that are accessed by the main form.)
If you never want any forms auto-created, go to Tools->Options->Environment Options->Form Designer, and uncheck the very last item labeled Auto create forms & data modules at the bottom. Note that your main form will always be auto-created, as it's what controls the application's lifetime for form based applications.

A: By default delphi creates all the forms in the beginning. You can open the .dpr file and delete the ones that you don't need. You could also do that from the UI.

A: For the forms that you don't want to appear at the start of runtime, go to the properties of the form (lower left hand side) and uncheck Visible. This should do the trick


text:
Q: Changing 1-3 random index(s) in a sequence to a random value I would also like the changed value to be random. For example
'(1 2 3 4 5)

one possible output.
'(1 3 3 4 5)

another
'(1 5 5 4 5)

A: there are more idiomatic ways to do this in clojure. For example this one:
you can generate infinite lazy sequence of random changes to the initial collection, and then just take a random item from it.
(defn random-changes [items limit]
  (rest (reductions #(assoc %1 (rand-int (count items)) %2)
                    (vec items)
                    (repeatedly #(rand-int limit)))))

in repl:
user> (take 5 (random-changes '(1 2 3 4 5 6 7 8) 100))
([1 2 3 4 5 64 7 8] [1 2 3 4 5 64 58 8] [1 2 3 4 5 64 58 80]
 [1 2 3 4 5 28 58 80] [1 2 3 71 5 28 58 80])

user> (nth (random-changes '(1 2 3 4 5 6 7 8) 100) 0)
[1 2 3 64 5 6 7 8]

and you can just take an item at the index you want (so it means collection with index + 1 changes).
user> (nth (random-changes '(1 2 3 4 5 6 7 8) 100) (rand-int 3))
[1 46 3 44 86 6 7 8]

or just use reduce to take the n times changed coll at once:
(defn random-changes [items limit changes-count]
  (reduce #(assoc %1 (rand-int (count items)) %2)
          (vec items)
          (repeatedly changes-count #(rand-int limit))))

in repl:
user> (random-changes [1 2 3 4 5 6] 100 3)
[27 2 33 4 76 6]

also you can just associate all the changes in a vector at once:
(assoc items 0 100 1 200 2 300), so you can do it like that:
(defn random-changes [items limit changes-count]
  (let [items (vec items)
        rands #(repeatedly changes-count (partial rand-int %))]
    (apply assoc items
           (interleave (rands (count items))
                       (rands limit)))))

in repl:
user> (random-changes [1 2 3 4 5 6] 100 3)
[1 65 61 44 5 6]

A: Figured it out. Decided to go a longer route and make a function.
(defn changeSequence
[sequ x]
(def transsequ (into [] sequ))
(if (> x 0)
(changeSequence (assoc transsequ (rand-int (count transsequ)) (rand-int foo)) (dec x))
(seq sequ)
))


text:
Q: Jogar variáveis para serem parâmetros na API Tenho um site e para entrar nele precisa logar, e os dados são: cpf e email. E tenho uma API que preciso jogar as variáveis cpf e email para serem parâmetros na api, porém não tenho muito conhecimento em api e também apenas tenho o link dela.
Preciso jogar esses dados pois cada usuário terá dados diferentes, e a api vai precisar desses dados no parâmetro para fazer um select e buscar dados da pessoa cadastrada com o cpf e email.
ex.: http://api/api/TRCKCLICODCPF=12345678901&EMAIL=fulano%40email.com
Consumindo API:
 function load(){

  var xhr = new XMLHttpRequest();
  xhr.open("GET", "http://api/api/TRCKCLICODCPF=12345678901&EMAIL=fulano%40email.com");

  xhr.addEventListener("load", function() {
      var resposta = xhr.responseText;
      // console.log("ola1");
      var clientes = JSON.parse(resposta);
      // console.log("ola2");
      // console.log(clientes);

      for (var i =0; i < 1; i++){
          // console.log("ola3");
         var clientes_1 = clientes.TRACKER[i];
         AdicionaNome(clientes_1);
         AdicionaCPF(clientes_1);
         AdicionaProduto(clientes_1);
         AdicionaCidade(clientes_1);
         AdicionaCodigoProduto(clientes_1);
         AdicionaCodigoCliente(clientes_1);
         AdicionaStatus(clientes_1);
         ActiveStatusImage(clientes_1);
         ActiveOnlyPostagem(clientes_1);
         adicionaClienteNaTabelaViagem(clientes_1);
         ActiveQtdViagem(clientes_1);

     }

  });

  xhr.send();
      }
      window.onload = load;

Eu mudei o link da api, só é um exemplo

A: Um método interessante é acessar via Curl, é semelhante a uma requisição ajax, mas com PHP, verifique também se a API tem alguma documentação abrangente...
Geralmente para autenticação o método é GET, então seria algo assim...
PHP
$url="http://api/api/TRCKCLICODCPF=12345678901&EMAIL=fulano%40email.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);    // get the url contents

$data = curl_exec($ch); // execute curl request
curl_close($ch);

$xml = simplexml_load_string($data);
print_r($xml)

Assim sua API não será visível a qualquer usuário caso fosse acessada no cliente...


text:
Q: Connect to Blob Storage from Python using Individual Docker Image Deployed as Azure Webapp I have a Docker with python which is deployed as webapp on Azure (I followed this tutorial: https://learn.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-docker-python-postgresql-app)
The Dockerfile looks like this:
FROM python:3.6.1
EXPOSE 2222 80 8080 5000
COPY daemon.json /etc/docker/
ENV http_proxy http://<LOCALPROXYADDRESS>:8080
ENV https_proxy https://<LOCALPROXYADDRESS>:8080

RUN apt-get update \
  && apt-get install -y --no-install-recommends openssh-server \
  && echo "root:Docker!" | chpasswd

COPY requirements.txt /
RUN pip install -r ./requirements.txt

COPY sshd_config /etc/ssh/

COPY init_container.sh /bin/
RUN chmod 755 /bin/init_container.sh
CMD ["/bin/init_container.sh"]

COPY app/ /app/
WORKDIR /app
ENV FLASK_APP=app.py
CMD flask run -h 0.0.0.0 -p 5000

I try to connect via python to a Blob Storage using BlockBlobService from azure.storage.blob. This works fine for a container started on my local machine. Once I push it to azure, the following error is printed:
azure.common.AzureException: HTTPSConnectionPool(host='<CONTAINERNAME>.blob.core.windows.net', port=443):
Max retries exceeded with url: /mycontainer?restype=container
(Caused by ProxyError('Cannot connect to proxy.',
NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at
0x7fe859467cc0>: Failed to establish a new connection: [Errno -2] Name or
service not known',)))

A: Try to connect to Azure Blob Storage in Python with StorageClient.set_proxy method via Http Proxy, like the code below.
from azure.storage.blob import BlockBlobService

block_blob_service = BlockBlobService(account_name="<your account name>", account_key="<your account key>")
super(BlockBlobService, block_blob_service).set_proxy("LOCALPROXYADDRESS", "8080")

Hope it helps.


text:
Q: Update SQL Server two statements UPDATE ADDRESS
SET ADDRESS.LATITUDE = b.latitude,
    ADDRESS.LONGITUDE= b.LONGITUDE
FROM POSTAL_CODE_LOOKUP b
WHERE ADDRESS.postal_cd = b.POSTALCODE
  AND (address.LATITUDE != b.LATITUDE OR address.LONGITUDE !=b.LONGITUDE)

 11:20:23  [BEGIN - 2454 row(s), 0.437 secs]  Command processed
 11:20:23  [BEGIN - 2454 row(s), 0.437 secs]  Command processed
... 2 statement(s) executed, 4908 row(s) affected, exec/fetch time: 0.874/0.000 sec  [2 successful, 0 warnings, 0 errors]

After executing the update I run the SQL below and get 2454 records.
select
    a1.POSTAL_CD, b.POSTALCODE,
    a1.LATITUDE, b.LATITUDE,
    a1.LONGITUDE, b.LONGITUDE
from
    ADDRESS a1, POSTAL_CODE_LOOKUP b
where
    a1.postal_cd = b.postalcode
    and (a1.LATITUDE != b.LATITUDE or a1.LONGITUDE != b.LONGITUDE);

Yes I have committed, and the records haven't changed. I don't understand why the update is being read as 2 statements. I don't understand why it's not updating.
How should I be writing this update statement?

A: Your ADDRESS table must have Update trigger, that's why there is a second statement about 2454 rows.
The amount updated is just 2454 rows, the same number You select after.

A: You have multiple rows in your join for one postal code i think

A: Use the below script to update the Address table .
UPDATE a
SET    a.LATITUDE = b.latitude,
       a.LONGITUDE= b.LONGITUDE
FROM [ADDRESS] a
 JOIN POSTAL_CODE_LOOKUP b
        ON a.postal_cd = b.POSTALCODE
WHERE (a.LATITUDE != b.LATITUDE or a.LONGITUDE !=b.LONGITUDE)


text:
Q: In TS, why number[][number] === number?
type Test = number[][number]; // Test will be inferred to 'number' as the above image show.

Why number[] is an index signature type with signature 'number'?

A: That's a way how you get union of types of values.
it is the same as: there is an array of numbers number[], we say [number], that means give us a union of types of values that belong to numeric key, because it's an array of numbers the result is number.
type TestObject = {
  test1: string;
  test2: number;
};

// union of all keys is string | number
type TestValueUnion = TestObject[keyof TestObject];

// 'test1' | 'test2'
type TestKeyUnion = keyof TestObject;

A: example
number[]  mean a array
when you want to get the type of array, you can add [randomInput]
so number[][number] mean get the type of number[]
number[][xxx] is also equal number   try it


text:
Q: Laravel do I have to worry about mass assignment when setting field by field I am a bit confused when it comes to laravels mass assignment.
I know that I can protect fields using:
protected $fillable = [
        'username', 'email', 'password'
    ];

and be protected here:
$flight = App\Flight::create(Input:all);

or

$flight->fill(['name' => 'Flight 22']);

But I only create or update Models like this:
public function createUser(NewUserRequest $request, User $newUser)
    {

$newUser->insertUser($request);

}

insertUser looks like this:
public function insertUser($request)
    {
        $newUser = $this;
        $newUser->user_type = (int) $request->input('user_type');
        $newUser->username = $request->input('username');
        $newUser->email = $request->input('email');
        if ($request->filled('password')) {
            $newUser->password = bcrypt($request->input('password'));
        }
        if ($request->filled('facebook_id')) {
            $newUser->facebook_id = $request->input('facebook_id');
        }
        $newUser->save();

        return $newUser;
    }

As you can see I always pick what fields I want to insert and what data should be inserted. So do I really need to set my $fillable when I dont use the create() or fill() methods?

A: The purpose of mass assignment protection is to protect developers who source model properties direct from user input, for example:
Example::create($request->input());

Without mass assignment protection a user who knows about the underlying application architecture could inject values into fields they're not expected to have access to, e.g if your User field has an is_admin value they could change their is_admin to 1 instead of 0.
Mass assignment protection is only required when working with unsanitized user input and mass assignment protection is only enabled by default when mass assigning. You have 3 options for a secure application:

*

*Make use of mass assignment and whitelist each property in $fillable

*Assign values individually so there is no mass assignment protection, e.g: $user->name = 'John Doe'

*Disable mass assignment protection and do not mass assign from user input, e.g:
protected $guarded = [];

Example::create($request->only('name', 'age'));

Example::create(['name' => $request->name, 'age' => $request->age]);

You do not need need to disable mass assignment protection in your example because you are not mass assigning values, you're assigning a value to each property individually. You can determine if you are using mass assignment by asking yourself "Am I passing in an array of properties and their values?".
You can learn more about mass assignment in the Eloquent documentation.


text:
Q: Does "Erase disk and install Ubuntu" option delete/erase everything on the Hard-drive? I'm just confused. I was a Windows user pretty much all my life. But now I want to switch to Linux for good. I have a 1 TB hard-drive attached to my laptop. As you know, in windows, the total hard-drive storage is divided into a couple of drives(i.e. Drive:C, Drive:D, Drive:E etc.). Usually, Windows is stored in Drive:C. My question is if I choose the Erase disk and install Ubuntu/ubuntu-derivatives option, will it erase the data on the other drives such as Drive:D/Drive:E, or will it just erase the drives where windows/any other OS is installed and keeping the data on other drives safe ?

A: Other people have explained 'drive' and 'partition' in the Linux context. Anyway, "Erase disk and install Ubuntu" removes the old partition table and creates a new one. This means that the opeating system sees the memory locations as empty in the whole physical device.
But the memory cells are still containing the data that were written before (in your case while it was still formatted by Windows). It is still possible (but a lot of hard work) to recover some of these data with special tools, e.g. PhotoRec.
If you want to make it impossible to recover the previous data, you can

*

*overwrite the whole drive with zeros or some random data, or

*use a built-in tool in the drive to remap the links between logical memory locations and physical locations (which works like encrypting without offering a key).

Removing the old partition table and creating a new one is usually good enough, at least for personal use.

You can find more details at this link.

A: Only Windows confusingly calls partitions "drives". Everyone else calls partitions "partitions", and disks/drives "disks".
The erase disk option uses the term "disk" in the non-Windows sense. Everything on that physical storage device (disk, SSD) will be erased, including all partitions regardless of what they are called.

*

*If "D:" is another partition on the same physical storage device (disk, ssd), it will be erased.

*If "D:" is on a separate physical storage device, it won't be touched.

A: You can boot into a "live" environment from an Ubuntu USB/DVD and use GParted to resize your hard drive and make room for your Ubuntu installation. It can get messy for those new to doing this so ensure you have a backup of what you want to keep. There is plenty of instruction on the net as to how to go about this.

A: If your storage device that you want to install linux on does in fact have more than one partition i.e. Drive D: and possibly Drive E:
In Windows ,transfer all your personal data that you want to save that is on the Drive C: to one of these other drives.
If you are installing Ubuntu or an Ubuntu flavour,choose "something else" in the installer, a partition manager will open and you can install to the partition you wish.
N.B. the partitions in the linux partition manager will not be named in the windows fashion,so you will have to carefully identify which one is C: You can usually do this by noting the sizes of the "drives" and the free space in them ,in Windows, and then comparing these values in the linux partition manager (Gparted)
If you do this carefully ,the two other partitions will remain untouched.
Backups are always advisable.


text:
Q: magento 2 - dynamic images not showing in home page after installing magento 2, dynamic images (Products/Slider/Blogs) are displaying in all website pages but not in home pages
i cleared the cache, re-indexed the website and changes the media folder permission but none of them solve my problem


text:
Q: GetNewClosure and Start-Job I'm having trouble understanding how GetNewClosure works in conjunction with Start-Job. Case in point I have the following code
function Test([string]$Name)
{
     $block = { Write-Host "Name = $Name" }.GetNewClosure()
     &$block
     Other $block
     OtherJob $block
}

function Other([scriptblock]$Block)
{
    Write-Host -NoNewline "In Other: "
    &$Block
}

function OtherJob([scriptblock]$Block)
{
    Write-Host -NoNewline "In OtherJob: "
    $j = Start-Job -ScriptBLock $Block
    Start-Sleep -s 1
    $j | Receive-Job
}

When calling the code I get
PS C:\> Test "foo"
Name = foo
In Other: Name = foo
In OtherJob: Name =

Notice that $Name is not captured in OtherJob.
It is probably related to Start-Job starting a new PS instance, but is there any workaround for this (Preferably one that does not include using -ArgumentList)?
PS: The version table should it matter
PS C:\> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5485
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

A: A little more googling yielded a potential workaround taken from
Powershell - how to pre-evaluate variables in a scriptblock for Start-Job
Basically you can use
$otherBlock = [scriptblock]::Create("Write-Host 'Name = $Name'")
OtherJob $otherBlock

Or set the variables in -InitializationScript


text:
Q: Why on submitting form with image as file, my $_FILES array returns Array() empty array and my image is not stored on desired folder after submit I have almost filled up this signup form 30 times in a day debugging this and still the image is not reaching to the destination folder as it should.
This code is present in htdocs/Email/signup.php and uploaded file should be moved to htdocs/gid113/Eagleeye/guard/imges/id.jpg  and even only "id." is inserted in mysql database and not "id.jpg" unable to get the extension for image .

    if(isset($_POST['signup'])){
        $result = $conn->query("SHOW TABLE STATUS LIKE 'guard'");
        $data = mysqli_fetch_assoc($result);
        $id = $data['Auto_increment'];
        $_SESSION["id"] = $id;
        print_r($_FILES);

        // File Image handling while signup
        if($_FILES['img']['error']==UPLOAD_ERR_OK){
            $file_name = $_FILES['img']['name'];
            $file_size = $_FILES['img']['size'];
            $file_tmp = $_FILES['img']['tmp_name'];
            $file_type = $_FILES['img']['type'];
            $destination = "../gid113/Eagleeye/guard/imges/".basename($file_name);
            $file_extension = pathinfo($file_name, PATHINFO_EXTENSION);
            move_uploaded_file($file_tmp,$destination);
            // $new_name ="./imges/".$id.".".$file_extension;
            $new_name = id.".".$file_extension;
            rename($destination,$new_name);
            // $img=pathinfo($new_name,PATHINFO_BASENAME);
            $img=$new_name;
        }
    }

A: SOLUTION:-

*

*Added $ before Id in $new_name declaration.

*Specified path to destination folder to the second parameter of rename as well.

if(isset($_FILES['img'])){
                $file_name = $_FILES['img']['name'];
                $file_size = $_FILES['img']['size'];
                $file_tmp = $_FILES['img']['tmp_name'];
                $file_type = $_FILES['img']['type'];
                $destination = "../gid113/Eagleeye/guard/imges/".basename($file_name);
                $file_extension = pathinfo($file_name, PATHINFO_EXTENSION);
                move_uploaded_file($file_tmp,$destination);
                // $new_name ="./imges/".$id.".".$file_extension;
                $new_name = $id.".".$file_extension;
                rename($destination,"../gid113/Eagleeye/guard/imges/".$new_name);
                // $img=pathinfo($new_name,PATHINFO_BASENAME);
                $img=$new_name;
}


text:
Q: Using third party component in Liferay I am new to Liferay. How can I use the third party components (jquery datepicker) in the liferay? Any step by step explanation from referring the scripts and intializing the component will be much helpful. Thanks in advance

A: What I have done and still works is:
In my jsp, after html, you must add 3 parts of javascript code:
1 -
<script>
    define._amd = define.amd;
    define.amd = false;
</script>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

2 - Your js code, this is just an example:
<script>
    (function($) {
        $(function() {
            var $j = jQuery.noConflict();
            var a = "${myDate}";
            var splitted = a.split("-");
            var newFechaStr = splitted[2]+ "/" + splitted[1] + "/" + splitted[0];
            $j("#datepickerIda").datetimepicker({
                timepicker:false,
                format:'d/m/Y',
                value:newFechaStr,
                dayOfWeekStart:1
        });
    $j.datetimepicker.setLocale('es');

   });
})(jQuery);
</script>

3 -
<script>
   define.amd = define._amd;
</script>


text:
Q: Launching an event just before the app is closed So, here it is my problem, I'm running a Flash app who is hosted in an html page that connects to a web service when it starts, what I need, is a way to launch/detect an event that communicates to that web service to say: "hey, I'm not here anymore" when the user:

*

*close the tab

*close the browser

*refresh the page

*anything not inside a flash controlled environment

How can I do that?, I mean, I'd need to find a way to send data to the web service even if the app is being shut down.
Thanks.

A: add some javascript: window.onunload = function(){/*do stuff*/}


text:
Q: Not printing out the proper letter- Python The question:
A- Write a function called has_no_e that returns True if the given word doesn't have the letter "e" in
it.
B- Modify your previous program to print only the words that have no "e" and compute the
percentage of the words in the list have no "e."
def main():
    file = input("Enter a file: ")
    file_output = open(file, 'r')
    output = (file_output.read())
    for line in output:
        word = line.strip()
        if len(word)>20:
            print (word)
    no_e = has_no_e(word)

    count = 0
    for line in output:
        word = line.strip()
        if has_no_e(word):
            count +=1
            print (word)
    percent = (count/1)*100 #Im still working on the percentage part
    print (percent)

def has_no_e(word):
    for char in word:
        if char in 'Ee':
            return False
        return True

Output:
c
h
s
i
s
c
o
o
l
900.0
Problem: So my problem is that instead of printing out the entire word, its printing out every letter (except e). I'm trying to get it to print it out the entire word if it doesn't have the letter e. For example, my file said "cheese is cool". I was expecting it to output "is cool" only. How would I go about doing this? Also, for the percentage: How can I bunch the word as one instead of individual letters? This way for the percentage I could do (count/# words) *100.

A: file_output.read() reads the entire file and returns it as a string. So output is the string "cheese is good".
The issue is for line in string:. You expect it to have line="cheese", then line="is", and finally line="good".
However, it instead goes character by character. So it runs the loops with line='c', then with line='h' and so on. For it to perform as you expect, you need to split output on either newlines or spaces (depending how your file separates words) and iterate through the resulting list.


text:
Q: Referencing a contentPane in an actionPerformed method I'm creating a load button and want it to populate a 9x9 gridlayout content pane nested inside the CENTER panel of a border layout (main window). This method is located inside the PAGE_START section of the border layout. The question is how can I place the buttons in the Grid Layout of the CENTER section from here?
       //Load Button
    JButton load = new JButton("Load");
    load.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed (ActionEvent a) {
            //Dialog Box To Locate The Puzzle
                SudokuPuzzle puzzle;
                JFileChooser chooser = new JFileChooser();
                FileNameExtensionFilter filter = new FileNameExtensionFilter(
                        "Text Files", "txt");
                chooser.setFileFilter(filter);
                int returnVal = chooser.showOpenDialog(SudukoGUI.this);
                if(returnVal == JFileChooser.APPROVE_OPTION) {
                    String fileLocation = chooser.getSelectedFile().getName();
                    Scanner file = new Scanner(fileLocation);
                    puzzle = new SudokuPuzzle(file, file);

                    //Load Puzzle To Model and draw it
                    try {
                        gridView = new JButton[9][9];
                        int[][] viewArray = puzzle.getArray();

                        for (int row = 0; row < 9; row++) {
                            for (int col = 0; col < 9; col++) {
                                gridView[row][col] = new JButton(String.valueOf(viewArray[row][col]));

***************THE NEXT LINE REPRESENTS MY PROBLEM***************
                                this.getContentPane().board.add(gridView[row][col]);

                            }
                        }

This is in the constructor
     JPanel board = new JPanel();
    board.setLayout (new GridLayout (9,9));
    board.setPreferredSize(new Dimension(400,400));
    this.getContentPane().add(board, BorderLayout.CENTER);

A: First of all declare board as final variable using:
final JPanel board = new JPanel();

So that board could be accessed from anonymous inner class of ActionListener. Thereafter, change this line:
this.getContentPane().board.add(gridView[row][col]);

To
board.add(gridView[row][col]);

A: This
this.getContentPane().board.add(gridView[row][col]);

Does not make any sense. You added board to the content pane in your constructor, but this does not mean that board is now a field of the content pane. So
getContentPane().board

Should fail to compile.
You should probably make board a field of your class, rather than declaring it a local variable in your constructor. Then you will able to refer to board throughout the body of your class.
Basic example:
public class Example
{
    private JPanel board;

    public Example()
    {
         board = new JPanel();
         getContentPane().add(board);
         //assuming above code takes place in the constructor
         JButton load = new JButton("load");
         load.addActionListener(new ActionListener()
         {
              public void actionPerformed(ActionEvent e)
              {
                    ...lots of code
                    //as board is no longer a local variable this will compile
                    board.add(gridView[row][col]);
              }
         }
    }
}

Note that you probably want to add load to your frame at some point.


text:
Q: Limit data going into a heat map across transitions in gganimate I'm newer to gganimate and trying to make a heatmap that only considers specific years into a frame and that shows only one frame per year with that year's data considered. I made a sample dput with just three years and code for the ggplot. Based on what I found in searching, I thought maybe view_step_manual() might be it but not sure how to write it if so.
foo <- structure(list(yearSeason = c(2021, 2021, 2021, 2021, 2021,
2022, 2022, 2022, 2022, 2022, 2023, 2023, 2023, 2023, 2023), x = c(-1,
14.4, -1.5, -13.3, 8.3, -2.9, -14.3, 23.9, 13.6, 1.1, 14.1, 16.3,
3.3, -10.8, 0), y = c(8.95, 15.65, 7.55, 5.55, 18.75, 8.25, 25.55,
3.75, 29.35, 7.45, 25.85, 27.75, 8.95, 29.45, 5.65)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -15L), groups = structure(list(
yearSeason = c(2021, 2022, 2023), .rows = structure(list(
    1:5, 6:10, 11:15), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -3L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE))

Here's what I tried:
ggplot(foo) +
  geom_density_2d_filled(mapping = aes(x=x,y=y,fill = ..level..,),
                     contour_var = "ndensity", breaks = seq(0.01, 1, length.out = 10),
alpha = .5) +
  labs(title = 'Year: {frame_time}') +
  transition_time(as.integer(yearSeason)) +
  ease_aes('linear')

So the output I'm looking for in this example would really just be three frames for each year (2021, 2022, 2023) that shows a heatmap for only data falling in that year.

A: You get the following error:
Error in transform_polygon(all_frames, states[[i]], ease, nframes[i],  :
  The transformr package is required to tween polygons

So you should load the transformr package to get this animation working like this:
library(ggplot2)
library(gganimate)
# devtools::install_github('thomasp85/transformr')
library(transformr)
ggplot(foo) +
  geom_density_2d_filled(mapping = aes(x=x,y=y,fill = ..level..,),
                         contour_var = "ndensity", breaks = seq(0.01, 1, length.out = 10),
                         alpha = .5) +
  labs(title = 'Year: {frame_time}') +
  transition_time(as.integer(yearSeason)) +
  ease_aes('linear')
#> Warning: The dot-dot notation (`..level..`) was deprecated in ggplot2 3.4.0.
#> ℹ Please use `after_stat(level)` instead.

Created on 2023-01-20 with reprex v2.0.2


text:
Q: issue creating new java fx Projects Im having issues creating a new javafx project, when i create it it gives flags off the bat saying that some of the imports aren't resolved to a type and i don't know what causing it. Ive installed e(fx)clipse which i thought was supposed to fix and import all the libraries needed to run javafx.
im using java-SE13 which to my understanding could run JavaFX

A: You likely did not download the JavaFX library and link it. JavaSE13 cannot run javaFX on its own, the javaFX library is a separate library that must be additionally downloaded from openjfx.io and linked to your program.


text:
Q: How to create one generic RewriteRule for these cases? I have a lot of rules with the same structure as below.
Is there any way to have only one that will satisfy all of these cases?
RewriteRule ^ecology/?$ /content.php?slug=ecology [NC,L]
RewriteRule ^vraveia/?$ /content.php?slug=vraveia [NC,L]
RewriteRule ^bonus/?$ /content.php?slug=bonus [NC,L]

I tried
RewriteRule ^(.+)/?$ /content.php?slug=$1 [NC,L]

without luck

A: Use:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/?$ /content.php?slug=$1 [NC,L]

This way, you avoid rewriting an existing file or directory
With -f you test for files, and with -d for directories. http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond

A: Assuming that a trailing slash being included in the final URL is your problem, try making the capturing non-greedy:
RewriteRule ^(.+?)/?$ /content.php?slug=$1 [NC,L]

If you want to match just a single level (e.g. ecology/ but not ecology/one/two/), use:
RewriteRule ^([^/]+?)/?$ /content.php?slug=$1 [NC,L]


text:
Q: Detecting swipe gesture for a gridview I am trying to implement some functionality when an user swipes on the grid view of my screen. I tried using a SimpleOnGestureListener as follows:
    class MyGestureDetector extends SimpleOnGestureListener {
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        try {
            if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
                return false;
            // right to left swipe
            if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                Log.w(null,"Right to Left swipe detected");

                return true;
            }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                Log.w(null,"Left to Right swipe detected");

                return true;
            }
        } catch (Exception e) {
            // nothing
        }
        return false;
    }
}

However am not able to detect the motion events . I tried debugging and saw that event e1 is passed as null . Can someone help?


text:
Q: MYSQL - Finding all parent_id in nested model set MYSQL VERSION : 5.7.33
I implemented the Nested Set Model concept based on: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
Here is the data :
+----+------+------+------+------+-------------------------------------+--------+------------------+
| id | lft  | rgt  | lvl  | root | name                                | code   | header_or_detail |
+----+------+------+------+------+-------------------------------------+--------+------------------+
|  1 |    1 | 2761 |    0 |    1 | AKTIVA                              | 1      |                0 |
|  2 |    2 | 2281 |    1 |    1 |     AKTIVA LANCAR                   | 11     |                0 |
|  3 |    3 |   62 |    2 |    1 |         KAS TUNAI                   | 1101   |                0 |
|  4 |    4 |    5 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
|  5 |    6 |    7 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
|  6 |    8 |    9 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
|  7 |   10 |   11 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
|  8 |   12 |   13 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
|  9 |   14 |   15 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 10 |   16 |   17 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 11 |   18 |   19 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 12 |   20 |   21 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 13 |   22 |   23 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 14 |   24 |   25 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 15 |   26 |   27 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 16 |   28 |   29 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 17 |   30 |   31 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 18 |   32 |   33 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 19 |   34 |   35 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 20 |   36 |   37 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 21 |   38 |   39 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 22 |   40 |   41 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 23 |   42 |   43 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 24 |   44 |   45 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 25 |   46 |   47 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 26 |   48 |   49 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 27 |   50 |   51 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 28 |   52 |   53 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 29 |   54 |   55 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 30 |   56 |   57 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 31 |   58 |   59 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 32 |   60 |   61 |    3 |    1 |             Kas Tunai USD (EL)      | 110104 |                1 |
| 33 |   63 |  216 |    2 |    1 |         KAS DI BANK                 | 1102   |                0 |
| 34 |   64 |   65 |    3 |    1 |             Bank BCA-GMD RPH TS     | 110201 |                1 |
| 35 |   66 |   67 |    3 |    1 |             Bank BCA-VETERAN RPH TS | 110201 |                1 |
| 36 |   68 |   69 |    3 |    1 |             Bank BCA-PEMUDA RPH TS  | 110201 |                1 |
+----+------+------+------+------+-------------------------------------+--------+------------------+
36 rows in set (0.01 sec)

My goal, I want each record to have a parent_id column.
Here I show only 36, but in the actual database there are 1374 rows.
I am using a query using a query with a subquery to get the parent_id as follows.
SELECT COALESCE((
SELECT GROUP_CONCAT(DISTINCT parent.id)
FROM chart_of_account AS parent
WHERE ((parent.lft < (node.lft)) AND (parent.rgt > (node.rgt))) AND (parent.root = node.root)
GROUP BY parent.root            ), node.root) AS parent_id  ,
    node.id
    , node.lft
    , node.rgt
    , node.lvl
    , node.root
    , CONCAT(REPEAT(' ', `node`.lvl * 4), `node`.name) AS name
    , node.code
    , node.header_or_detail
FROM chart_of_account AS node
WHERE root = 1
ORDER BY root, lft

The result is :
+-----------+----+------+------+------+------+-------------------------------------+--------+------------------+
| parent_id | id | lft  | rgt  | lvl  | root | name                                | code   | header_or_detail |
+-----------+----+------+------+------+------+-------------------------------------+--------+------------------+
| 1         |  1 |    1 | 2761 |    0 |    1 | AKTIVA                              | 1      |                0 |
| 1         |  2 |    2 | 2281 |    1 |    1 |     AKTIVA LANCAR                   | 11     |                0 |
| 1,2       |  3 |    3 |   62 |    2 |    1 |         KAS TUNAI                   | 1101   |                0 |
| 1,2,3     |  4 |    4 |    5 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     |  5 |    6 |    7 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     |  6 |    8 |    9 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     |  7 |   10 |   11 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     |  8 |   12 |   13 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     |  9 |   14 |   15 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     | 10 |   16 |   17 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     | 11 |   18 |   19 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     | 12 |   20 |   21 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     | 13 |   22 |   23 |    3 |    1 |             Kas Kecil Rupiah        | 110101 |                1 |
| 1,2,3     | 14 |   24 |   25 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 15 |   26 |   27 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 16 |   28 |   29 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 17 |   30 |   31 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 18 |   32 |   33 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 19 |   34 |   35 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 20 |   36 |   37 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 21 |   38 |   39 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 22 |   40 |   41 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 23 |   42 |   43 |    3 |    1 |             Kas Tunai USD           | 110102 |                1 |
| 1,2,3     | 24 |   44 |   45 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 25 |   46 |   47 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 26 |   48 |   49 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 27 |   50 |   51 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 28 |   52 |   53 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 29 |   54 |   55 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 30 |   56 |   57 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 31 |   58 |   59 |    3 |    1 |             Kas Tunai Dibrankas     | 110103 |                1 |
| 1,2,3     | 32 |   60 |   61 |    3 |    1 |             Kas Tunai USD (EL)      | 110104 |                1 |
| 1,2       | 33 |   63 |  216 |    2 |    1 |         KAS DI BANK                 | 1102   |                0 |
| 1,2,33    | 34 |   64 |   65 |    3 |    1 |             Bank BCA-GMD RPH TS     | 110201 |                1 |
| 1,2,33    | 35 |   66 |   67 |    3 |    1 |             Bank BCA-VETERAN RPH TS | 110201 |                1 |
| 1,2,33    | 36 |   68 |   69 |    3 |    1 |             Bank BCA-PEMUDA RPH TS  | 110201 |                1 |
+-----------+----+------+------+------+------+-------------------------------------+--------+------------------+

If Using a subquery, to get 1.374 rows took 4.2 seconds.
Is there any other way ?
Here is the explain:
Plain Text Explain

+----+--------------------+--------+------+---------------+-----+---------+-----+------+-------+
| id | select_type        | table  | type | possible_keys | key | key_len | ref | rows | extra |
+----+--------------------+--------+------+---------------+-----+---------+-----+------+-------+
|  1 | PRIMARY            | node   |      | ALL           |     |         |     |      | 5598  |
|  2 | DEPENDENT SUBQUERY | parent |      | ALL           |     |         |     |      | 5598  |
+----+--------------------+--------+------+---------------+-----+---------+-----+------+-------+


text:
Q: why not assign var a value into id field? $.getJSON('getwarehousename',function(data){
  for(var i=0;i<data.length;i++){
    $("#plantname").val(data[0][0]);
    var a = JSON.stringify(data[0][1]);
    alert("PlantWH...."+a)
    $("#plantwhname").val(a);
    alert("wname.."+$("#plantwhname").val())
  }
});

In this variable a value is plantwarehouse01, but this value can not be assigned to plantwhname id field?
$(document).ready(function() {
  var html2="<label><select id='plantwhname' class='wname' name='store1'>";
  var ht2="<option selected='selected'>Select</option>";
  $("#plantware").html(html2);
  $.getJSON('findPlantwarehouseForMultiple',function(data){
    if(data!=0){
      for(i=0;i<data.length;i++){
        ht2+="<option>"+data[i].plantwarehousecode+"</option>";
      }
      ht2+="</select></label>";
      $("#plantwhname").html(ht2);
      $("#plantwhname").attr("Style","width:220px;");
    }
  });
});

A: i think your select option list and your new add option not same so new option not select so first add this option
$('#selectID').append($('<option>',
 {
    value: value_variable,
    text : text_variable
}));

$.getJSON('getwarehousename',function(data){
  for(var i=0;i<data.length;i++){
    $("#plantname").val(data[0][0]);
    var a = JSON.stringify(data[0][1]);
    alert("PlantWH...."+a);
    $('#plantwhname').append($('<option>',
         {
            value: a,
            text : a
        }));
    $("#plantwhname").val(a);
    alert("wname.."+$("#plantwhname").val())
  }
});

then select it using this code. hope this will help you


text:
Q: create-react-app Failing to create a new React app in windows 10 I have Create-react-app version 1.4.3 installed. When I try to create a new App , I get the following messages in the command prompt. Please help me find and fix the issue.
C:\Users\GSI-KOL\Desktop\server>create-react-app client

Creating a new React app in C:\Users\GSI-KOL\Desktop\server\client.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\GSI-KOL\Desktop\server\client\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js

npm ERR! path C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, lstat 'C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\GSI-KOL\\Desktop\\server\\client\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'C:\\Users\\GSI-KOL\\Desktop\\server\\client\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\GSI-KOL\AppData\Roaming\npm-cache\_logs\2017-11-08T13_08_03_705Z-debug.log

Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting client / from C:\Users\GSI-KOL\Desktop\server
Done.

C:\Users\GSI-KOL\Desktop\server>

A: It looks like you need admin privileges to write some of the generated files. Can you create a terminal instance with administrator rights then reissue the command?

A: You probably had "create-react-app" running before, which was the problem in my case anyway. The way I solved this was using
npm cache clean --force and ran create-react-app my-app again.

A: I suspect NPM has an issue. However, this was how I was able to resolve it
Follow this steps:

*

*npm install -g yarn

*yarn global add create-react-app

*Create-react-app <projectname>

A: npm cache clean --force

Then try
npm create-react-app navigate

A: I also faced same issue and I rectified it using the comment
given below:
npm cache clean --force

After this comment try:
npx create-react-app project_name

A: I was faced this same problem . It is due to the issue with npm .
please run the following command in command Line
npm cache clean --force

then run
create-react-app <project Name>

If your problem still exist then switch from npm to yarn
run the following commands, it solved my problem
npm install -g yarn

yarn global add create-react-app

create-react-app <projectname>

A: Just run this one command to resolve issue:
sudo chown -R 1001:1001 "/home/<user_name>/.npm"

A: This is due to the network issues try to download all dependency one by one or try to clean  cache "npm cache clean --force" after this try to create an app
npx create-react-app <app__name>. But your internet connection should be stable.

A: I tried the npm cache clean --force and the yarn route but, neither worked. What worked for me was running Powershell as Administrator then entering:
set-executionpolicy remotesigned

A: try this
npm install -g yarn

yarn global add create-react-app

create-react-app my-app

A: I had the same problem and this was solved to me with these steps:

*

*Be sure that you have the lastest version of Node.js installed. (https://nodejs.org/)

*npm install -g create-react-app

*create-react-app client-app --use-npm or npx create-react-app client-app --use-npm
i hope it helped..

A: this should work
npm cache clean --force

A: I was also facing the same issue, here is how I fixed it :
 1. I first cleaned my cache using the --force keyword
 2. I reinstalled create-react-app globally
 3. I recreated my app.
Illustration:

*

*clean your cache

    npm cache clean --force

*Reinstall create-react-app globally

    npm i -g create-react-app

*Recreate your app

    create-react-app .

A: This is what I did
npm install -g yarn

then this
npx create-react-app my-project

A: For me, i wasn't connected to the internet when i tried to run 'create-react-app', so i connected and tried it, it worked, i'm guessing it needed to install some packages from the internet.

A: Creating a new React app in C:\Users\CM\Downloads\react\github-profile.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

npm ERR! path C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-

v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b1
0893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806

npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996
b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec6
5545008a3cad93d00f806'
npm ERR! { [Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1f
a335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec6554500
8a3cad93d00f806']

npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1
fa335b10893d67f7339e4
af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path:
npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-

npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996
b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015
eec65545008a3cad93d00f806'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path:
npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335
b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93
d00f806',
npm ERR! parent: 'postcss-image-set-function' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a
text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-
check thenpm ERR! permissions of the file and its containing directories, or
try  running

npm ERR! the command again as root/Administrator (though this is not
recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\CM\AppData\Roaming\npm-cache_logs\2019-03-22T10_
27_19_722Z-debug.log

Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-
scripts   has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting github-profile/ from C:\Users\CM\Downloads\reactDone.``

i was facing similar error but i tried to run create-react-app command many times and finally it was created , this was the problem with my internet connection. check your inernet connection

A: I also encountered with the same problem, According to the error, you have a problem with your npm.
Try this command
sudo chown -R 1000:1000 "<location of npm>/.npm"

just take an example of my command
sudo chown -R 1000:1000 "/home/vidit/.npm"

A: All you need is npm cache clean --force
Works 100%
In my case, it happened when I aborted a wrong command I initiated.
Then I ran npm cache clean --force and the cache was cleaned; after that, I ran my npx create-react-app and it worked perfectly as it should.
Quick tip: Uninstall create-react-app from your machine like so, npm un -g create-react-app and run npx create-react-app instead of npm create-react-app any time you want to create a new react app.
Reason: npx will always use the latest version of create-react-app to create a new react app for your project, and npx uninstalls/removes the create-react-app package from your machine when it's done.
Don't worry, it takes about 20 seconds to install the create-react-app package, so...
Do not forget to npm cache clean --force when npx create-react-app goes bananas (i.e. refuses to work).

A: I faced the same problem, and I did these to solve the problem;

*

*npm clean cache --force..

this didn't work... I returned a warning npm WARN using --forcing recommended protection disable.

*I ignored that and did and reinstalled create-react-app globally by running;
npm i -g create-react-app

*I created my app(project name) by running;
create-react-app my-app-name
I believe this should work for you..

A: I face the same issue.
I Try this But it does not work for me
npm cache clean --force
So uninstall Node
and install the latest version. It's worked for me
Hope it works for you :)

A: I resolved the same issue by changing the timeout time to greater than 30000
npx create-react-app appname -timeout=90000

A: In my case, none of the above mentioned worked for me. What fixed the problem was updating the npm:
npm install npm@latest -g
I did this because in the new LTS version (16.15.1) of NodeJS, npm was updated from 8.5.5 to 8.13.2.

A: just instead using the git-bash as a terminal use Windows powershell as a terminal it will work

A: in your system go to this location
C:\Users\user\AppData\Roaming
and inside that you will find a folder named "npm" delete that folder
and try npx create-react-app command again. conform it will work

A: My problem was similar and unlike others cleaning cache by using (npm cache clean --force) wasn't working out for me
this helped me instead
npx create-react-app my-app --use-npm
hope this does the trick for anyone who isn't getting result from cleaning cache

A: This worked for me
run npm install -g create-react-app (it will install create-react-app globally)
then create your app by running npx create-react-app [project-name]

A: This was my error:
3695 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\****\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts"
3696 verbose node v6.10.3
3697 verbose npm  v6.4.1
3698 error code Z_BUF_ERROR
3699 error errno -5
3700 error zlib: unexpected end of file

This solved the issue:
npm cache clean --force and ran create-react-app my-app


text:
Q: Pyspark/Spark Event Log Access Denied Error I have tried to set up a Spark and Pyspark Environment. I have been able to scale through various errors. However, when I run my code in Anaconda Jupyter, I get the following error which is referencing access denied to the spark event file.
Py4JJavaError: An error occurred while calling None.org.apache.spark.api.java.JavaSparkContext.
    : java.io.FileNotFoundException: C:\tmp\spark-events\local-1651494793387.inprogress (Access is denied)

I will appreciate it if anyone knows what settings I need to further put in place to avoid this error. Thank in advance

A: could you show how do you instantiate the Spark context to better troubleshoot?
If you are using Spark in your own computer in standalone mode and you don't need to create or submit jobs and you want to use it only with the Python interface I will recommend you to install it by pip or conda, so you don't need to set it up.
# pip
pip install pyspark

# conda
conda install -c conda-forge pyspark


text:
Q: Appy function on sparse martix according to its col value I need to apply a function on a sparse martix according to the column value.The wanted matrix is new_mtx. This code does exactly what I want but this takes too much time (I'm doing NLP so I have a huge database).
Because an example is always easier to understand :
import numpy as np
from scipy.sparse import csr_matrix

row = np.array([0,0,0,0,0, 1,1,1,1,1 ,2,2,2,2,2 ,3,3,3,3,3 ,4,4,4,4,4 ])
col = np.array([0,1,2,3,4, 0,1,2,3,4, 0,1,2,3,4,0,1,2,3,4,0,1,2,3,4 ])
data = np.arange(1,26)
mtx = csr_matrix((data, (row, col)), shape=(5, 5))

coef = {0:0, 1:1, 2:2, 3:3,4:4}

new_mtx = mtx.copy()
for i in range(0,mtx.shape[0]):
     for j in range (0,mtx.shape[1]):
        new_mtx[i,j] = pow(coef[i],mtx[i,j])

Is there a faster way to achieve this with build-in function ?


text:
Q: repeater inside update panel is not working <asp:UpdatePanel ID="updatePanel" runat="server">
  <ContentTemplate>
    <asp:Repeater ID="rptrtest" runat="server" OnItemCommand="rptrtest_ItemCommand" OnItemDataBound="rptrtest_ItemDataBound">
      <div> <asp:TextBox ID="txtName" runat="server"/> <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" > </asp:Button>
      </div>
    </asp:Repeater>
  </ContentTemplate>
</asp:UpdatePanel>

on button click event i'm sending name to another usercontrol in same page.
i'm having repeater inside update panel this whole thing in one usercontrol  my problem when i click submit button inside repeater there is no Asynchronous post back happening please any one help.

A: Your repeater is missing the ItemTemplate tag
<asp:UpdatePanel ID="updatePanel" runat="server">
  <ContentTemplate>
    <asp:Repeater ID="rptrtest" runat="server" OnItemCommand="rptrtest_ItemCommand" OnItemDataBound="rptrtest_ItemDataBound">
      <ItemTemplate>
        <div> <asp:TextBox ID="txtName" runat="server"/> <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" > </asp:Button> </div>
      </ItemTemplate>
    </asp:Repeater>
  </ContentTemplate>
</asp:UpdatePanel>

References

*

*Repeater (MSDN)

*Item Template (MSDN)


text:
Q: How to generate an employee id with year of registration in PHP? I need to generate an employee id for eg: E13001, the number should be auto incremented, and when the next year comes, it should be E14001(year is 2014).It should again start from 001 for every year. I have tried with yy format but the sequence number continues from the previous year. How i suppose to my change the sequence number generation ? help me. Thanks in Advance.

A: Well, the auto-increment on a column in MySQL will not work except for integers. Also it will increment with each field.
To do what you want, you need to separate the id and year in tow  (for the mysql table). So you get a table with id,emp_id(should not be managed by the db, no AUTO-INCREMENT) and year. Then select max(emp_id) where year ='2014', so when adding a new employee you will increment that value. To get the employe id the way you need it you should merge the tow columns into one and dump the first tow chars from the year.
You should know that this then becomes a distributed e_id, and every time you need to work with it you will need to do extra work. But you keep the format you need.
Hope this helps you get an idea of how it can be done.

A: Hi you can try in the following way
<?php

$connection = mysqli_connect("localhost","root","")
or die("no connection");
$db_select=mysql_select_db("test",$connection)
or die("no connection to db");
$query3 = "SELECT * FROM simple";
$result3 = mysqli_query($query3);
$count = mysql_num_rows($result3);
if($count == 0)
{
$year = date('y');
$seq = 1;
$a = sprintf("%04d", $seq);
$emp_id = E.$year.$a;
$query= "INSERT INTO simple (emp_id) VALUES ('$emp_id')";
$result=mysqli_query($query)or die(mysql_error());
}
else
{
    $query2 = "SELECT * FROM simple ORDER BY id DESC LIMIT 1";
    $result2 = mysqli_query($query2);
    $row = mysql_fetch_array($result2);
    $last_id = $row['emp_id'];
    $rest = substr("$last_id", -4);
    $insert_id = "$rest" + 1;
    echo $ars = sprintf("%04d", $insert_id);
    $year = date('y');
    $emp_id = E.$year.$ars;
    $query= "INSERT INTO simple (emp_id) VALUES ('$emp_id')";
    $result=mysqli_query($query)or die(mysql_error());
}

Hope this code helps you.


text:
Q: Custom Query Task I'm building a web application in ArcGIS Server for .net and I want to create query task for each layer so that each query depends on the previous result query task, how can I do that?

A: Since you're using ASP.NET, I assume you're using the ADF. We use MVC and the JavaScript API, but we create a class on the server to manage each query type (vehicles, garages, etc.).
You could create a page method to set up each query and pass it the results of the previous query. When the user makes a selection, call the page method with the selected value. In the page method, code the query and return the results to the second drop down.
Is that the kind of process you're looking for? Or do you need the actual code?

A: If I understand what you mean,you need to select features drom previous selection,for example if the first query select 1000 features in layer1,you need the second query in this layer,selects from that 1000 features.If this is right,maybe this is a solution for it:
1.Creating a table containing this columns at least: UserName|SessionId,LayerId,FeatureId,TimeStamp,(For example TBSel table)
2.Create an extension,overload tha SelectionChanged event of IActivatedView,and in the callback method,if there is new selections in that layer,(Can delete previous records corresponding to layerId and UserName and) insert new records for new selections in that layer(or all layers) TimeStamp column must be filled with the system time.
3.Combine each query for that layer with this phrase:
WhereClause+=" AND FeatureId in (SELECT FeatureId FROM TBSel WHERE UserName='MyUser' AND LayerId='MyLayerId' AND TimeStamp=(SELECT Max(TimeStamp) FROM TBSel WHERE UserName='MyUser' AND LayerId='MyLayerId' ))
in this way,selection from that layer is from most previous selection(or result of previous query),even you can make this optional,and if user want to enable this option,you will change WhereClause of the query filter.
Hope I could understand what you mean and it helps.


text:
Q: What's the advantage of preparing a matrix to return in python? It's the code in the book 'Machine Learning in Action'. source code
And the what is passed to dataSet is a m * 3 array(datingTestSet2.txt which can be found in the superior directory. )
My question is:
What's the advantage of preparing a matrix to return? (conserve memory?)
If I don't prepare the matrix, will it go wrong? (It seems not.)
from numpy import *
def autoNorm(dataSet):
    minVals = dataSet.min(0)
    maxVals = dataSet.max(0)
    ranges = maxVals - minVals
    normDataSet = zeros(shape(dataSet)) # prepare matrix to return(It's my own comment, not in the source code. )
    # Because there is a similar code before it,
    # I think it should be the same meaning. Or any means else?
    m = dataSet.shape[0]
    normDataSet = dataSet - tile(minVals, (m,1))
    normDataSet = normDataSet/tile(ranges, (m,1))   #element wise divide
    return normDataSet, ranges, minVals

A: There's no advantage. In the code you show, the first assignment to normDataSet has no lasting effect, because two lines later there's a second assignment to normDataSet. At that point, the reference count of the zeros array object that was previously bound to normDataSet reaches zero, and that old array is immediately garbage collected. (This is assuming CPython, of course, but at the time of writing none of the alternative Python implementations has fully working support for NumPy.)
I'd guess that this is a simple (but relatively harmless) error on the author's part. I'd suggest submitting a bug report so that it can be fixed.
By the way, a terminology nit: normDataSet is an array, not a matrix. This matters because NumPy does have a matrix type, whose behaviour on multiplication, division and exponentiation differs from that of a regular array.

A: In addition to being unnecessary to initialize normDataSet, it is not needed at all. You can directly modify the array dataSet points to without affecting the passed in array.
The code in general is overly verbose and complicated, and does not use numpyto its full effect. I'm not aware of a buit-in function to renormalize an array to the range [0,1] in numpy, but it can be easily done using element-wise operations on a numpy array:
def autoNorm(dataSet):
    minVals = dataSet.min(0)
    ranges = dataSet.max(0) - minVals
    dataSet = (dataSet-minVals) / ranges
    return dataSet, ranges, minVals


text:
Q: Как добавить два объекта в json файл, используя php? Я такой вопрос уже задавал. Но, дело в другом. Да, несколько объектов добавляются в JSON файл, но валидатор ругается. Сейчас объясню почему. Вот код, как добавляю два объекта в файл.
file_put_contents('js/allProducts.json',json_encode($json1, JSON_UNESCAPED_UNICODE));
file_put_contents('js/allProducts.json',json_encode($json2, JSON_UNESCAPED_UNICODE), FILE_APPEND);

Но, вот как отображается у меня в JSON файле.
[{
    "Id": "010",
    "Title": "Милый дом 100мл",
    "Price": "210",
    "ImgSrc": "standart_candle.jpg",
    "Description_1": "бергамот, чистый хлопок",
    "Description_2": "пион, лаванда, морские ноты, петигрен",
    "Description_3": "мускус, сандаловое дерево",
    "Count": "40"
}]
[{
    "Id": "110",
    "Title": "Candle box набор 100мл",
    "Price": "320",
    "Description_1": "Коробочка, для создания аромасвечи своими руками.",
    "Description_2": "Создайте свечу самостоятельно, чтобы ещё больше наслаждаться моментом зажжения.",
    "ImgSrc": "new_category.jpg",
    "Count": "20"
 }]

Оно вставляется в файл JSON как два отдельных объекта. Как мне объединить в один используя PHP?


text:
Q: How can I fix "Failed to compile src/index.js 'firebase' is not defined no-undef"? I am trying to use a React web app to read and write stuff in a Firebase realtime database. Every time I run "npm run start", I get this error message.
Failed to compile
src/index.js
  Line 25:1:   'firebase' is not defined  no-undef
  Line 28:16:  'firebase' is not defined  no-undef

Search for the keywords to learn more about each error.
This error occurred during the build time and cannot be dismissed.

This is what package.json, src/index.js, build/index.html, and public/index.html looked like when I first got this error. (is it bad to have 2 index.html files?)

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.12.2",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "firebase": "^9.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-router-config": "^5.1.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

import React from 'react';
import ReactDOM from 'react-dom';
//import './index.css';
//import App from './App';
//import reportWebVitals from './reportWebVitals';
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const config = {
  apiKey: "AIzaSyBk5lf0WtiZPs1ZQkA48OfXpzW7P_RCrZk",
  authDomain: "test-c2ec9.firebaseapp.com",
  projectId: "test-c2ec9",
  storageBucket: "test-c2ec9.appspot.com",
  messagingSenderId: "11138018851",
  appId: "1:11138018851:web:ecfb63337ca11f62028b96",
  measurementId: "G-3S1M3601YR"
};

// Initialize Firebase
firebase.initializeApp(config);

// Get a reference to the database service
var database = firebase.database();
const app = initializeApp(config);
const analytics = getAnalytics(app);

ReactDOM.render(
  <React.StrictMode>
  </React.StrictMode>,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint.
//reportWebVitals();

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Welcome to Firebase Hosting</title>

Welcome

Firebase Hosting Setup Complete

You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!

      Open Hosting Documentation

Firebase SDK Loading…

<!DOCTYPE html>

    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />

    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

    <title>React App</title>

    You need to enable JavaScript to run this app.

Lines 25 and 28 in src/index.js are "firebase.initializeApp(config);" and "var database = firebase.database();", respectively. You should be able to reproduce this error by following these steps:
create test/package.json, test/src/index.js, test/build/index.html, and test/public/index.html
copy and paste the above 4 snippets into their respective files
save the 4 files
open a command line interface
use cd to navigate to the test folder
run "npm install"
run "npm run start"
Commenting out lines 25 and 28 causes a much longer error message that starts with "Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)." When I searched that error message, I got results telling me to add those lines back into index.js, which leads me back to this "'firebase' is not defined" error. Additionally, I tried each of these things, and I still got the same error message.
restarting my computer
following this tutorial
changing line 28 to "var rootref = firebase.database().ref();"
running "npm start" instead of "npm run start"
pasting this snippet in the head part of build/index.html and public/index.html

<link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'>

pasting this snippet in the head part of build/index.html and public/index.html

<link rel='stylesheet' type='text/css' href='/resources/tutorial/css/example.css'>

pasting this snippet in the head part of build/index.html and public/index.html

<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/5.0.0/firebase-ui-auth.css" />

pasting this snippet in the head part of build/index.html and public/index.html

copying this snippet from the head part of build/index.html and pasting it in public/index.html

Is there anything else that I can try?

A: Recently, Firebase announced that version 9 of Firebase SDK JS is generally available. This was done to do some optimisations.
Try using:
import { initializeApp } from 'firebase/app';
import { getAuth, onAuthStateChanged } from 'firebase/auth';

and
const firebaseApp = initializeApp({ /* config */ });
const auth = getAuth();
onAuthStateChanged(auth, user => { console.log(user); });

instead of
import firebase from 'firebase/app';
import 'firebase/auth';

and
const firebaseApp = firebase.initializeApp({ /* config */ });
const auth = firebaseApp.auth();
auth.onAuthStateChanged(user => { console.log(user); });

Refer to this link for further reference: https://firebase.google.com/docs/web/modular-upgrade


text:
Q: check if a string inserted by user input corresponds to a particular format i have this method that ask the user for an input(a Date) in a specific format -- DD/MM/YYYY and i managed to partially limit the user input by this way using this code
date.matches("[0-9]+[0-9]/[0-9]+[0-9]/[0-9]+[0-9]+[0-9]+[0-9]"));

but i still got a problem on the input because if the user insert a date like  12121/12121212/12121 it takes it like a good input and goes forward
the input cicle is determined by this portion of code using a JOptionPane
String date  = JOptionPane.showInputDialog(frame,"Inserisci la data di partenza separata da / (GG/MM/AAAA):");
    if (date ==null) { return;}
    while (!date.matches("[0-9]+[0-9]/[0-9]+[0-9]/[0-9]+[0-9]+[0-9]+[0-9]")) {
        JOptionPane.showMessageDialog(frame, "Data inserita errata");
        date  = JOptionPane.showInputDialog(frame,"Inserisci la data di partenza separata da / (GG/MM/AAAA):"); }

then i split the string by using
String[] parts = date.split("/");
    int year = Integer.parseInt(parts[2]);
    int month = Integer.parseInt(parts[1]);
    int day = Integer.parseInt(parts[0]);

how can i get this to work limiting the numbers of digits of the inserted string ?

A: You should try to parse it as a date of the given format and catch parse errors. Take a look at SimpleDateFormat


text:
Q: HistoryApiFallback not working on Webpack 4 (with React Router 4 and nested routes) Context:
Trying out RR4 with webpack 4 (devServer: {apiHistoryFallback: true}
Sample Webpack 4 config
http://localhost:8080/reports works when cut and pasted into the address bar (aka history fallback is working)
and I can click a link for /reports/8, as I have added a nested route to the component at /reports
<Route path=${match.path}/:reportId component={ReportDetail}/>
but cut and paste http://localhost:8080/reports/9 into the address bar and I get a blank screen and a:
Refused to execute script from 'http://localhost:8080/reports/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Tried setting the contentBase for devServer but that didn't resolve the issue.
This functionality worked fine in Webpack 3 and RR3. Not sure whether to bark up the Webpack or React Router tree.
Similar issue to this one but for Webpack 3

A: Apparently adding:
<base href="/" />
to the head tag of your index.html is enough to fix this issue. Meep

A: I found out that if you add:
output: {
  publicPath: '/'
}

to your webpack.config.js then you don't need to add
<base href="/" />

to index.html
see: webpack-dev-server, historyApiFallback not working (webpack-4, react-router-4)


text:
Q: JavaScript URL issue with Permalinks enabled I am using the following JavaScript function to fetch the data using ajax call
function findName() {
    var name = "Jhon";
    $.ajax({
        method: "POST",
        url: "oc-content/themes/bender/ajax-test.php",
        data: { name : name },
        success: function (data) {
            alert(data);
        },
    })
}

It calls the following php file and works fine.
http://127.0.0.1/osclass/oc-content/themes/bender/ajax-test.php

But when I enable SEO friendly Permalinks in my CMS current page URL is appended in start of link and I get the following error in Chrome Console.
GET http://127.0.0.1/osclass/fashion-beauty/oc-content/themes/bender/ajax-test.php?name=Jhon 404 (Not Found)

Anybody tell me how to solve this issue?

A: The url you've provided in the ajax call is document relative. When you changed the server's url generation scheme, you also caused the url pointed at by the ajax call to change.
Adjust the ajax url, changing:
url: "oc-content/themes/bender/ajax-test.php",

To:
url: "/osclass/oc-content/themes/bender/ajax-test.php",

A: Why don't you make the URL server-relative? Something like this:
function findName() {
    var name = "Jhon";
    $.ajax({
        method: "POST",
        url: "/osclass/oc-content/themes/bender/ajax-test.php",
        data: { name : name },
        success: function (data) {
            alert(data);
        },
    })
}

A: As you have not posted the php code. I would mention that any url directly navigated through addressbar of browser causes in the GET request and i can see you have a POST request in the ajax, so, it can't work.
Workaround would be to use $_REQUEST super globals at php end. $_REQUEST would work for $_GET/$_POST requests.


text:
Q: Alamofire parameter only accepts [String : Anyobject]? I'm using Alamofire which is an HTTP networking library in Swift, and am trying to make a PUT request with the json below as the parameter in the request, but it seems it doesn't like the versions field because it has another dictionary inside of it. Is there no way around this?
var reqJson = [
        "asdf": "sdfs",
        "lsd": "asdf",
        "asdf" : "coc",
        "qwer": "sdf",
        "cvc": "kljb",
        "xcv": "qwe",
        "versions": [
            [
                "version": "\(version)",
                "component": "\(compName)"
            ]
        ]
    ]

    Alamofire.request(.PUT, baseURL + "/cli/applicationProcessRequest/request", parameters: reqJson, encoding: .JSON).authenticate(user: _user, password: _passwd).responseJSON{
        (_,_,data,error) in

        completionHandler(error)
    }

It seems like this is the case because the parameters is supposed to be [String : Anyobject] but isn't another dictionary an Anyobject?

A: There's not enough info in your request for the compiler to infer the correct type (it's inferring an NSDictionary instead, probably because of the nested dictionary). Simply modify your declaration to help things along.
let reqJson: Dictionary<String, AnyObject> = [
    "asdf": "sdfs",
    "lsd": "asdf",
    "asdf" : "coc",
    "qwer": "sdf",
    "cvc": "kljb",
    "xcv": "qwe",
    "versions": [
        [
            "version": "abc",
            "component": "xyz"
        ]
    ]
]


text:
Q: NSDate between two dates Is this a good way to check if serverOnNowDate is between publishedStartTime  and  publishedEndTime?
 return !( [self.publishedStartTime compare:serverOnNowDate] == NSOrderedDescending
        || [self.publishedEndTime compare:serverOnNowDate] == NSOrderedAscending );

A: Written as a instance method:
- (BOOL)isBetweenDate:(NSDate *)earlierDate andDate:(NSDate *)laterDate
{
    // first check that we are later than the earlierDate.
    if ([self compare:earlierDate] == NSOrderedDescending) {

        // next check that we are earlier than the laterData
        if ( [self compare:laterDate] == NSOrderedAscending ) {
            return YES;
        }
    }

    // otherwise we are not
    return NO;
}

Usage:
NSDate *date = [NSDate now];

if ( [date isBetween:startDate andDate:finishDate] ) {
    NSLog(@"Between dates!!!");
}

A: You can use the below method
- (BOOL)inputDate:(NSDate*)date start:(NSDate*)beginDate end:(NSDate*)endDate
{
    if ([date compare:beginDate] == NSOrderedAscending)
        return NO;

    if ([date compare:endDate] == NSOrderedDescending)
        return NO;

    return YES;
}