w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
NodeJS: What's the difference between a Duplex stream and a Transform stream?
The difference is just syntactic sugar. Transform streams are full duplex streams but rather than implementing _write and _read methods, you are asked to implement just the _transform method. You can read more about streams on the excellent substack's streams guide or from Isaacs's readable-stream repo.

Categories : Node Js

Stream in NodeJS
Most of Node's Stream classes aren't meant to be used directly, but as the base of a custom type: Note that stream.Duplex is an abstract class designed to be extended with an underlying implementation of the _read(size) and _write(chunk, encoding, callback) methods as you would with a Readable or Writable stream class. One notable exception is stream.PassThrough, which is a simple echo stream implementation. var PassThrough = require('stream').PassThrough; var stream = new PassThrough; Also note that ps will be a global, making it directly accessible in all other modules.

Categories : Javascript

nodejs gm using stream twice
try this, i dont think you need to use writeStreams in this case: gm(imagePath) .resize(640, 480) .autoOrient() .flip() .write(newImagePath, function(e) { if (e) throw e; gm(newImagePath) .resize(320, 240) .write(newImagePathSmall, function(e) { if (e) throw e; console.log('resized successfuly'); }); });

Categories : Node Js

NodeJS deserialization from a stream
You are getting the data chunk by chunk. Chunks themselves may not be complete JSON objects. Either buffer all of the data, or use something to do it for you (say the request module), or if you need to parse a long stream take a look at the JSONparse module.

Categories : Json

Wrapping a bidirectional stream in NodeJS
This seems to be one approach: https://github.com/ajlopez/ObjectStream/blob/master/lib/objectstream.js

Categories : Javascript

How to test if an object is a Stream in NodeJS
The prototype you are looking for is the stream.Readable stream for readable streams, and stream.Writable for writable streams. They work in the same way as when you check for Buffer.

Categories : Node Js

Getting 401 from Twitter Stream API using C#
try include your query string to baseString: var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" + "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&track={6}"; var baseString = string.Format(baseFormat, oauth_consumer_key, oauth_nonce, oauth_signature_method, oauth_timestamp, oauth_token, oauth_version, Uri.EscapeDataString(valueToTrack) ); .... var postBody = "track=obama"; https://dev.twitter.com/docs/auth/creating-sig

Categories : C#

Nodejs and Twitter API 1 - res.on function
res is a NodeJS event emitter, and res.on hooks up a callback for an event. The object res that you are using is a Node http response object, and it has nothing to do with the REST API that Twitter provides. The Node client makes a request to a http server (be it Twitter or Google or Stackoverflow). When the server responds, the res object emits the corresponding events. You can try , host: 'stackoverflow.com', , port: 80, , path: '/questions/18149079/nodejs-and-twitter-api-1-res-on-function' and res.on('end', function() {console.log(data)}); and check out the resulting html data :P

Categories : Node Js

NodeJS - How to stream request body without buffering
Pipe req to res. Req is readable stream and response is a writable stream.It should work http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('Echo service: ' + req.url + ' ' + JSON.stringify(req.headers, true, 2)); req.pipe(res); }).listen(9002);

Categories : Node Js

Stream API in twitter Not responding
The 401 error code indicates that you're not properly authenticated. Are you certain those credentials are correct? A good way to test that would be to connect to the regular streaming API (rather than a user stream) and seeing if you still get a 401. If you do, then your credentials are incorrect. If it works, then there's a problem with the user stream you're requesting.

Categories : Java

Node.js twitter stream api
The code you are using is for old twitter api version 1. Twitter recently launched new version of api 1.1 and discontinued the older version. New twitter api requires you to authenticate every request and there are some changes in the authentication mechanism you can read in twitter developer site. As for above error in script it is because you are trying to parse JSON.parse(chunk); where chunk is html and you are getting those error. Try updating your code for latest version of twitter api. Thanks

Categories : Javascript

401 error from Twitter Stream API using C#
I think this question might be able to help you out (same error message): Getting 401 from Twitter Stream API using C#

Categories : C#

NodeJS - How to pipe same video stream to multiple clients?
Streams can be thought of as fixed-sized queues in that they "buffer" or store a certain pre-defined amount of data before they either refuse to accept more or data begin to fall off the reading end of the stream; they can be considered queues in that they store data in "first in, first out" (FIFO) order. Writing to a stream makes data available to be consumed by all of the stream's current readers (those entities which have opened the stream for reading.) Reading from a stream removes a fixed amount of data from one end of the stream, freeing up space on the other end to potentially accept more data. Once data are read from the stream and more data have been added to the stream to fill its buffer, those data which have been read are gone. Node.js streams can indeed have multiple reade

Categories : HTML

Getting mentions and DMs through twitter stream API 1.1? (Using twython)
There is no way to stream direct messages. However, there is a way to stream a users timeline. Check out the documentation on Twitter here: https://dev.twitter.com/docs/streaming-apis/streams/user from twython import TwythonStreamer class MyStreamer(TwythonStreamer): def on_success(self, data): if 'text' in data: print data['text'].encode('utf-8') # Want to disconnect after the first result? # self.disconnect() def on_error(self, status_code, data): print status_code, data # Requires Authentication as of Twitter API v1.1 stream = MyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) stream.user() Until a new version of requests (https://github.com/kennethreitz/requests) is released, however, tweets

Categories : Python

Twitter Stream API to get users tweets
The streaming apis provide you with real-time events therefore if none of the users Tweet during the time you are listening you will not see any output. If you are instead trying to fetch a users historic tweets consider using Twitter#getUserTimeline(screenName) instead, e.g.: final Twitter twitter = new TwitterFactory().getInstance(); final List<Status> statuses = twitter.getUserTimeline(screenName); for (Status status : statuses) { System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); } See this example for further details.

Categories : Java

401 error while trying to call Twitter stream API
You haven't included the HTTP method or the base URL into your baseString before you compute the signature. This is taken from the Twitter site: Creating the signature base string The three values collected so far must be joined to make a single string, from which the signature will be generated. This is called the signature base string by the OAuth specification. To encode the HTTP method, base URL, and parameter string into a single string: Convert the HTTP Method to uppercase and set the output string equal to this value. Append the '&' character to the output string. Percent encode the URL and append it to the output string. Append the '&' character to the output string. Percent encode the parameter string and append it to the output string.

Categories : C#

iOS Client connecting to NodeJS socket.io results in Stream end encountered
Turns out that socket.io has its own authentication protocol and is not compatible with SocketRocket out of the box. See this SO answer: How to use SocketRocket with socket.io? From the answers there, you could take a look at socket.io-objc

Categories : IOS

Twitter Stream API get 100 status and stop the exceution
see the below code maybe helpfull for you String token= "Key Word"; Query query = new Query(token); FileWriter outFile = new FileWriter(token.replaceAll("^#","").concat(".txt"), true); int numberOfTweets = 1500; long lastID = Long.MAX_VALUE; ArrayList<Status> tweets = new ArrayList<Status>(); while (tweets.size () < numberOfTweets) { if (numberOfTweets - tweets.size() > 100) query.setCount(100); else query.setCount(numberOfTweets - tweets.size()); try { QueryResult result = twitter.search(query); tweets.addAll(result.getTweets()); System.out.println("Gathered " + tweets.size() + " tweets"); for (Status t: tweets) if(t.getId() < lastID) lastID = t.getId(); } catch (TwitterException te) { System.out.println("Couldn't connect: " + te); }; query.setMaxI

Categories : Java

How to Stream Through Large Amounts of Twitter Data?
you can look into Storm framework. Below are few links for further reference:- http://storm-project.net/ https://github.com/nathanmarz/storm

Categories : Asp Net

NodeJS/ExpressJS send response of large amount of data in 1 stream
Node's http.request() returns data in chunks for streaming (would be nice if they explicitly state this). Thus it's necessary to write each chunk to the body of Express's response, listen for the end of the http request (which is not really documented), and then call response.end() to actually finish the response. var req = http.request(options, function(res) { res.on( 'data', function(chunk) { response.write(chunk); } ); res.on( 'end', function() { response.end(); } ); } ); req.on('error', function(error) { … }); req.end(); Where response is Express's response the the initial client request (curl or angular's ajax call).

Categories : Node Js

Troubleshooting Error: connect ECONNREFUSED in nodejs stream-adventure tutorial
There is a pull request to fix this, here: https://github.com/substack/stream-adventure/pull/16 Try to listen on port 8001 instead and rerun verify after closing all processes listening on 8000.

Categories : Javascript

Search new twitter with a specific hashtag form a stream with twitter4j
Access to twitter firehose is only given to selected companies via resellers. So unless you are one of those companies, you want to use sample() instead of firehose. You should see some logs though. Are you sure your loggers are set up correctly? EDIT: Read this section of the documentation and add a valid twitter4j.properties file. Note that you have to sign up with twitter to get an access token. Once you have a token and filled the config file, you can just include it in your classpath.

Categories : Java

stop the Twitter stream and return List of status with twitter4j
It is not a good idea to force an asynchronous piece of code into synchronous mode. Please see http://stackoverflow.com/a/5934656/276263 See if you can rework your logic. However, the below code works as per your requirement. public class Stream { public static void main(String[] args) throws TwitterException { Stream stream = new Stream(); stream.execute(); } private final Object lock = new Object(); public List<Status> execute() throws TwitterException { final List<Status> statuses = new ArrayList(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey("bbb"); cb.setOAuthConsumerSecret("bbb"); cb.setOAuthAccessToken("bbb"); cb.setOAuthAccessTokenSecret("bbb"); TwitterStr

Categories : Java

Xamarin Social component fails to retrieve Twitter json stream
It seems like you are not authorised when you make this call. From Xamarin.Social documentation. Xamarin.Social uses the Xamarin.Auth library to fetch and store Account objects. Each service exposes a GetAuthenticateUI method that returns a Xamarin.Auth.Authenticator object that you can use to authenticate the user. Doing so will automatically store the authenticated account so that it can be used later. The reason why it works in Twitter API console is that you have authorised there prior to making a call. If you are already authorising in your app then please post the code you use to authorise.

Categories : Json

Sevenzip extractFile(String file, Stream stream) method stream parameter. c#
Setup a FileStream that SevenZip can write out to: DirectoryInfo directoryInfo = new DirectoryInfo(ApplicationPath); FileInfo[] zipFile = directoryInfo.GetFiles("*.7z"); using (SevenZip.SevenZipExtractor zipExtractor = new SevenZip.SevenZipExtractor(zipFile[0].FullName)) { using (FileStream fs = new FileStream("", FileMode.Create)) //replace empty string with desired destination { zipExtractor.ExtractFile("ConfigurationStore.xml", fs); } }

Categories : C#

How to update an XML document by stream reading a file and simultaneously stream writing output
Use SAX parser instead of DOM. You can also use the StAX APIs (part of JDK package javax.xml.stream ). Further reading- http://docs.oracle.com/javase/tutorial/jaxp/sax/parsing.html http://download-llnw.oracle.com/javase/6/docs/api/index.html?javax/xml/stream/package-summary.html

Categories : Java

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

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

Dart is there any way to invoke onDone callback from stream.listen() where the stream is from StreamController
You need to call StreamController.close() new Stream.fromIterable(data) basically creates a StreamController, adds the elements of the iterable one at a time, and closes the controller when the iteration is complete. In your second code block you're doing this manually, but just not closing the controller. Here's the relevant docs: http://api.dartlang.org/docs/releases/latest/dart_async/StreamController.html#close

Categories : Dart

Stream video from iPhone to web server - compress and stream step
Take a look at http://www.gdcl.co.uk/2013/02/20/iOS-Video-Encoding.html. This sample uses an AVAssetWriter to encode the video from the camera to H264 and then uses RTSP/RTP to stream the data to a player.

Categories : Iphone

How to chain write stream, immediately with a read stream in Node.js 0.10?
request(url).pipe(fs.createWriteStream(filename)).pipe(writestream); is the same as this: var fileStream = fs.createWriteStream(filename); request(url).pipe(fileStream); fileStream.pipe(writestream); So the issue is that you are attempting to .pipe one WriteStream into another WriteStream.

Categories : Node Js

"Merging" a stream of streams to produce a stream of the latest values of each
This solution will work for one-item streams but unfortunately accumulates every item in an inner stream until it finishes. public static IObservable<IEnumerable<T>> MergeLatest<T>(this IObservable<IObservable<T>> source) { return Observable.Create<IEnumerable<T>>(obs => { var collection = new PerishableCollection<T>(); return source.Subscribe(duration => { var lifetime = new DisposableLifetime(); // essentially a CancellationToken duration .Subscribe( x => // on initial item { collection.Add(x, lifetime.Lifetime); obs.OnNext(collection.CurrentItems().Select(p => p.Value))

Categories : C#

Can a writeable stream be piped to either a readable or wirtable stream
Ad 1: Yes, a must be a readable stream, and b must be a writable one. But, streams are not neccessarily either / or, they also can be both: Readable and writeable at the same time. So, b and c are both, hence you can pipe into them, but also pipe from them. Technically they are so-called duplex streams. Ad 2: Should be answered by now ;-). Ad 3: Yes, you should definitely check out the stream-handbook by @substack (aka James Halliday). For buffers, see How to use buffers in Node.js by NodeJitsu.

Categories : Node Js

Copy all but the last 16 bytes of a stream? Early detection of end-of-stream?
Read between 1 and n bytes from the input stream.1 Append the bytes to a circular buffer.2 Write the first max(0, b - 16) bytes from the circular buffer to the output stream, where b is the number of bytes in the circular buffer. Remove the bytes that you just have written from the circular buffer. Go to step 1. 1This is what the Read method does – if you call int n = Read(buffer, 0, 500); it will read between 1 and 500 bytes into buffer and return the number of bytes read. If Read returns 0, you have reached the end of the stream. 2For maximum performance, you can read the bytes directly from the input stream into the circular buffer. This is a bit tricky, because you have to deal with the wraparound within the array underlying the buffer.

Categories : C#

Balancing slow I/O in a fast stream read stream
I just ran into this problem last night, and in my hackathon induced sleep deprived state, here is how I solved it: I would increment a counter whenever I sent a job out to be processed, and decremented the counter when the operation completed. To keep the outbound traffic from overwhelming the other service, I would pause the stream when there was a certain number of pending outbound requests. The code is very similar to the following. var instream = fs.createReadStream('./combined.csv'); var outstream = new stream; var inProcess = 0; var paused = false; var rl = readline.createInterface(instream, outstream); rl.on('line', function(line) { inProcess++; if(inProcess > 100) { console.log('pausing input to clear queue'); rl.pause(); paused = true; }

Categories : Node Js

Stream processing errors with stream with embedded nulls
What you pass a C style string (char pointer) to the std::istringstream constructor it actually instantiates a std::string and passes that instead. This happens due to an implicit conversion. The conversion constructor of std::string interprets a null byte character in C style strings as an end of string terminator causing all characters after it to be ignored. To avoid this you can explicitly construct a std::string specifying the size of the data and pass it to std::istringstream char bin[] = {0x30, 0xb, 0x0, 0x6, 0x6, 0x2b, 0xc, 0x89, 0x36, 0x84, 0x13, 0xa, 0x1}; std::istringstream strm(std::string(bin, sizeof(bin) / sizeof(bin[0]))); Note: I don't know exactly what you are trying to accomplish but I recommend using std::vector instead of a raw character buffer if possible.

Categories : C++

Is there a generator that will turn a stream of text into a stream of lines?
After reading your edit, maybe you could modify the stream object which returns arbitrary amounts of text? For example, in the stream.next() method, there is some way the stream generates a string and yields it when .next() is called. Could you do something like: def next(self): if ' ' in self.remaining: terms = self.remaining.split(' ') to_yield, self.remaining = terms[0], ''.join(terms[1:]) yield to_yield else: to_yield = self.remaining + self.generate_arbitrary_string() while ' ' not in to_yield: to_yield += self.generate_arbitrary_string() to_yield, self.remaining = terms[0], ''.join(terms[1:]) yield to_yield This pseudocode assumes that the stream object generates some arbitrary string with generate

Categories : Python

scala iterator and stream example. stream fails on reuse
It fails because the sentences Iterator has been expended. One is not suppose to call an Iterator after a method on it has been called except for the next and hasNext methods. A simple example shows this: scala> val it = Iterator(1,2,3) it: Iterator[Int] = non-empty iterator scala> it.foreach(println(_)) 1 2 3 scala> it.foreach(println(_)) scala> In your case sentences has been expended on the first call and is empty on the second one giving a size of 0. Calling toStream on it does not change this. You get back an empty Stream. If you want to reuse sentences assign it to a list with val l = sentences.toList before calling count.

Categories : Scala

nodejs conflicts with node (re installing nodejs)
You may be able to use my pre-built packages which are available here: https://launchpad.net/~chris-lea/+archive/node.js They install a /usr/bin/nodejs binary and then create a symlink from that to /usr/bin/node. If you are going to use these, be sure to remove any vestiges of any previous installs so that the system is using the correct binaries.

Categories : Javascript

I want to stream video from my webserver, but I only want it to stream when there is a viewer
Try Page Visibility API. Supported Browsers : http://caniuse.com/#feat=pagevisibility

Categories : Javascript



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