w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
I have my code running on jsfiddle, but why can't on local computer?
use either, $(document).ready(function() { // Handler for .ready() called. }); or $(function() { // Handler for .ready() called. }); instead of $document.ready(function(){ // Handler for .ready() called. });

Categories : Javascript

Knockout validation hello world not running on jsfiddle
There is nothing wrong with your code. However the current version of the validation plugin on (cdnjs 1.0.2) is quite old and it has a bug which prevents the ko.validation.registerExtenders working correctly. This bug has been fixed since then. As a workaround you need to call ko.validation.registerExtenders() at the start of your fiddle: ko.validation.registerExtenders(); var Vm = function(){ var self = this; self.validatableField = ko.observable().extend({ equal: "2" }); self.alertValue = function(){ alert(self.validatableField()); }; }; ko.applyBindings(new Vm(), document.getElementById('vm')); Demo JSFiddle.

Categories : Knockout Js

script works in jsfiddle but not in site
You need to load the script in a $(document).ready() handler. Fiddle adds it for you. Hence it is working there. $(document).ready(function () { $("#issues > li").click(function () { var $img = $("#theimg"); var $li = $(this); var newsrc = ""; newsrc = $li.data("img"); if (newsrc === undefined) newsrc = "issue" + $li.index() + ".jpg"; var loadstep = 0; function endstep() { // end of preload or hide if (++loadstep === 2) // if the preload is done and hide too, change src and show picture $img.attr("src", newsrc).animate({ opacity: 1 }); } // preload picture var $tmpimg = $("<img/>", { src: newsrc }).on("load", endstep);

Categories : Javascript

My script works in jsFiddle but not in my webpage
If you put the script link into a browser, it returns an error message: Sorry! Gadget cannot be displayed until all required settings are provided. So I would guess that you haven't fully configured it.

Categories : Misc

code working fine in jsFiddle site but not running on my desktop tools
This works: var a = ['option a', 'option b', 'option c', 'option d', 'option e', 'option f']; var b = ['good', 'ok', 'bad', 'excellent', 'average']; function init() { for (var i = 0; i < a.length; i++) { var ele = document.getElementById('scroll-content2'); var table = document.createElement('table'); table.className = 'table2'; var tr = document.createElement('tr'); tr.className = 'c2'; var td = document.createElement('td'); var txt4 = document.createTextNode(i + 1 + "." + " "); var txt = document.createTextNode(a[i]); td.appendChild(txt4); td.appendChild(txt); for (var j = 0; j < b.length; j++) { var divi = document.createElement('div'); divi.className = 'divi';

Categories : Javascript

Jquery script works in JSfiddle but not on html page
The problem might be, in jsfiddle the script was executed on dom ready (fiddle not working outside the dom ready handler).... but in your page it doesn't look like that In jsfiddle the second dropdown in the LHS panel selects the place where the script will be added, by default it is added as a window.onload handler. So move the invocation of icon_hover to a dom ready handler jQuery(function(){ icon_hover(); }) Demo: Fiddle

Categories : Javascript

Simple JQuery script working on JSFiddle, not on my site
Use that to be sure that your code will be executed after the html loading. $(document).ready(function(){ var img = new Image(); img.src = $('#imageViewerImg').attr('src'); img.onload = function() { var imgWidth = this.width; } if($imgWidth > 700) { $("#photoHolder").css({"vertical-align":"none","text-align:":"none"}); } });

Categories : Jquery

Is it possible to import the javascript from a jsfiddle as an external resource into another jsfiddle?
I've been scouring the web for resource that might help you. This should help. Apparently, you cannot do this. As fiddles are only meant to be temporary test for logic without the hassle of setting up folder structures in your personal computer. Hope this helps.

Categories : JSF

Simple jQuery Script Not Working FadeIn/FadeOut Based on Scroll Height (Does on jsfiddle)
You are using jQuery.noConflict() then you try to use $ The code uses scrollHeight() instead of scrollTop() Here it is how it should look your code: (function($){ var $window = $(window); $window.scroll(function(){ if ($window.scrollTop() >= 162) { $('.small-logo').fadeOut(); } else { $('.small-logo').fadeIn(); } }); }(jQuery)); This is your current code: $(window).scroll(function() { if($(window).scrollHeight()>=162) { $('.small-logo').fadeOut(); } else { $('.small-logo').fadeIn(); } });

Categories : Jquery

Running a .py script from bash, how can I pass a python variable back to the terminal once the .py is done running?
You can write your variable and its value into an ini file from the python script. In Values.ini file my_var="value" After executing python script, just invoke Values.ini using . operator . Values.ini Now your shell variable $my_var will be having the assigned value. The advantage with this method is that you can assign any number of variables like this. var1="value1" var2="value2" var3="value3"

Categories : Python

Running pig script gives the error as: job has failed. Stop running all dependent jobs
After some research, I found that the problem here is LeaseExpiredException. This might be because the output of mapper was removed. One of the reason for this might be due to the quota allocated for the user. In my case, I was running this script in a very large data, and my quota was insufficient to process/store the data. We can check the quota by the following command: hadoop fs -count -q /user/username Thank you.

Categories : Hadoop

Running python script on crontab is causing permissions errors but running via terminal is fine
@Lucas Ou-Yang @Hyperboreus as Hyperboreus said it depends on the user privilege who run it . i think that if you give the /tmp/ dir a 777 permission from the root account it'll be fixed : chmod 777 -R /tmp/ okay try with : chmod 777 /tmp/ if the error still check if the directory /tmp/ exist !

Categories : Python

Re-installing Linux O.S. and then running bunch of commands in a .sh script , how to stop the script if something fails?
You can check the error code from commands you run #!/bin/bash function test { "$@" status=$? if [ $status -ne 0 ]; then echo "error with $1" exit 255 fi return $status } test ls test ps -ef test not_a_command taken from here for more information Bash Beginner Check Exit Status

Categories : Linux

How to run a script that it has to connect 3 solaris servers, do some operations and create files in the machine where the script is running?
Use sshfs to mount the needed directories of your three servers. Afterwards you can run the script locally accessing the remote data as local files.

Categories : Bash

sys module giving different output when running Python script through IDLE and by double-clicking the script
print os.path.dirname(sys.executable) is what you should use. When you click it it is probably running through python.exe so you are removing the extra char from the w.

Categories : Python

Cron not running Python script is script not in home folder
cron is running crontab(5) entries from the home directory of the user. You need to change appropriately the directory i.e. to call the chdir(2) syscall (either thru the cd shell builtin, or inside your python script using os.chdir). You should query the current directory (using getcwd(3), or the pwd command, or the os.getcwd in Python) in your script. Also check your PATH if running commands.

Categories : Python

error with global name when running a script from another script - python
This is a pretty interesting problem. First a quick workaround, you can provide dictionaries to use as the local and global namespace when calling execfile(), using an empty dictionary for globals works fine: # test_fun1.py a = 1 def test1(): print a execfile('test_fun2.py', {}) test1() Alternatively, if you want the code to execute within the global scope of your module you can use globals() instead of {}. Now on to why this isn't working... from the documentation on execfile(): If both dictionaries are omitted, the expression is executed in the environment where execfile() is called. Here "both dictionaries" is referring to the optional globals and locals arguments to execfile(). In this case "the environment where execfile() is called" is the local scope of the fun

Categories : Python

Running a variable script with parameters through a script
If you do this: #!/bin/sh for app in "$@"; do sh "jboss-$app" restart done Then you can pass a space-separated list of app names to the script ./restart-apps app1 app2 app3 ...

Categories : Shell

When running Python's pdb as a script, how do I autostart the script?
that's probably not the way to do to it. you should modify/extend the existing pdb.py. the code looks like this: while True: try: pdb._runscript(mainpyfile) if pdb._user_requested_quit: break print "The program finished and will be restarted" except: traceback.print_exc() print "Uncaught exception. Entering post mortem debugging" print "Running 'cont' or 'step' will restart the program" t = sys.exc_info()[2] pdb.interaction(None, t) print "Post mortem debugger finished. The "+mainpyfile+" will be restarted" it looks like you could replace `pdb._runscript(mainpyfile)' with something like runpy.run_module(sys.argv[0], run_name="__main__", alter_sys=True) (from PEP 338). not a complete solutio

Categories : Python

[three.js]: script running in IE10, not running as HTA
Okay, problem understood... solution is tricky. When using Three.js code within an HTML application (HTA), then the HTA uses IE7 quicks mode by default. You can easily add the following line to the Three.js HTA: <meta http-equiv="X-UA-Compatible" content="IE=IE10" /> But then, no more HTA mark-up is understood (windowstate, applicationname - to mention just a few) since the MS IE team wants to "focus more on standards" :-( But there is a trick which works... Create an empty HTA using all the mark-up code that you like, for example: <hta:application windowstate="minimize" border="none" icon="myIcon.ico" /> Do NOT use the IE10 X-UA-Compatible meta statement here. Create an onload javascript function within that HTA that loads the THREE.js HTML page to document.location.

Categories : Internet Explorer

Don't run script if it's already running
Try using ignore_user_abort(true); it will continue to run even if the person leaves and closes the browser. you might also want to put a number instead of true false in the db record and set a maximum number of processes that can run together

Categories : PHP

Running a PHP script
What you need to do is to fork the process before you terminate it. This way when you exit the process (or close your ssh connection) the secondary process will continue to run. $pid = pcntl_fork(); if ($pid == -1) { die('could not fork'); } else if ($pid) { // parent pcntl_wait($status); } else { // child // write your code here! }

Categories : PHP

running pig script
I have not used node.js. But here I find a link to show how to execute a unit command in node.js: http://www.dzone.com/snippets/execute-unix-command-nodejs For example, if you want to run a pig script called foo.pig. Then you can try the following code: var sys = require('sys') var exec = require('child_process').exec; function puts(error, stdout, stderr) { sys.puts(stdout) } exec("pig -f foo.pig", puts); You can replace pig -f foo.pig to any command that you use to run your pig script.

Categories : Node Js

Running a script from within a shell
the sage shell is a process running in the foreground and due to the sequential nature of your script, the sage shell has to finish running before the next line of the script is executed. It is after the sage shell exits that the easy_install line is run. The script is performing as written.

Categories : Python

Running a php script with a .bat file
The START command optionally accepts a title for the created window as its first argument; in this case, it thinks that C:Program Files (x86)PHPv5.3php.exe is the title to display and -f (the second argument) is the executable you want to run. You can therefore fix this by providing a placeholder title, e.g. start "email reminder task" "C:Program Files (x86)PHPv5.3php.exe" -f C:inetpubwwwrootsitenamecrons eminder-email.php Or, preferably, you can ditch the START command altogether (you aren't using any of its unique facilities) and just run PHP directly: "C:Program Files (x86)PHPv5.3php.exe" -f C:inetpubwwwrootsitenamecrons eminder-email.php

Categories : PHP

Running exec in a script
exec will only give you the last line ... your probably want to use passthru <?php if ($_GET['run']) { # This code will run if ?run=true is set. passthru("./check_sample.sh"); } ? For passing parameters you can just form the add it to the command like this. (escapeshellarg will handle the escaping and quoting of the value for you) passthru("./check_sample.sh ".escapeshellarg($_POST["fieldname"])); If you need the output as a string your options are to use popen or surround the passthru in an output buffering block: ie: ob_start(); /* passthru call */ $data = ob_get_clean();

Categories : PHP

Running a script for certain days
Put this in your crontab: */20 * * * * bash /path/to/your/script.sh Then remove it after 10 days. Better yet, have your script check the current date and send you an email when it's 10 days from now to remind you to remove it. You could also just have the script remove the line from the crontab (or just remove the crontab file if it's only got this one line) after 10 days.

Categories : PHP

Running two scripts as one script
You have already identified the basic problem: The need to run the sending and the receiving concurrently. You must delve into multi-threading. The basic design pattern could be: Create a thread for the receiving part with a flag for cancelling it. Loop infinitely doing the following: check to see if there is inbound data; if there is receive it and output it; sleep a timeout; break if the cancellation flag is set. On the main thread, create your receiver and start it, then enter your input loop: If the user inputs a message, send it on the same thread. If the user types 'exit', set the cancellation flag on the receiver thread, wait for it and exit. More or less: class Receiver (Thread): def __init__ (self): super (Receiver, self).__init__ () self.cancelled = False

Categories : Python

Keep UI updated while script is running
You can try researching WebWorkers. Or you can split your work into separate chunks and call each chunk after the next using setTimeout with a timeout of 0. setTimeout( function() { executeNextChunk(); }, 0 ) This gives the browser time to do other stuff in between invocations.

Categories : Javascript

Why isn't my 'cycle' script running?
Also include Jquery.min.js <script type="text/javascript" src="scripts/jquery.min.js"></script> before your cycle.js Wordpress has already Jquery Loaded so you can remove your jQuery.js from your script and try ..I suppose its mere Jquery Conflict

Categories : Javascript

Script is not running at the same time as the loop
Definitely your addGraph complete function gets called asynchronously. You can work around this like this. <script> console.log ("LOOP"); var impressions = [<?= implode(",", $prod_impression_dots) ?>]; var testdata = [ { "key" : "Impressions" , "type": "line", "values" : impressions, "yAxis": 1 } ].map(function(series) { series.values = series.values.map(function(d) { return {x: d[0], y: d[1] } }); return series; }); nv.addGraph((function (testdata) { return function() { console.log ("Add graph is called here"); console.log (testdata); var chart = nv.models.multiChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .x(function(d,i) { return i })

Categories : PHP

Java not running shell script
Verify two things: If you have modified the perl script, make sure it has #!/bin/perl in the first line, same for your shell script, it must have #!/bin/sh or #!/bin/bash if you are specificaly using bash. Your moved files must have executable permissions, change them with something like .chmod 755 myFile.

Categories : Java

bat file running py script in different directory
Ultimately there needs to be some way to tell your script what you are needing to process. There's a variety of ways for that, but it really just needs to happen. I think the most obvious thing to do in the batch file is to copy the target file in place before running your Python script. However, a cleaner solution might be to take a command line argument into the python script (via sys.argv) which tells the script which file it needs to process.

Categories : Python

How do you debug a LONG RUNNING php script?
Xdebug does not have functionality for this. Using pcntl_signal and then using xdebug_print_function_stack is an option, but what you can also do is to create a "function trace". This is something that makes Xdebug write every function call to disk as soon as they happen. This should be able to tell you where your script hangs. From what I can see though is that is waiting for IO. There is more information about function traces at http://www.xdebug.org/docs/execution_trace

Categories : PHP

How can I update the current script before running it?
Yes, you can update the script you're running, then execute it again. (Just make sure to exit the first script after updating.) Here's some sample code I created: Write-Host "Starting script" if ($(Get-Item G:selfUpdater2.ps1).CreationTimeUtc -gt $(Get-Item G:selfUpdater.ps1).CreationTimeUtc) { Copy-Item G:selfUpdater2.ps1 G:selfUpdater.ps1 $(Get-Item G:selfUpdater.ps1).CreationTimeUtc = [DateTime]::UtcNow &G:selfUpdater.ps1 exit } Write-Host "Continuing original script; will not get here if we updated." Note that, if you have parameters to pass around, you'll have to pass them to the target script. Since your updated script may well have more or fewer parameters than your current script (some bound, some unbound by the current script), you'll need to iterate through

Categories : Powershell

Xdebug interrupts the running of PHP script
500 (Internal Server Error) in phpstorm 9.0 when enabling xdebug breakpoints. Validate your whatches for php session. Errors in whatches can generate errors in executing php code. Errors disapears when you disable xdebug listening or correct/remove whatches.

Categories : PHP

Check if server running script?
First find IP address of the machine requesting the link by: if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } Now $ip is IP address of the requesting machine. And let's say your computer IP is 123.456.789.1 (something like that) So let's assign it to a variable $server_ip = "123.456.789.1"; Now if($ip == $server_ip && isset($_GET['reloadImages'])){ echo "<img src="site.com/image.jpg" />"; exit; } else{ echo "Sorry! you cannot see"; }

Categories : PHP

302 Found when running the Perl Script
You print your HTTP header here: print $q->header Then you print another HTTP header here: print $q->redirect($client->get_login_url()); An HTTP message can have only one set of headers. If you're sending a 302 redirect, then there's no need to print any HTML either, so get rid of all of this: print $q->header, # create the HTTP header $q->start_html('Facebook App'), # start the HTML $q->h1('Facebook Authentication'), # level 1 header $q->end_html; # end the HTML

Categories : Perl

Error on running database script
ALTER DATABASE [MYDATABASE] SET COMPATIBILITY_LEVEL = 100 SQL Server 2005 doesn't have this command yet - new feature of SQL Server 2008. You need to use this instead: EXEC sp_dbcmptlevel AdventureWorks, 90; Level 90 = SQL Server 2005 - that'll work; level 100 is SQL Server 2008 which will not work in SQL Server 2005 obviuosly..... ALTER DATABASE [MYDATABASE] SET HONOR_BROKER_PRIORITY OFF EXEC sys.sp_db_vardecimal_storage_format N'MYDATABASE', N'ON' Those are both new features in SQL Server 2008 or newer and don't have any equivalent in SQL Server 2005. The vardecimal storage format isn't supported (nor needed) in SQL Server 2005.

Categories : Sql Server

How to detect a running script on windows?
You can use the isAlive method on the thread to check if it is already running. On similar lines, if you were running a process instead, then you could write a pid file everytime you start the process and query the OS for the status of that specific pid anytime you required. Check the following link for more on isAlive. http://docs.python.org/2/library/threading.html#threading.Thread.isAlive

Categories : Python



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