w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Referencing NodeJS Net Sockets outside of the connection context
Sockets should have unique identifier. If they are not identified uniquely on connection layer, then you have to create identification your self manually. It can be processId + increment or any other network reliable identification. Then there is worker that has socket and is responsible for handling its message queue as well as sending messages. Redis can easily store ID of sockets, but have to store worker ID that this socket is bound as well. Then you need to have direct communication between workers in order to be able to send messages to each other. This can be done through Redis by having message queues for workers or sockets, and workers responsible for this sockets will pull messages and process them for sending. Or you can have direct communication from workers to workers for exa

Categories : Node Js

Nodejs cron plugin vs running nodejs script from crontab
The main difference between the two methods in my opinion would be the level at which you want to schedule job. When using crontab your jobs are scheduled by the cron daemon that runs on the system. node-cron on the other hand is a pure JavaScript implementation of cron. So system is not responsible for running jobs but your V8 engine which executes it. Jobs will be run as long as your js application runs. So why would you use one or other ? That depends on the purpose of your job, where is it best tethered . If job is a maintenance job for system run it via crontab. If you want to run a function in node.js periodically use node-cron. If you want to run a bash script you would want to use crontab. So how you want to do it via system (bash) or JavaScript is upto you.

Categories : Node Js

Is it feasible to send media files(images/ video/ pdf etc...) from a server to another server through Html Fom?
1. Usage of ftp (make sure to use an encrypted connection, not plain ftp) and scp, where you can use ssh public key authentication, which is equally safe as storing your mysql password, just make sure the credentials are not accessible. You will need any kind of authentication anyway (also for html/php) 1a. Rsync + crontab Isn't it possible to use some kind of cronjob and rsync to do the task? 2. To receieve send a file with curl <?php $url = 'http://target-server/accept.php'; //This needs to be the full path to the file you want to send. $file = realpath('./sample.jpeg'); // the post fields. // note the "@", to denote that the file path should be evaluated $post = array( 'extra_post_field' => '123456', 'file_contents' => '@' . $file ); $ch = curl_init(); curl_setop

Categories : PHP

Run nodejs command line module to output in nodejs web server?
you could have 2 node instances. One the http server and the second instance the command line instance to run jasmine. The http server instance would spawn the command line instance. Then you could register a GET route on the http server such as someexample.com/runtests which would call the tests and wait for the tests to finish and respond with the console output. This is sort of unorthodox, but there wouldn't be a direct way to run command line applications through the browser without modifying their source.

Categories : Node Js

Script not uploading files to my server
Your <form> tag should have enctype="multipart/form-data" attribute. See the example #1 here.

Categories : PHP

php script for uploading files to a remote server
At the very least, I think you need the directory separator between the $uploaddir and $uploadfile so try changing: $uploadfile = $uploaddir . $file; to $uploadfile = $uploaddir . '/' . $file; Also make sure to sanitize $uploaddir because something like ../../some_dir may let me upload to arbitrary directories. And uploading of a file with a .php extension would allow me to upload PHP code to your server and run it, so be advised of some of these issues.

Categories : PHP

I need a script that searches files for SSI and replaces the include with the actual HTML
The specification does not cover every details, so I have the following assumptions. The <!--#include file="myfile.html"--> line stays its own. Other characters are removed. Included files does not contains additional includes. In project directory no subdirs has to be checked. In this case something like this can do the job. It is in bash: #!/usr/bin/bash search=${1:-./} replace() { while read -r x; do if [[ "$x" =~ <!--#include file="([^.]+.html)"--> ]]; then cat "${BASH_REMATCH[1]}"; else echo "$x" fi done <"$1" } while read f; do replace "$f" > tmp_$$.tmp && mv tmp_$$.tmp "$f" done < <(find $search -maxdepth 1 -name '*.html') It reads all the *.html files in the specified directory (not recursively). If no args gi

Categories : Python

How to change an image tag url in multiple html files using batch script?
@ECHO OFF SETLOCAL enabledelayedexpansion for /r U: %%i in (*.html) do ( echo found %%i SET outfile="%%~dpni.lmth" ( SETLOCAL disabledelayedexpansion FOR /F "usebackq delims=" %%L IN ("%%i") DO ( SET "line=%%L" SETLOCAL ENABLEDELAYEDEXPANSION SET "line=!line:/live/=/test/! echo !line! ENDLOCAL ) ENDLOCAL )>!outfile! ) pause GOTO :EOF How about this development? Notes: I've modified your FOR/R to ECHO the HTML file being processed and use %%i rather than switching to %%f. U: is my RAMDRIVE; you'd need to modify that to suit. outfile is set to generate a filename which matches the HTML filename, but with a .lmth extension (can't update in-place) - it gets that from the ~dpn prefixing the i, which means the drive, path and name of the file %%i. It's

Categories : Batch File

use html 5 or php to manipulate files on server
My first reaction would be this: Do an admin where you let the user upload the file (ordinary file upload, flash file upload or HTML5, doesn't matter). The file is then stored outside the www-root (no direct access to the file). Let the user add a username/password for this file and generate a unique ID/Key for the file. (DB columns: id, filename, username, password, url_key). Present the full url to the user that they can send to the client. When customer loads: mydomain.com/file/the_generated_url_key, you get the key from the url, if it exists, and promt a login box, which you authenticate against the database. Then you simply do a: echo file_get_contents(path_to_the_real_file); Of course with the correct headers, depending of the file type. Like the comment said. Do NOT let PHP

Categories : PHP

Python script write multiple CSV files into SQL Server table error
You can skip the first line this way: csv_data.next() #throw away first row for row in csv_data: if len(row) >= 10: cursor.execute("INSERT ..." ...) Also, you should check to make sure that row contains enough elements before executing: if len(row) >= 10: #use first ten values in row, if there are at least ten cursor.execute("INSERT ...", row[:10]) You currently have your insert statement listed as two strings next to each other. This has the effect of joining them together with no space in between. You may want a space before "VALUES".

Categories : Python

How to show list of web server files in HTML
Possibility 1) activate DirectoryBrowsing [aka DirectoryListing] (Apache, IIS and probably all others support this). Possibility 2) use PHP, JSP, ASP or whatever language to make a list of the files. HTML itself is just a markup language, so there's no possibility to do that with HTML only.

Categories : HTML

Use web.config to allow server-side includes in HTML files (IIS)
Presuming that your hoster has enabled SSI's and delegated Read/Write permissions for handler mappings then this should work: <configuration> <system.webServer> <handlers> <add name="SSINC-html" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="File" requireAccess="Script" /> </handlers> </system.webServer> </configuration> Whilst we're on the topic, Robert McMurray (MSFT IIS staffer) has a fairly recent refresher blog post all about SSI's here: http://blogs.iis.net/robert_mcmurray/archive/2010/12/28/iis-notes-on-server-side-includes-ssi-syntax-kb-203064-revisited.aspx

Categories : HTML

Sort according to price in html using java script
Give this a go using jQuery .sort(), here is a fiddle. $(function() { $(".offer_item").sort(function(a, b) { // Find the price element var priceAText = $(a).find(".offer_price").text(); var priceBText = $(b).find(".offer_price").text(); // Trim the currency symbol from the start of the text var priceA = parseFloat(priceAText.substring(1, priceAText.length)); var priceB = parseFloat(priceBText.substring(1, priceBText.length)); // Return the comparison result return priceA > priceB; }).each(function() { // Add all the elements back into the parent, in order $(this).appendTo(".offer_list"); }); });

Categories : Javascript

Execute sql server script from java
If I understand you correctly, the scenario would be: Read .sql file using one of the Readers Execute SQL commands using JDBC and Statement class.

Categories : Java

Facebook is not compressing Java Script files used in Like and Comment Plugin
I was also concerned about this, until I read google's own product forum, where everybody was complaining about this pagespeed tool and specifically those uncompressed things that are actually external. I use firefox with firebug and yslow and think it's more reliable than pagespeed. http://productforums.google.com/forum/#!topic/adsense/Kz-9lxPw9VI%5B851-875-false%5D

Categories : Facebook

how to write a windows batch script to copy some files and folders from location A to B based on a variable like server name
Use a text editor (for example the Windows built-in Notepad) to store the commands you would type on the commandline in a file. Save that file with the extension ".bat" or ".cmd". The command you'll probably want to use is "copy" or "xcopy". You can learn more about how to call them by calling them with "/?". Example: copy /? To learn more about environment variables, try: set /?

Categories : Windows

Referencing files in Android
You must put it in assets and get it from there like : How to open a pdf stored either in res/raw or assets folder?

Categories : Android

Action Script 3.0 Referencing multiple Arrays
Try for instead of for each for, for each difference for (var i:int = 0; i < pieces.length; i++) { var piece:MovieClip = pieces[i] as MovieClip; piece.buttonMode = true; piece.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject); piece.addEventListener(MouseEvent.MOUSE_UP, dropObject); if (targets[i].hitTestObject(targ[i])) { piece.x = xcoord[i]; piece.y = ycoord[i]; } }

Categories : Actionscript

Extract java script from html document using regular expression
What you probably could try to do is scriptlis = re.findall(r'<scripts*([^>]*)s*>(.*?)</script', gdoc, re.I|re.S) Because most script tags are of type: <script language="javascript" src="foo"></script> or <script language="javascript">alert("foo")</script> and some even are <SCRIPT></SCRIPT> Neither of which match your regex. My regex would grab attributes in group 1, and the possible inline code in group 2. And also all tags within HTML comments. But it is about the best possible without BeautifulSoup et al

Categories : Python

How can I insert java script file into webview after load a html
You can write javascript ineterface to inface between javascript and java code. This way you can call functions both ways. Follow the link below to know how its done: http://www.codelixir.com/android-webview-interfacing-between-java-and-javascript-tutorial/

Categories : Javascript

Using html forms to change java script fields without jquery
You need a function that will use the values provided by the user in the form to update the JS variables as you want. Then you just need to call this function from a button's onclick handler: <script> var myVarToUpdate = "test"; function update() { // find the input element by ID and assign its value to `myVarToUpdate` myVarToUpdate = document.getElementById("someText").value; } </script> <form> <input id="someText" value="" /> <button type="button" onclick="update()">Update</button> </form> This way the form will not be submitted at all, i.e. the page won't reload. Actually, you even do not need a proper <form> in this case.

Categories : Javascript

java script queries not showing results until temporary internet files deleted
To prevent the browser from caching your content and then serving that (stale) content up, you can set headers that say that your content shouldn't be stored in caches, which will force the browser to load a clean copy from your server every time the page is loaded, ensuring that up-to-date content is loaded each time. How to set HTTP headers (for cache-control)? has info, though you'll want to use NO-CACHE instead of PUBLIC, since that poster was trying to enable caching and you're trying to disable it. You can do more complicated things if you want (e.g. if you know that your database is only updated once an hour on the hour, you could set cache-control headers that will say that the content can be cached, but only till the end of the hour), but for what you've described, simply disall

Categories : PHP

JS files referencing confusing behavior
Remember that when it comes to javascript, everything depends on what the browser sees - there's nothing in your server code, your project configuration, or anything else in your app which would cause the issue with javascript. With that in mind, just run View Source on your page. My guess is your script tags are getting put in after the control, so the control is attempting to do things that are not defined yet. Once you confirm this, figure out where the content placeholder with the scripts is, and move it accordingly - it probably is in the body now, and just needs to go into the head, or at least higher in the body.

Categories : Javascript

How to put an onclick event for a HTML table row created dynamically through java script.?
<table id="table"></table> $("#table").append("<tr><td>Hi there</td></tr>"); $("#table").on( "click", "tr", function(){ // do something alert( $(this).children("td:first").text() ); }); Any time the click event bubbles up to <table id="table">, this function will be called (no matter if the <tr>s are inserted dynamically, or hard coded). This will require the jQuery library http://jquery.com/ http://api.jquery.com/on/

Categories : Javascript

Could you please help me to highlight the selected HTML table row created dynamically through java script
One approach is to first loop through the other rows and remove the styling (really should be a class) then apply the styling (again, class) to the selected row. Here's one way of doing it: function rowHighlight() { var selectedRows = document.getElementsByClassName('selected'); for (var n = 0; n < selectedRows.length; n++) { selectedRows[n].className = ''; } this.className = 'selected' } And here's a working example of it, though very simple: fiddle time!

Categories : Javascript

CSS Class Referencing in HTML
Move <link rel="stylesheet" href="CSS/Styles.css"/> to the head or before the <div id="navigation">. Like this: <head> <link rel="stylesheet" href="CSS/Styles.css"/> </head> Or: <link rel="stylesheet" href="CSS/Styles.css"/> <div id="navigation"> <ul class="top-level"> But it's better to move it to the head as it's easier to manage. Also check if the path CSS/Styles.css is correct.

Categories : HTML

Referencing HTML elements
You can use a class for all referenced elements like: <div id="trigger" data-reference="reference_1">Trigger</div> <div id="meter" class="reference_1"></div> <div id="voltmeter" class="reference_1"></div> And in your jQuery part: $("#trigger").click( function() { var e = $(this); e.addClass("animated"); $('.' + e.data('reference')).addClass("animated"); });

Categories : Javascript

How do I write a client side Java script to run on a Node JS server
From what I can understand you are looking for an alert function in node. There really isn't one. If you just want to print something to the console ( the ugly black box ) you can use console.log like this: console.log(”Oh..Node what have you done?") If you would like to not change a line of code you could wrap console.log in an alert function like this: var alert = console.log; And it will work as is. If you are looking for Dom interactions you can try jsdom. EDIT : If you want a javascript file which is capable of being run on both the client side and the server side you would do something like this. if (typeof(process) !== 'undefined' && typeof(process.stdout) !== 'undefined') { console.log('You are running Node.js'); } else { alert("Why use console.log(

Categories : Javascript

Access UNIX server and run a shell script from java application
You could use SSH component JCraft for remote connection and shell commands invocations: import com.jcraft.jsch.* Exerp from my old code: JSch jsch = new JSch(); String command = "/tmp/myscript.sh"; Session session = jsch.getSession(user, host, 22); session.connect(); Channel channel = session.openChannel("exec"); ((ChannelExec)channel).setCommand(command); channel.setInputStream(null); ((ChannelExec)channel).setErrStream(System.err); InputStream in = channel.getInputStream(); channel.connect(); byte[] tmp = new byte[1024]; while (true) { while (in.available() > 0) { int i = in.read(tmp, 0, 1024); if (i < 0) { break; } System.out.print(new String(tmp, 0, i)); } if (channel.isClosed()) { if (channel.getExitStatus() == 0) {

Categories : Java

How can I deploy my Java files to my Tomcat Server automatically?
Ant is one possibility you have. Build your war-file and copy it automaticaly to your Tomcat directory. the tomcat will compile the sources via hot deploy. Here you get a nice documentation: Ant War-File and the copy task: ant copy file

Categories : Java

How to pass the selected max and min price value to java script function inside of select tag in html?
Update your script like this: function updatePriceLimit(select,budget) { var limit = select.value; document.getElementById(budget).value = limit; } Your HTML: <select onchange="updatePriceLimit(this,'budget_min')"> <select onchange="updatePriceLimit(this,'budget_max')">

Categories : Javascript

Remove all HTML from java server pages
You can't do this easily because HTML and JSP are both rich structures, both in terms of atoms (lexemes) and more complex constructs (tables, statements, ...) A full up parser which recognizes all those structures would do the trick. If you can get such a parser, then that's an easy way to go. But if you only want physical line counts of HTML vs JSP, then you only need the part of the parser necessary for this task. In particular, you don't need all the construct recognition machinery; just the part that recognizes the atoms, e.g., just the lexical part of the parsing engine. You can do this by defining lexers for each type of syntax (e.g HTML and JSP) that pass control to one another as transitions between them are encountered. This is a very standard task modulo sweat equity. Then

Categories : Java

program to show a progress bar while transferring all files from one server to another in java
You can sort an array using Arrays.sort(...) ie String[] childFiles = file.list(); Arrays.sort(childFiles); As I understand it, this will sort the files in natural order, based on the file name. You can modify this by passing a custom Comparator... Arrays.sort(childFiles, new Comparator<File>() {...}); // Fill out with your requirements... Progress monitoring will come down to your requirements. Do you want to see only the overall progress of the number of files, the individual files, a combination of both? What I've done in the past is pre-iterated the file list, calculated the total number of bytes to be copied and used a ProgressMonitor to display the overall bytes been copied... Otherwise you will need to supply your own dialog. In either case, you will need use Swing

Categories : Java

Receiving files from Java server to Android. accept() not working
I think the client part is working right, it stops at the accept method. So the problem is in the server which never gets to connect. The server part should be like this: try { Socket s = new Socket(); InetAddress addr = InetAddress.getByName("192.168.1.110"); SocketAddress sockaddr = new InetSocketAddress(addr, 8888); s.connect(sockaddr, 20000); // 20 seconds time out ObjectOutputStream oos=new ObjectOutputStream(s.getOutputStream()); ArrayLIst b = new ArrayList(); b.add("It Works"); oos.writeObject(b); oos.close(); s.close(); } catch (Exception e) { ..... }

Categories : Android

How to send emails from my server with a mail server and nodejs
I just had to do this as well, but I am running my node server on an Azure virtual Ubuntu Linux server. I imagine the same steps would work from your home server if you're running Ubuntu. Here is what I found worked: I installed the postfix email server using this guide: https://help.ubuntu.com/community/Postfix It looked like a lot of work at first, but it worked for me pretty easily. I found the easiest way to send the outgoing email from node.js was to use emailjs: http://github.com/eleith/emailjs.git I found that emails sent often end up being marked as spam. To help avoid this, you can go to wherever you manage your domain name (I use enom) and then configure an SPF record to help make your outgoing email look legit. Here is my node.js module to send emails using emailjs:

Categories : Javascript

Display java script preload banner before html document loaded - Pure Javascript
first you can set body { display: none; } and then call the preload function to load all the required images. like this preload('image1.jpg,image2.jpg,image3.jpg'); and at the end of function you can change style of body tag to make it visible again. .visible { display: block; } function preload(images) { if (document.images) { var i = 0; var imageArray = new Array(); imageArray = images.split(','); var imageObj = new Image(); for(i=0; i<=imageArray.length-1; i++) { //document.write('<img src="' + imageArray[i] + '" />');// Write to page (uncomment to check images) imageObj.src=imageArray[i]; } // ------ add class to body tag to make it visible again var d = document.getElementsByTagName

Categories : Javascript

Java Script get data from server (asp.net) and save it in local storage (client side)
You are trying to throw in an object into localStorage Change localStorage.setObject("teamworkGantDemo", prj); to localStorage.setItem("teamworkGantDemo", JSON.stringify(prj)); or simply localStorage["teamworkGantDemo"] = JSON.stringify(prj) But if you are insistent on using a wrapper around this, you could do this : Storage.prototype.setObject = function(key, value) { this.setItem(key, JSON.stringify(value)); } Storage.prototype.getObject = function(key) { return JSON.parse(this.getItem(key)); } Then use it this way : localStorage.setObject("teamworkGantDemo", prj);

Categories : Javascript

php file referencing issue on server
Change webhost or switch to plan where PHP has a sensible configuration. public_html should never be enforced as part of the external URL. $_SERVER['DOCUMENT_ROOT'] should be allowed, it's a read-only variable.

Categories : PHP

SQL Server - Foreign Key Referencing Primary Key A OR B
I dont think that this is the correct approach. I would rather recomend that you add an additional field to table Matchup (lets say Pick) and add a CHECK CONSTRAINT to ensure that it is either Team_A or Team_B. CHECK constraints enforce domain integrity by limiting the values that are accepted by one or more columns. You can create a CHECK constraint with any logical (Boolean) expression that returns TRUE or FALSE based on the logical operators. From FOREIGN KEY Constraints In a foreign key reference, a link is created between two tables when the column or columns that hold the primary key value for one table are referenced by the column or columns in another table. This column becomes a foreign key in the second table. And it does not seem to be what you are looki

Categories : Sql Server

referencing jquery global variables inside html?
Two ways: $(...).html('<img src="' + url2 + '"/>Saving...') Or: $(...).append($('<img/>').attr('src', url2)) The second method is cleaner/better IMHO.

Categories : Javascript



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