w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Javascript: Send Array of ints through node.js binary websockets
As far as the browser side, you can verify easily enough using chrome's dev tools. Look at the binary traffic and it will tell you if your sending binary of text frames. They are different kinds of frames in the websocket spec. On the node side, you can verify your buffer values are truly node buffers by using Buffer.isBuffer(). I see you're writing your buffer using the "binary" string encoding. This is probably not what you want. In node, the encoding for native Buffer instances is null. The "binary", "ascii", "utf8", "hex", "base64" encodings are all string encodings/decodings. What the binary encoding means is that every byte is stored in the string as a 8-bit unicode code point. // Convert a binary buffer into a "binary" encoded string. function binaryEncode(buffer) { var s

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

send an Array from Android to PHP Script over HTTP and get the data
One way is to serialize the array in the way the php serialize command does it. After receiving the string value(by the method you currently use), you can use the unserialize command to get the array in your php code. Here is a litle php example to demonstrate the workflow. $arr = array(1,2,3,4,5,6); $stringArr = serialize($arr); echo $stringArr; echo "<br/>"; $arr2 = unserialize($stringArr); if ($arr === $arr2) { echo "arrays are equal"; } The output of the script is: a:6:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:5;i:6;} arrays are equal The main difficulty is to construct the resulting string for complex structures (in your case, it is pretty straight forward for an array of integers). This fact results in the second approach. One can use a serialization API or anot

Categories : PHP

How to send array contain dictionary to server in ios?
Change: NSDictionary *tempDict = [[NSDictionary alloc]initWithObjectsAndKeys:tempReportArray,@"FeedStats", nil]; To: NSDictionary *tempDict = [[NSDictionary alloc]initWithObjectsAndKeys:tempArray,@"FeedStats", nil]; tempReportArray => tempArray

Categories : IOS

How in C# to send array/collection in SQL Server
For every author, he/she writes books with genre, etc... so you only should have one for loop. Your code flow should be something like this: for(...) { //insert into Book (author, book, genre, pages) } Your Book author field is a foreign key to Author table. An author can have many written books, so your Book table must have multiple entry for a single author. Your Book table should have contents like this (in order of: author, book, genre, pages): You, MyNewBook, Genre1, 10 You, MyOldBook, Genre2, 20, You, MyNotSoNewBook, Genre1, 100 You, MyVeryNiceBook, Genre1, 1000

Categories : C#

How to send byte array to server side using AJAX
Better do this: $.ajax({ url: '/Home/ImageUpload', dataType: 'json', type: 'POST', data:{ data: data}, //your string data success: function (response) { alert("hi"); } }); And in controller: [HttpPost] public ActionResult ImageUpload(string data) { var bytes = System.Text.Encoding.UTF8.GetBytes(data); //other stuff }

Categories : Javascript

email send works via perl script but not shell script
You have to export the smtp variable, otherwise mailx will not see it. Like this: #!/bin/sh SUBJECT="some subject" export smtp=10.233.1.199 EMAIL=abc@xyz.com echo "some message" | mailx -s "$SUBJECT" "$EMAIL" Btw the smtp variable is not mentioned in man mailx in my system nor in another Linux system I have access to. But I found it mentioned in an answer on superuser.com. That is to say, I'm not sure this would work on systems where it is not mentioned in man mailx, but if it works for you that's great.

Categories : Perl

how can i pass a variable from my php script and send it to my bash script
Try using shell_exec in your php script to execute your shell script and pass your variable, like so: $cmd="perl -pi -e 's/ : /:/g' /opt/lampp/htdocs/" . escapeshellarg($variable); $r=shell_exec($cmd); escapeshellarg is used to escape any potentially dangerous characters in $variable, to prevent a command line injection attack.

Categories : PHP

Error while writing a Google CCS server in node using node-xmpp
The important part is to send the message in the required format : <message id=""> <gcm xmlns="google:mobile:data"> { "to":"REGISTRATION_ID", // "to" replaces "registration_ids" "message_id":"m-1366082849205" // new required field "data": { "hello":"world", } "time_to_live":"600", "delay_while_idle": true/false } </gcm> </message> It doesn't matter if you use a template or not. I don't know python nor javascript, but the purpose of the template in the python example seems to be simply to avoid the need to write the xml tags that wrap the JSON every time you send a message. You can append them to the JSON when you send the message.

Categories : Javascript

Read XML node attributes without using node name in SQL Server query
declare @xml xml set @xml = '<book Category="Hobbies And Interests" PropertyName="C#" CategoryID="44" /> <sport Category="Hobbies And Interests" PropertyName="Cricket" CategoryID="46" />' select T.c.value('@PropertyName', 'varchar(100)') from @xml.nodes('/*') T(c) If you expect that there can be elements without PropertyName attribute, you can use: select T.c.value('@PropertyName', 'varchar(100)') from @xml.nodes('/*[@PropertyName]') T(c) If you also expect that elements can be nested, you can use: select T.c.value('@PropertyName', 'varchar(100)') from @xml.nodes('//*[@PropertyName]') T(c)

Categories : Sql Server

Mongoid-tree: Why do I only get a children array on Node.new and not Node.create?
I believe this is because Node.new creates an instance of the node object having an empty array while Node.create is the representation of an instance of a new Node actually persisted to the database (presumably skipping over the field with the empty array)

Categories : Ruby

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

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

Can my sql server send messages to activemq server without any java app in between
Please don't as SQL Server to do this. SQL Server is designed to store data. You are asking too much of it. Depending on how many places you would want to add to this queue from, I would choose one of the following solutions: If you want to add to this queue from a bunch of different places, and don't want to change existing code, create an application to move items from SQL Server to ActiveMQ. The items in SQL Server can be populated by a trigger. If there are only a few places that add to this queue, add that logic to the application so that every write to SQL Server will also write to ActiveMQ. If you really still don't want to modify any code, you can configure ActiveMQ to use SQL Server as its persistence database. Then you can modify its data and hope that it plays nice. This is

Categories : SQL

how to download a pdf file stored in a server in client side in node.js server
Send the correct mime-type, and then the content of the pdf. fs.readFile('temp/xml/user/username.pdf',function(error,data){ if(error){ res.json({'status':'error',msg:err}); }else{ res.writeHead(200, {"Content-Type": "application/pdf"}); res.write(data); res.end(); } }); I'm assuming res is your response object. Ah but you are using Express. Use Jonathan's answer instead.

Categories : Node Js

Netscape Enterprise Server and Server-Side JavaScript (SSJS) vs Node.js
The main difference would be the evolution of Javascript over the the past 15+ years. Node.js uses the V8 Javascript Engine which would be far more optimized for modern computers. Wikipedia has a good list of the differences between various server-side JS solutions. Here is a list of features for Netscape Enterprise Server - provides a good idea of what makes modern SSJS solutions much better. Why did it not gain attention? Realistically, client-side JS has only recently started to become the standard for web development so it was unlikely anybody would have considered using it for server-side development when it wasn't even really widely adopted for it's original purpose. I say widely adopted in that previously it was always difficult to cater JavaScript solutions to all browsers.

Categories : Javascript

Send zip created by node-zip
I recommend you to use streams for this approach. var fs = require('fs'); var zlib = require('zlib'); var http = require('http'); http.createServer(function(request, response) { response.writeHead(200, { 'Content-Type': 'application/octet-stream' }); var readStream = fs.createReadStream('test.file'); var unzipStream = zlib.createUnzip(); readStream.pipe(unzipStream.pipe(response)); }).listen(3000); This will properly not work in real world (as I am not common with zlib) but it may give you the direction

Categories : Node Js

How to copy file from one server to another server in node js using webDAV protocol?
You can try with node module - poster for directly upload to server Stream local file var poster = require('poster'); var options = { uploadUrl: 'http://mysite.com/upload', method: 'POST', fileId: 'file', fields: { 'myfield': 'value', 'myfield2': 'value2' } }; poster.post('file.jpg', options, function(err, data) { if (!err) { console.log(data); } }); Stream remote file var poster = require('poster'); var options = { uploadUrl: 'http://mysite.com/upload', method: 'POST', fileId: 'file', fields: { 'myfield': 'value', 'myfield2': 'value2' } }; poster.post('https://www.google.com/logos/2012/addams11-hp.jpg', options, function(err, data) { if (!err) { console.log(data); } });

Categories : Node Js

How to send control C node.js and child_processes
I found your previous question. Looks like you are trying to create/emulate a terminal from within node.js. You can use readline for reading and writing from a terminal. To write control character, you can see the example from its docs : rl.write('Delete me!'); // Simulate ctrl+u to delete the line written previously rl.write(null, {ctrl: true, name: 'u'}); To directly answer the question, to pass special characters you will need to pass their ASCII values. Ctrl + C becomes ASCII character 0x03. Value taken from here. spawn.stdin.write("x03");

Categories : Windows

Send UDP datagram from browser using Node.js?
As you mentioned it's impossible with native browser technologies. JavaScript can not use any transport protocols directly. The only feasible way I know is to use Flash. You can find examples in this discussion.

Categories : Javascript

Send Data from Drupal to node.js
If the space between the names is the issue, try using urlencode(). The code will be something like: $Name = urlencode(check_plain($form_state['values']['Name']));

Categories : PHP

how to send the a zip file as response in node js?
Use netstat to find which process is using the port. $ netstat -onp tcp Proto Local Address Foreign Address State PID TCP 127.0.0.1:60472 127.0.0.1:62522 ESTABLISHED 408 TCP 127.0.0.1:62522 127.0.0.1:60472 ESTABLISHED 1204 $ You can even use grep to narrow it down: $ netstat -onp tcp | grep 13000 TCP 127.0.0.1:13000 127.0.0.1:62522 ESTABLISHED 408 $

Categories : Node Js

How can I send HTML over JSON (in JS / Node)
On the receiving end, you need to simply undo the JSON serialization. That's it! Your HTML will be in its regular format at obj.html, which you can then parse with whatever DOM parser you want.

Categories : HTML

On Node.js can I send a request and close it before the answer?
Just don't wire up the client data event. app.post('/something', function(req,res) { client.post(...., function(res2){ //let the posted value and response finish //won't do anything with it res2.resume(); //if you want to return after post, but before response data is read. //comment out the res.end below, and use this one. // res.end("done"); }); //if you are just wanting to fire and forget the post request... res.end("done"); });

Categories : Node Js

Send data by parts in node.js express
The response object is a writable stream. Just write to it, and Express will even set up chunked encoding for you automatically. response.write(chunk); You can also pipe to it if whatever is creating this "file" presents itself as a readable stream. http://nodejs.org/api/stream.html

Categories : Node Js

How to send data back to node from casperjs?
You may probably prefer to use something like SpookyJS (https://github.com/WaterfallEngineering/SpookyJS) which offer the ability to use CasperJs inside a Node.js program. I don't know if you will find the feature you want but it's probably cleaner anyway.

Categories : Json

how to keep a node server app running on windows server
I'm not sure about running node in iis. However, you can take a look at the node packages forever, pm2, and nodemon, which will recover the instance in case of failure. Here's how to install node.js as a service Here's something on installing node in iis 7.5 Just an update. I've been using iisnode at work for the better part of a year. I would recommend it if you are deploying to Windows.

Categories : Node Js

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

Unable to send messages to who are not online using node.js on my localhost
I figured out other way to do this client.on('message_from_client',function(data){ alldata = data.data; console.log(alldata); alldata = JSON.parse(alldata); alldata.forEach(function(data){ if(data.message_to!=''){ client.emit("update_message_from_server", data); if(data.message_to != client.username){ redisClient.SISMEMBER('online',data.message_to,function(err,reply){ if(reply!=0){ redisClient.get(data.message_to,function(err,reply2){ if(reply2!=null){ io.sockets.sockets[reply2].emit("update_message_from_server",data ); }

Categories : Javascript

How to send json data from node js to html page
If you use Express in node.js, here is the way to send json object as response: app.get('/test', function(req, res, next) { res.json({ message: 'Hello World' }); }); Then in JS on your html page html, if you use jQuery: $.ajax({ url: '/test', complete: function(data) { console.log(data); } }); Feel free to experiment with stuff, as well use Dev Tools in Chrome, experimentation - helps a lot to understand what and how it works.

Categories : Node Js

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

Create an array of integers from an array of objects (id) and send to a web service
Can't you create a NSString with the list of integers and separate them by , and send that instead? NSMutableString *mutableList = [[NSMutableString alloc ]initWithString:@"<q14:ArrayOfint>"]; //I'll say like this because i don't know if you added them as NSNumber or NSString for(int i = 0 ;i < idProdotti.count;i++) { NSInteger value = [[idProdotti objectAtIndex:i]integerValue]; [mutableList appendFormat:@"<arr:int>%d</arr:int>",value]; } [mutableList appendFormat:@"</q14:ArrayOfint>"]; and send mutableList then release it; //second one for qtaProdotti NSMutableString *mutableList1 = [[NSMutableString alloc ]initWithString:@"<q15:ArrayOfint>"]; //I'll say like this because i don't know if you added them as NSNumber or NSString for(int i = 0 ;i <

Categories : Iphone

Which datastructure to send to d3.js script?
The data structure I would use would be an array of objects: [{title: "Probably not", votes: 4}, {title: "But you're saying there's a chance", votes: 10}, {title: "I just added this...", votes: 7}] Then, further down in the code: .attr("y", function(d) {return d.votes;}) and .attr("height", function(d) {return d.votes;}) Then for the title you can use d.title to access the right value.

Categories : Javascript

How can I send email from within a script?
You can use sendmail. It is exactly what you are looking for. Here is an example: Make a file named test.mail with the following lines: Subject: test local first line of my message (compulsory blank line) and do: /usr/bin/sendmail -v your@emailaddress.com < test.mail

Categories : Linux

Send a value from a cookie to a script
You can get the values set in the cookie by using "document.cookie". Update: var cookievalue= document.cookie; var xmlhttp= new XMLHttpRequest(); var url="https://example.com/path?value="+cookievalue; xmlhttp.open("POST",url,false); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); xmlhttp.send();

Categories : Javascript

How to send HTTP headers to static directory in Connect (Node.js)
You have two options: write your own middleware to send the headers, or use a lib. Helmet is a middleware that implements several security headers, including x-frame. Your code would look something like: var app = connect() .use(connect.static('public')) .use(helmet.xframe('allow-from', 'http://example.com')) .listen(3000); To add your headers manually, withouth any extra lib, you could do something like this by writing your own middleware: function addMyHeaders(req, res, next){ res.setHeader("X-My-custom-header", ":{D"); next(); } var app = connect() .use(addMyHeaders) .use(connect.static('public')) .listen(3000);

Categories : Javascript

REST Api in node to send audio file along with json data
It is very different type of data you trying to deliver to client. Much better and scalable will be to have two separate requests. One for JSON data that will contain details over where Audio is located (file name?). RESTful dont have to answer with only JSON or XML data, but it is highly recommended though. Then another request to node, that will respond with streaming audio data, please check this good question and answers. If you need just to send audio file without live streaming, then read this: Nodejs send file in response

Categories : Javascript

How, in Node.js, to respond to a GET request from client (send some HTML in response)?
As @Daniel stated in his comment, the response object is certainly an Express object, and you can return your HTML simply by rendering a view, like so: exports.friends = function(request, response) { //do stuff response.render('friends.html'); }; Of course, you would have to define your views in your app.js setup, with something like this: app.set('views', __dirname + '/views')

Categories : Ajax



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