w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I run custom js function when angular js finished retrieving data from the server (and updating the dom)?
If you want to react to only specific interpolation changes (in your case, user.articles) you could set a $watch listener for it in your controller: $watch('user.articles.length', valueChanged); And if you want to run some code only after DOM is changed: var timeout; function valueChanged () { if (!timeout) { // only run doStuffWhenDOMChanged when the $digest loop is finished and call stack is empty: timeout = $timeout(doStuffWhenDOMChanged, 10); } } function doStuffWhenDOMChanged() { //do stuff here... timeout = null; }

Categories : Angularjs

How to post single in jquery ajax, after all events finished?
var dataToPost = new Array(); var isButton1Clicked = false; var isButton2Clicked = false; //panel1 $("#save").click(function() { isButton1Clicked = true; dataToPost['panel'] = btoa($('#blob1').val()); checkAndSubmit(); }); //panel2 $("#save").click(function() { isButton2Clicked = true; dataToPost['panel2_amount'] = $('#multi').val() * $('#multi2').val() + 1; dataToPost['crc32'] = crc32($('#blob2').val()); checkToSubmit(); }); //some magic function function checkToSubmit() { //make only ONE ajax request, saving data from all panels if (isButton1Clicked && isButton2Clicked) { $.ajax({ type: 'POST' data: dataToPost }); } }

Categories : Javascript

NullPointer Exception while updating UI from AsyncTask is Finished
I think for your ProgressDialog null and async onPreExecute method override implement and solve for your excepiton, @Override protected void onPreExecute() { super.onPreExecute(); mProgressDialog = ProgressDialog.show(YourActivityName.this, "wait", "loading"); }

Categories : Java

Socket.io emitting and broadcasting events but wont "hear" events from the server
You are mixing up your client and server logic. This code (from your template): socket.on('addUser', function (data) { console.log("ADDING NEW USER:"); req.session.user = data; console.log(data); $("#usernames").append('<p>'+data+'</p>'); }); Is executing on the client side where there is not req object available. By default, socket.io and express sessions don't play together - you need to add some additional logic to your app. There are several projects that aim to make this easier such as: express.io session.socket.io

Categories : Node Js

How to stop Jquery from running more than once until the script is finished
You can use the following code inside your function: $(document).ready(function() { $('#search-container .trigger').mouseover(function(e) { $('section .search-bar input').stop(true,true).animate({width:"150px"}, 750, function(){ $(this).find('input').first().focus(); }); $('.search-bar').stop(true,true).animate({width:"185px"}, 750, function(){ $(this).find('input').first().focus(); }); }); $("#search-container .trigger").mouseleave(function(e){ $("section .search-bar input, .search-bar").stop(true,true).animate({width:"0px"}, 750, function(){ $(this).find('input').first().focus(); }); }); });

Categories : Javascript

How to use perl script to monitor whether a process is finished?
You could open a named pipe and wait for it to close: open(PROC, "-|", "/path/to/process") or die "can't open process: $!"; # do something close(PROC) or die "can't close process: $!"; The close statement will make the perl script wait for the process to finish.

Categories : Perl

Node.js terminates execution before script is finished, connecting via socket.io-client
I'd start by seeing if socket.io is throwing any errors: socket.on('error', function (exception) { console.log(exception); }); I'd also look to see if you're connecting to the right port. It's probable that the remote socket.io server is not on a default port.

Categories : Node Js

Is there a way to tell if a Jenkins server has finished shutting down?
This is the most ghetto hack. What I'm basically doing is looking at the error output from the java command that executes the Jenkins CLI jar file, and if the error output contains "Failed to connect", I assume that the Jenkins has been shut off. I would love to see if anyone has a more graceful solution, cause man, this is just gross. while(!$JenkinsIsDown) { Write-Host "Getting the session ID from Jenkins to check if it's down..." #This is a terrible hack so we can process the output of the command $JenkinsProcess = New-Object System.Diagnostics.ProcessStartInfo $JenkinsProcess.FileName = "java" $JenkinsProcess.RedirectStandardError = $true $JenkinsProcess.RedirectStandardOutput = $true $JenkinsProcess.UseShellExecute = $false $JenkinsProcess.Argume

Categories : Batch File

Updating UI from events using asyc await
You should use Invoke method of Control. It executes some code in Control's thread. Also you can check InvokeRequired property to check if you need to call Invoke method (it checks if the caller is on a different thread than the one the control was created on). Simple example: void SomeAsyncMethod() { // Do some work if (this.InvokeRequired) { this.Invoke((MethodInvoker)(() => { DoUpdateUI(); } )); } else { DoUpdateUI(); } } void DoUpdateUI() { // Your UI update code here } In some cases you should check the IsHandleCreated property of Control before calling Invoke method. If IsHandleCreated returns false then you need wait while Control's handle will be created

Categories : C#

Forcing server to wait because image haven't finished writing to disk
Let's say UserA uploads a file while UserB browses normally. After UserA uploads a file, does UserB experience the 2 second delay? UserB will only experience a delay if UserB's and UserA's requests are being handled by the same thread, which is not the case since most web servers use a separate thread to handle each connection. Thread.sleep(2000) be the best code to use? No, this is probably not a good way of doing things. Aside from tying up the cpu, you are explicitly having the thread wait 2 seconds before attempting to access the file when you have no guarentee that the file will be ready at that point. It would be better to try leverage Java's wait() and notify() Object methods for concurrency. However, I do not know if that is necessariy since you should know when the

Categories : Java

Reading CSV files located on LINUX server and updating the tables in SQL Server Database
Since you know how to proceed once the csv file is on your Windows box, it seems this question amounts to how to get the file from a Linux server to a Windows server. I suggest rcp or rsync. There are Windows versions of both.

Categories : Linux

Server Sent Events, server-side code
Your understanding is correct. PHP needs to keep running, and in PHP you will need a loop, and you'll quickly run out of free Apache threads. If you need to handle lots of connections you need to use event-based server like Node.js or Tornado that can handle lots of open connections. If you'd rather use PHP, then a partial solution is to close connection after few seconds. The browser will reconnect, so you'll get a hybrid of polling and SSE. In PHP you can check sys_getloadavg() to decide whether you can keep connection open or you're running short on free processes.

Categories : PHP

Ajax - using the script to load different 'events'
Add an additional argument to your loadXMLDOC function which takes the URL to load. e.g.: function loadXMLDoc(url) { ... xmlhttp.open("GET",url",true); xmlhttp.send(); } Then change your onclick methods: <div class="" onclick="loadXMLDoc('../home/indexFav.php')">Everyone</div> <div class="" onclick="loadXMLDoc('../home/indexAll.php')">Favourites Only</div>

Categories : Ajax

Updating CRON with bash script
I would offer this shorter version: crontab -l | sed '/cd /s#/5#/10#' | crontab - which should change 5 to 10 where the line has cd. Or use anm.sh in place of cd as an address to be more specific in case there is more than one cd line: crontab -l | sed '/anm.sh/s#/5#/10#' | crontab -

Categories : Linux

Chrome Extension's Content Script catch custom events?
Yes, content script can communicate with the injected web page. Because the context of content script and injected web page are isolated from each other, they must communicate with shared DOM. I think content script can't catch the custom event which was fired by injected page directly. But you can post message to content script when specific custom event is fired. window.postMessage can fit your needs. Injected page: <!DOCTYPE html> <html> <head> <title></title> </head> <body> <button id="btn">test</button> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $("#btn").click(function(){ $(document).trigger("MY_EVENT"); }); $

Categories : Javascript

clashing events triggered by same click from separate script functions
You're on the right track with using a callback. You need to trigger the marker click after the scrolling has completed. If the issue your facing is your scripts are hiding functions from one another, create a global application object and place the functions needed in there. You'll also want to remove the javascript from the href attributes and replace them with another data attribute with the corresponding id. <ul class="chart"> <li><a data-slide="3" data-id="bond">Bond Street</a></li> <li><a data-slide="3" data-id="barbican">Barbican</a></li> </ul> Create a application wide object to store functions window.myapp = {}; Add the triggerClick function to this object myapp.triggerClick = function(){...}; Now call thi

Categories : Jquery

Google App Script not updating after saving changes and publishing
The "latest code" URL is a developers-only address, with a unique ID followed by /dev. Only the owner of the script can access this, and it will always show the results of the current code. The published application has a URL with a different unique ID followed by /exec. To show results of updated code, the author must first save a new version, then publish that version.

Categories : Google Apps Script

Google Spreadsheet Script not Updating Dynamically
I tried adding the GoogleClock() parameter, and it seemed to work fine. For example, in D2: =COUNTIF(getColor("Neshig";GoogleClock()),"#00FF00") This made it update on the minute.

Categories : Google Apps Script

Jquery script to catch link click events for Universal Analytics
From what you have given there are few things that can go wrong there There is no base tag in the page. You need to have a <base href="" /> in the page The script is added inside head . Then the body element is still not loaded so you need to add the script inside dom ready handler/register the delegated handler to document object instead of body Assuming jQuery is loaded correctly and it is added before this script try <base href="yourbaseurl" /> then if (typeof jQuery != 'undefined') { jQuery(function(){ var filetypes = /.(zip|exe|dmg|pdf|doc.*|xls.*|ppt.*|mp3|txt|rar|wma|mov|avi|wmv|flv|wav)$/i; var baseHref = ''; if (jQuery('base').attr('href') != undefined) baseHref = jQuery('base').attr('href'); var hrefRedirect = ''; j

Categories : Javascript

How to get jQuery click events to fire from a dynamically Generated Ajax script
It's not necessary to defer binding the event handler; use event delegation to listen from a parent element // or some other more immediate parent element $( "body" ).on('click', 'a.chainSelected', function(event) { alert('clicked'); event.preventDefault(); return false; });

Categories : Jquery

Chrome extension auto updating selective script
Chrome downloads the extension as a zip file, which essentially means that it replaces the entire crx file when you (the developer) update your extension. If you want to have fine grained control of you assets you will need to host them outside the extension/app and store them in the HTML5Filesystem that is associated with your extension.

Categories : Javascript

Script not posting input to PHP server script.
Your dataString is incorrect, you forgot a '&' between vars : var dataString = 'mac=' + mac + '&store=' + store; Plus there is no need for a string, just pass an object, jQuery will do the rest : $.ajax({ type: 'POST', url: 'ajax/subscribe.php', data : {mac: mac, store: store}, etc...

Categories : PHP

How to load test Server Sent Events?
I took a simple path of creating a shell script that initiates N background jobs of cURL which connected to the SSE endpoint of my service. To get the exact cURL syntax, open your Chrome web dev tools -> Network tab -> right click on the entry of the request to the SSE endpoint and choose from the context menu "Copy as cURL" Then you paste that command in a shell script that roughly looks like: #!/bin/bash i=0; while [ $i -lt 50 ] ;do [PASTE YOUR cURL COMMAND HERE] -s -o /dev/null & i=`expr $i + 1`; done This will add 50 background cURL jobs each time it's run. Notice that I added to Chrome's cURL command the params -s -o /dev/null. This is to run cURL in silent mode and to suppress any output. In my case the service was implemented in NodeJs, so I used process.hrtime()

Categories : Misc

iOS events to load data from server
You should have a method applicationWillEnterForeground: in your AppDelegate. This method is called each time the app comes back to the foreground - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. }

Categories : IOS

Server Sent Events and Rails Streaming
The way that SSEs are built is by the client opening a connection to the server, which is then left open until the server has some data to send. This is part of the SSE spec, and not a thing specific to ActionController::Live. It's effectively the same as long-polling, but with the connection not being closed after the first bit of data is returned, and with the mechanism built into the browser. As such, the only way it can be implemented is by having multiple open client connections to the webserver which sit there indefinitely. As to what resources are required to deal with them, I'm not sure, as I've not yet tried to benchmark this, but it'll need enough servers for Puma to keep open thousands of connections if you have that many users with a page open. The default limit for puma is 1

Categories : Ruby On Rails

Server sent events and browser limits
You are right about the number of simultaneous connections. You can check this list for max values: http://www.browserscope.org/?category=network And unfortunately, I never found any work around, except multiplexing and/or using different hostnames.

Categories : Javascript

Sending Server-Sent-Events through a socket in C
Each line in an HTTP header needs to be terminated using . See rfc2616 section 2.2 Basic Rules CR = <US-ASCII CR, carriage return (13)> LF = <US-ASCII LF, linefeed (10)> HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all protocol elements except the entity-body Your example just uses so the headers may appear to all be part of a single line to some simple http clients. Try changing to ending each line that isn't part of the entity using

Categories : C

How to use python script to start other python scripts and check whether all "child scripts" are finished?
Try swapping the location of r.wait() and po.close() if __name__=="__main__": for dirpath, dirname , filenames in os.walk(rootdir): for filename in filenames: if filename=='Test.py': argument.append( [ dirpath, filename ] ) print argument po=multiprocessing.Pool() r=po.map_async(Openpy, argument) r.wait() po.close() It might not be your problem, but it looks like maybe you are closing the pool before the result is evaluated.

Categories : Python

How to import data via post deployment script from SQL Server CE into a SQL Server DB freshly created using VS database project
1) Is it possible to reference a SQL Server Compact database (sdfDB) in T-SQL script? If you are thinking to something like this, INSERT INTO [SQL SERVER Db].Table (Values) SELECT (Values) FROM [Sql Server Compact Db].Table unfortunately no, this is not possible. 2) If not, what is the best practice to import data into a freshly created DB from an embedded datasource which can be deployed by build script in a remote machine. You can use the SQL Server Compact Toolbox, that contains features to generate scripts from a Sql server compact file, that you can use to populate the SqlServer database. Features: Script! Migrate a SQL Server Compact database directly to SQL Server (LocalDB/Express) Migrate from SQL Server Compact to SQL Server, SQL Azure and SQL

Categories : Visual Studio 2012

Script working fine on development server but not remote server
If its timing out on the server it's more than likely because a link to a resource in your script is not pointing to the correct location. Leading to a function call not working or other resource not being found.

Categories : PHP

Running script on a remote server in bash working on 1 server, not on the other
It's just a guess but i would try this filename=hostnames > export.log while read -r -a line do hostname=${line//"} echo $hostname":" >> export.log ssh -t -t $hostname "bash -s" < script.sh >> export.log & done < "$filename" exit Just to make sure you don t get stuck on one server.

Categories : Bash

Why is my python script that runs the adb shell monkey command crashing for large values of events?
This might be your problem, but it's hard to tell without more information… You've given the subprocess a pipe, but you don't read from it until after it's finished. The warning in the docs explains why this is bad: This will deadlock when using stdout=PIPE and/or stderr=PIPE and the child process generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data. Use communicate() to avoid that. It makes perfect sense that it would work for small numbers of commands—when there's not enough data to fill the pipe buffer—but hang for larger numbers. Looping around poll instead of calling wait doesn't help anything; all it does is burn 100% CPU for no reason. You're still not reading from the pipe. And calling communicate after the process

Categories : Android

How does Ember.js listen to events fired off from the server?
I don't think ember can listen to the callback event. However, within your callback you can update a value in an ember object. For example, here's some code of an ember controller, and a callback Ember controller App.MyController = Em.ObjectController.extend({ authenticated: false, updateAuthStatus: function() { Em.debug("We're auth status updated and is now: " + this.get('authenticated'); }.observes('authenticated') }); Callback function(authenticated) { if (!authenticated) { alert("Authentication failed") } else { App.__container__.lookup("controller:my").set('authenticated', true); } } Better yet, have your passport authentication run from within an ember controller then you won't have to find the controller using the lookup function (and will probably al

Categories : Node Js

Server sent events - cross domain safari
WebKit doesn't support CORS in SSE yet. Solutions: Fetch from the same origin, new EventSource("/app.php"); Use CORS-aware polyfill for Safari. https://github.com/Yaffle/EventSource Create iframe at same origin that your SSE stream (http://mydomain.org/iframe.html), read same-origin stream in the iframe, and use postMessage() to send events to other origins.

Categories : PHP

How do you create and detect one-time Server Sent Events?
You likely want to use Web Sockets. Socket.io is great if you're using node.js but there are also php libraries to help you out,

Categories : PHP

How to handle events from Server in each Client thread
Implement a pub/sub pattern. You can use MemBus for in-process message bus. It can be easily configured and supports both synchronous and asynchronous processing. Your Server will be pushing IData events to the bus and multiple Clients that subscribe to the same bus will receive the messages in the same order as the server sent them. Each Client instance can be called on a separate thread.

Categories : C#

updating nulls value in sql server
You can declare @location_ID as null CREATE PROCEDURE update2 @SSN INT , @Employee_FirstName VARCHAR(50) , @Employee_lastName VARCHAR(50) , @gender_ID INT , @Department_ID INT , @location_ID INT = NULL , @salary DECIMAL(18, 3) AS UPDATE Employee SET Employee_FirstName = @Employee_FirstName , Employee_lastName = @Employee_lastName , gender = @gender_ID , Department_ID = @Department_ID , location_ID = @location_ID , salary = @salary WHERE SSN = @SSN

Categories : SQL

Rails: I want Server Sent Events. Do I have to drop Phusion Passenger?
Server Side Events works great on Phusion Passenger. I wrote a demo for you. Check out https://github.com/phusion/passenger-ruby-server-side-events-demo Hongli Lai, Phusion CTO Phusion Passenger developer

Categories : Ruby On Rails

HTTP: what are the relations between pipelining, keep-alive and Server Sent Events?
Yes, FIFO. TCP/IP guarantees delivering data in-order, so responses can't arrive in a different order (if the server/proxy is buggy and sends responses in wrong order then you're totally screwed). I don't recall any reason per HTTP spec. It may be just caution, because pipelining is poorly implemented in some proxies/servers. HTTP spec suggests 2 connections per server, browsers have settled on 6-8 connections per server, but there is no fixed limit. Running out of connections is a real problem for Apache, and for high-load situations it's recommended to disable KeepAlive in Apache and use a proxy (e.g. HAProxy) that can cheaply provide Keep-Alive functionality to clients. The benefit of a proxy is that one proxy can distribute connections to several servers (helps scaling), or can modif

Categories : Http

Handling Onload events to add server side logic in ADF
There are multiple ways of doing this, including doing this in a method call in the taskflow before you reach the page. Some options: https://blogs.oracle.com/adf/entry/an_epic_question_how_to

Categories : Oracle



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.