Re: [nodejs] Re: node server can't show characters besides English

2013-10-25 Thread Tim Caswell
Also keep in mind that the native string type in JavaScript is UCS-16 which means that any code points higher than 16 bits have to be encoded using surrogate pairs. (Note that the native encoding is quite different from the UTF-8 encoding commonly used when serializing strings to binary data) A qu

Re: [nodejs] Will "node-graceful-fs" make it's magic to all third party modules also?

2013-11-05 Thread Tim Caswell
If it monkey-patched existing modules in the current process, then you need to require it once per process you want patched. So in the case of cluster, you probably want it in the worker so that worker code gets patched. On Tue, Nov 5, 2013 at 4:15 PM, Filipe Deschamps wrote: > Alan, I saw thi

Re: [nodejs] how to best develop two related modules simultaneously

2013-12-08 Thread Tim Caswell
Though to be fair, I often prefer manually creating the symlink directly as you did since I use nvm and my global node_modules changes when testing different versions of node. On Dec 7, 2013 7:55 PM, "Dave Horton" wrote: > Ah, yes thanks! > > On Saturday, December 7, 2013 6:51:07 PM UTC, Brian Di

Re: [nodejs] When will Chrome Beta for Android fully support webRTC and HTML5

2013-12-08 Thread Tim Caswell
Is this the mailing list you meant to send this to? On Dec 6, 2013 12:05 PM, "Ket" wrote: > I've tested my web application on several android mobile devices > (smartphone, tablets). None of it works. > > The test link is here: http://meldville.com/demo/broadcaster.php > > It streams audio and vid

Re: [nodejs] Re: Ben Noordhuis's Departure

2013-12-09 Thread Tim Caswell
I would help Fedor finish candor and candor.io. other than the bad debugging experience, candor is a pretty fun language. Let's spend our precious time making and not destroying ok? I sure don't have near enough time as it is to work on all the cool things there are. -Tim Caswell (Aka @

Re: [nodejs] NodeJS with Apache

2012-02-01 Thread Tim Caswell
There is nothing wrong with mixing severs as long as you're aware of the tradeoffs. One easy way to integrate a node server in a system is to have the browser connect to the node server on a custom port using long polling jsonp. The PHP, rails, or other system can post messages to the node server

Re: [nodejs] sendin file to browser

2012-02-01 Thread Tim Caswell
The browser needs to request the file or node will never know about it. Probably with an XHR request. https://developer.mozilla.org/en/XMLHttpRequest On Tue, Jan 31, 2012 at 9:04 PM, Angelo Chen wrote: > Hi, > > I have a link < a href="#">send me this file, when user click, how > to send the fil

Re: [nodejs] ad serving and tracking system in node.js

2012-02-01 Thread Tim Caswell
Latency and requests per second are not the same thing. Especially in a system like node where you can have thousands of concurrent requests going on at once. Typically, the more concurrent requests, the slower each request gets. Node can probably handle this load given the right coding and clus

Re: [nodejs] Re: multiple version of node on windows

2012-02-01 Thread Tim Caswell
But he said "The installer won't even let me downgrade" ;) I'm not sure how the installer works, but surely there is an uninstall option for the old version, and if not would deleting the files be enough. Node is quite portable. I know on posix systems, the only file needed for executing is the

Re: [nodejs] building a simple multi-user JSON API?

2012-02-01 Thread Tim Caswell
Why not use couch directly? It's interface is http and thus available to all the clients. If you have other or static resources that need to be on the same domain, a node http proxy in front of couch might work. Of course if your query requirements don't work with couch's api, then that may make

Re: [nodejs] NodeJS with Apache

2012-02-06 Thread Tim Caswell
see, I would like to have it delivered via node. I'm going to use > sphinxsearch and would like to initialize a search in sphinx and have it > output to node which would then send json to the browser for users to see. > > Thanks for any help again, > > >> From: Ti

Re: [nodejs] actual request ip address instead of 0.0.0.0?

2012-02-06 Thread Tim Caswell
I should mention that you can use the same request handler for several http servers. For example. var Http = require('http'); var Stack = require('stack'); var Creationix = require('creationix'); local handler = Stack( Creationix.log(), Creationix.static("/", __dirn

Re: [nodejs] Re: actual request ip address instead of 0.0.0.0?

2012-02-06 Thread Tim Caswell
Lol! At least I used curly braces for the middleware. On Mon, Feb 6, 2012 at 1:59 PM, Christopher Jeffrey wrote: >>     local handler = Stack( > > Too much Lua in your blood! > > On Feb 6, 1:10 pm, Tim Caswell wrote: >> I should mention that you can use the same req

Re: [nodejs] Current state of GUI stuff?

2012-02-11 Thread Tim Caswell
Don't underestimate the value of HTML and dom based guis. Your front-end is written in the same language as your backend and debugging is often much easier. You just need to get some good front-end devs who know how to make it pretty. I too want native apps in node that work cross-platform. nod

Re: [nodejs] how to write for-each loop in JavaScript properly

2012-02-13 Thread Tim Caswell
Since this is the nodejs list, I'm going to assume you're working in node. In that case, Object.keys is built-in and it's really fast in V8 (much faster than for .. in). Also if you want to share code with the browser and it's not a mobile app (meaning it needs to support old ES3 browsers), then

Re: [nodejs] non blocking JSON.stringify

2012-02-13 Thread Tim Caswell
Yajl does both parsing and encoding. Clarinet is basically a pure js tool that does much the same thing yajl can do. It's not hard to create JSON.parse and JSON.stringify APIs on top of yajl (though, at that point, you're buffering the final object or need the full json string buffered to parse i

Re: [nodejs] Re: how to write for-each loop in JavaScript properly

2012-02-13 Thread Tim Caswell
On Mon, Feb 13, 2012 at 11:21 AM, Axel Kittenberger wrote: > some() is only for Arrays tough. Same with forEach. I had forgotten about Array.prototype.some(). If you want the short-circuit of some, use my code from above, but call it "some" to avoid confusion. > On Mon, Feb 13, 2012 at 5:47 PM

Re: [nodejs] Fork and patch npm modules

2012-02-13 Thread Tim Caswell
There is the npm link command that does just this. I don't know if it works on windows though since it uses symlinks. If it doesn't work, then yes nesting works just fine. Git is fairly good at ignoring nested repos automatically. On Mon, Feb 13, 2012 at 1:57 PM, Phoscur wrote: > Hi, > After r

Re: [nodejs] Node CPU use analysis

2012-02-13 Thread Tim Caswell
It may be written in JavaScript and thus has the overhead of a language VM. This especially hurts in terms of memory overhead per process. But node wins over apache and nginx by having the right event model. Good low-level primitives in libuv and the ability to script-in assumptions. For exampl

Re: [nodejs] Node CPU use analysis

2012-02-13 Thread Tim Caswell
On Mon, Feb 13, 2012 at 5:18 PM, Matt wrote: > On Mon, Feb 13, 2012 at 4:28 PM, Tim Caswell wrote: >> >> But node wins over apache and nginx by having the right >> event model. > > > Maybe over Apache, but you need to read more about nginx. Sorry, that period was

Re: [nodejs] Re: how to write for-each loop in JavaScript properly

2012-02-14 Thread Tim Caswell
n that case (switches inside switches inside for(;;) with continue and break all over the place) Sorry for derailing the list with performance implications that seems to have changed a little in the last year. Happy coding everyone! -Tim Caswell 2012/2/14 Scott González : > On Tue, Feb 1

Re: [nodejs] Re: Node CPU use analysis

2012-02-14 Thread Tim Caswell
Matt, I'm not offended by the tone. I understand the intent and tone are hard to convey on the internet. That's why I love going to tech conferences to meet people face to face. I hope to be at nodeconf this summer, maybe we can discuss this there. But I do disagree with your statement "it's j

Re: [nodejs] How to deal with xs:duration

2012-02-15 Thread Tim Caswell
There is no XML native to node, so I don't quite understand the question, but I can tell you that the Date constructor takes most date formats as input, and you can compare two Date instances to get the difference. https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date 2012/2/

Re: [nodejs] Re: Node CPU use analysis

2012-02-15 Thread Tim Caswell
On Wed, Feb 15, 2012 at 4:14 PM, Matt wrote: > On Wed, Feb 15, 2012 at 5:12 PM, Matt wrote: > >> (or your choice of non-alcoholic beverage). >> > Sweet! ;) > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > Yo

Re: [nodejs] monit and node

2012-02-16 Thread Tim Caswell
I don't know about monit, but if you start the service with upstart, a simple 'restart' directive will auto-restart the process if it dies. Is there some other port you can check on to see if your app is alive? On Thu, Feb 16, 2012 at 5:05 AM, Angelo Chen wrote: > Hi, > > I have a simple nodejs

Re: [nodejs] display jpegs from database

2012-02-21 Thread Tim Caswell
If you're able to read the binary data from the db, then it's a simple matter of piping/sending the data to the the http client (browser) using the proper mime type in the "Content-Type" header. If you want to embed the image in css or html (in the same http request), then it needs to be base64 en

Re: [nodejs] display jpegs from database

2012-02-21 Thread Tim Caswell
data.length }); res.end(data); }); } On Tue, Feb 21, 2012 at 9:58 AM, Angelo Chen wrote: > Any sample on this piping thing? > > On Feb 21, 2012, at 11:53 PM, Tim Caswell wrote: > > If you're able to read the binary data from the db, then it's a simple > matte

Re: [nodejs] parseInt bug

2012-02-21 Thread Tim Caswell
It's not so much a V8 bug, but an unfortunate feature of JavaScript itself. Crockford would call this one of the "bad parts". parseInt() tries to be clever and guess the radix if you don't give it one. Numbers starting with "0" are assumed to be octal (unless it starts with "0x" of course). Whi

Re: [nodejs] parseInt bug

2012-02-21 Thread Tim Caswell
Actually, according to that mdn page I just linked, ES5 (which V8 implements) should not try to parse octal mode and in a way it's a bug. But changing the behavior will "break the web" for sites that expect the ES3 behavior. Isn't JavaScript versioning fun? On Tue, Feb 21,

Re: [nodejs] Best practice for pushing lots of data over TCP to a distant server

2012-02-23 Thread Tim Caswell
Tcp itself handles a lot of the connection issues, so it's fairly reliable. You can still get disconnects at this level and you'll need to write reconnect logic if you want to be that robust. As far as bandwidth throttling, use Stream.prototype.pipe which implements "backpressure". That is, it s

Re: [nodejs] Secure distribution of NodeJS applications

2012-02-23 Thread Tim Caswell
Yes, since javascript functions show their source when they are toStringed, the source needs to be kept in memory, even in snapshots. I will say if you're building a custom binary anyway, why not put the sensitive parts in a C++ addon and require that from the JavaScript? Reverse engineering On

Re: [nodejs] Secure distribution of NodeJS applications

2012-02-23 Thread Tim Caswell
Yes, functions written in C++ can be called from javascript (this is how all the node primitives are implemented). C++ can call back to js, it's just not as straightforward. On Thu, Feb 23, 2012 at 10:54 AM, Jeremy Rudd wrote: > Don't know much about C++ addons. Can they access NodeJS objects as

Re: [nodejs] Best practice for pushing lots of data over TCP to a distant server

2012-02-24 Thread Tim Caswell
make sure to not send data faster than it's able to leave. On Thu, Feb 23, 2012 at 3:50 PM, Dan North wrote: > ** > The "best practice" here is to prefer pull over push. The remote daemon > will always knbow best r > ---------- > *From:

Re: [nodejs] Best practice for pushing lots of data over TCP to a distant server

2012-02-27 Thread Tim Caswell
> rather than try to reinvent anything. > > Which brings me to ask: Is there an rsync implementation for node? (or > could the OP actually use rsync in this case?) > > Cheers, > Dan (on a BlackBerry with an itchy send button) > -- > *From:

Re: [nodejs] Re: enable/disable assertion

2012-02-27 Thread Tim Caswell
That's clever, I like that. Not sure if I'll use it, but I'll keep the technique in mind. On Sun, Feb 26, 2012 at 4:30 AM, JeanHuguesRobert < jeanhuguesrob...@gmail.com> wrote: > De&&mand( something) // ie "Demand" instead of "Assert" > > That's a convention I use to solve your issue. Instead of

Re: [nodejs] minimalist OS for web server: Raspberry Pi?

2012-02-29 Thread Tim Caswell
The existing debian image is good. Also there will be an archlinux image soon for the raspberry pi. For any linux version, the easiest thing to do (if you care about being up to date) for node is build from source (either by hand or using a version manager like nvm, nave, n, etc...) On Wed, Feb

Re: [nodejs] Re: Secure distribution of NodeJS applications

2012-03-02 Thread Tim Caswell
I don't have experience with hiding source code (I tend to put everything I write on github out of habit), but I do know about keeping parts of code secure and out of the hands of anyone who might write a script using my library. A quick example is a task I was working on at HP to ass http proxy s

Re: [nodejs] Re: Secure distribution of NodeJS applications

2012-03-02 Thread Tim Caswell
*add HTTP proxy support (I should check more before sending) On Fri, Mar 2, 2012 at 8:29 AM, Tim Caswell wrote: > I don't have experience with hiding source code (I tend to put everything > I write on github out of habit), but I do know about keeping parts of code > secure and ou

Re: [nodejs] How to detect and diagnose event-loop blocking?

2012-03-02 Thread Tim Caswell
It will need some adjusting, but the event source hooks I wrote for [trycatch] allow you to insert code at the root of an event stack. You can create a timestamp before the first function is called, and another when it returns. if the difference is larger that some preset, you can flag that stack

Re: [nodejs] Throttling intensive IO task in node.js

2012-03-06 Thread Tim Caswell
Node can handle this. You just need to write the logic to not allow more than X child processes be running at once. Here is some simple code to give a rough idea. Please don't block your node process while waiting for child processes. var queue = []; // or if the queue gets huge, use a smarter

Re: [nodejs] Re: minimalist OS for web server: Raspberry Pi?

2012-03-12 Thread Tim Caswell
Also, if you ever are in a situation where V8 is simply too large or too non-portable, know that the underlying libuv C library does most of the raw work for node. I've made it a recent hobby to try libuv in all sorts of different scripting engines to see how it works there. None of them are near

Re: [nodejs] spdy?

2012-03-12 Thread Tim Caswell
Why not have a spdy client? I think it's pretty common to use a node process at a consumer of some webservice(s). Granted keepalive gets you pretty far, but I think spdy can be even better for performance, especially response multiplexing. On Mon, Mar 12, 2012 at 9:46 AM, David Bjorklund wrote:

Re: [nodejs] keep alive webserver

2012-03-12 Thread Tim Caswell
it depends on your system. On Ubuntu I use upstart and create a small script in /etc/init/SOMENAME.conf. And then you can use start, stop, and restart like `sudo start SOMENAME` Here is the upstart config for howtonode.org: description "Run node server" env PATH=/home/tim/nvm/v0.6.11/

Re: [nodejs] keep alive webserver

2012-03-12 Thread Tim Caswell
There is an old article on howtonode written by Tim Smart I think, but it's not what I use. If you want to use upstart, best to read the manual. On Mon, Mar 12, 2012 at 3:56 PM, theCole wrote: > Tim, > > Do you have the link to the blog where that was posted? > > -Cole > > -- > Job Board: http:

Re: [nodejs] Storing data in variables on server that runs with inteval (2 sek.)

2012-03-14 Thread Tim Caswell
Node's event loop is non-blocking. It's perfectly fine to run events on an interval and it can mix in with other events (like http requests). As long as no event blocks the process for a long time, things will run smoothly. As far as polling your database, well, if there is no notification or tr

Re: [nodejs] streams that are readable and writable

2012-03-19 Thread Tim Caswell
>From the node docs: http://nodejs.org/api/stream.html > > > A stream is an abstract interface implemented by various objects in Node. > For example a request to an HTTP server is a stream, as is stdout. Streams > are readable, writable, or both. All streams are instances of EventEmitter > . > You

Re: [nodejs] Official template engine integration method?

2012-03-19 Thread Tim Caswell
There is no official node.js http framework other than the http.createServer() API. As you probably know, that doesn't have many features beyond basic http protocol parsing and encoding (no sessions, templates, static file serving, or even cookies). Express is probably the most popular add-on fra

Re: [nodejs] authorization

2012-03-19 Thread Tim Caswell
You're probably better off just writing your own code to integrate everything than trying to find some pre-made module and bending it to your will. Depending on how you want to get credentials (html form, http auth, etc) at some point, you'll have the username as a javascript variable. Then do yo

Re: [nodejs] Custom module dependency declarations?

2012-03-19 Thread Tim Caswell
If you have npm installed look at `npm help json`. Basically just declare your dependencies in your app in a package.json file. If you don't ever want to publish your app or module on npm, put in a `"private": true,` line and it will disable accidentally publishing it to npm. Then when deploying

Re: [nodejs] Re: Official template engine integration method?

2012-03-19 Thread Tim Caswell
ngines", nothing else. For cases when > > I do not intend to use connect or express > > > > On Mar 19, 2:03 pm, Tim Caswell wrote: > > > > > > > > > > > > > > > > > There is no official node.js http framework other than

Re: [nodejs] streams that are readable and writable

2012-03-19 Thread Tim Caswell
is both, the only example I've encountered is tls.connect(). Maybe > it's fair to say that it is not common to have streams that are both > readable and writable. > > On Mon, Mar 19, 2012 at 7:31 AM, Tim Caswell wrote: > > From the node docs: http://nodejs.org/api/strea

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Tim Caswell
"global" installs install into the node directory. nvm doesn't upgrade node in-place so each new version of node is a new version. What you can do it not install npm modules "global"ly. If you must have them everywhere (like command-line scripts) install then in $HOME or something and put $HOME

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Tim Caswell
Keep in mind that it's best to not install libraries globally. It safer to just declare your dependencies in your app's package.json and install them locally using `npm install`. This prevents a world of headache with version mismatches. I only use global installs for things like `lessc` `share`

Re: [nodejs] nvm and npm global installs

2012-03-20 Thread Tim Caswell
om $PREFIX per node version and puts $PREFIX/bin in your path) > > On Tue, Mar 20, 2012 at 10:40 AM, Tim Caswell wrote: > >> Keep in mind that it's best to not install libraries globally. It safer >> to just declare your dependencies in your app's package.json and ins

Re: [nodejs] Re: working with synchronous libraries

2012-03-20 Thread Tim Caswell
As cool as streamline is, I don't think it will work for this case since it would have to transform backbone itself in order to use the transformed I/O calls. Backbone uses _ for something completely different, so I don't expect that to work out very well. The root problem is you're trying to use

Re: [nodejs] Best way to organize modules which has dependencies

2012-03-23 Thread Tim Caswell
That's actually not a bad model. The connect middleware system I designed works like that. Each middleware is a standalone module. It may depend on some other modules for functionality (the static file server module depends on the mime database module). But as far as runtime configuration and a

Re: [nodejs] Non-blocking Addons Example?

2012-03-29 Thread Tim Caswell
to perform compression in a background thread. < https://github.com/joyent/node/blob/master/src/node_zlib.cc> Too much use of the thread pool can be bad for a program, so take all considerations in moderation. -Tim Caswell On Thu, Mar 29, 2012 at 3:49 AM, Felix Halim wrote: > Currently, my C++ p

Re: [nodejs] Re: OOP Sample

2012-03-29 Thread Tim Caswell
For javascript in general, I've written several articles showing the fundamentals of OOP on the howtonode.org blog. - http://howtonode.org/object-graphs - http://howtonode.org/object-graphs-2 - http://howtonode.org/object-graphs-3 JavaScript is not Java. It's quite possible to write a large c

Re: [nodejs] The Node Beginner Book and using modules

2012-03-31 Thread Tim Caswell
What do you mean by not needed? If the function uses the parameters and won't work without them (remember all arguments are technically optional in js), then it's needed. If the value is already available to the function from some other source, then either it's a badly designed API or there is so

Re: [nodejs] Re: Modest proposal to make async optional in Node.js

2012-04-02 Thread Tim Caswell
Node is non-blocking and will always be. That's the core concept of node. However there are other use cases. I believe the original question was asking if there was a way to have a blocking system (which is simpler in many respects), but only diverge from node as much as required. The one quest

Re: [nodejs] Re: Modest proposal to make async optional in Node.js

2012-04-02 Thread Tim Caswell
Fibers aren't blocking. They are faux blocking. If the process was really blocked it wouldn't be able to work on other stuff. And you can do fibers in node today, just be aware of the tradeoffs and concurrency gotchas involved. My recommendation is to not use fibers or code transforms like stre

Re: [nodejs] Re: Modest proposal to make async optional in Node.js

2012-04-05 Thread Tim Caswell
Fibers are not blocking. This is not the same thing. If the issue is that writing callbacks is hard and it's easier to reason about multiple stacks, threads, or other techniques that appear blocking but really are not, then sure use fibers. But like I already stated. True blocking is an entirel

Re: [nodejs] Re: Modest proposal to make async optional in Node.js

2012-04-05 Thread Tim Caswell
Alright we're all in agreement. I love when that happens! So to summarize: - Node is non-blocking and at the core uses callbacks and event emitters to handle the control-flow. - Fibers, code rewriters, and all other forms of faux blocking are technically compatable with node as well as giving

Re: [nodejs] Re: Need to run a loop in node.js

2012-04-06 Thread Tim Caswell
Keep in mind that the nextTick hack technique still blocks your CPU. It's just broken up into many small parts. If you must do something that's truly CPU intensive, put it on a thread or another process. Most modern machines (even phones) have multiple CPU cores. Interprocess communication is a

Re: [nodejs] Re: Need to run a loop in node.js

2012-04-06 Thread Tim Caswell
> And you can now write CPU intensive functions directly in Javascript, and > run them in a separate thread: https://github.com/xk/node-threads-a-gogo. > > > On Friday, April 6, 2012 9:22:29 PM UTC+2, Tim Caswell wrote: >> >> Keep in mind that the nextTick hack tec

RE: [nodejs] Tracking NPM Package Usage

2012-04-07 Thread Tim Caswell
It's couchdb, but otherwise correct. On Apr 7, 2012 7:41 AM, "Jann Horn" wrote: > Am Samstag, den 07.04.2012, 02:16 -0700 schrieb Glenn Block: > > Isaac mentioned to me at node summit that all the data is there in their > > mongo db and will be surfaced in the registry in the near future.. > > H

Re: [nodejs] How to avoid callback hell?

2012-04-09 Thread Tim Caswell
ounter and checks if it should move on to the next named step function. The take away is less is more. 90% of the time you don't need a library at all. Just be aware of how closures and named functions work and take advantage of the tools the language already provides. - Tim Caswell

Re: [nodejs] [ANN] Calango.js: Build native apps in Node + HTML5

2012-04-09 Thread Tim Caswell
Just curious, but could something like this be done with gecko, maybe using chromeless? Or are depending on the fact that newer qtwebkit uses v8? On Apr 6, 2012 5:26 PM, "Artur" wrote: > This is a long overdue announcement, but only recently did I have the > chance to get back to this project. I

Re: [nodejs] Node.js vs Ruby on Rails

2012-04-10 Thread Tim Caswell
Besides V8 being considerably faster than Ruby (which is actually less important than you think), the real issue is the fact that rails is based on blocking I/O. This means that you need a process or thread per concurrent customer. Node can multiplex thousands of connections in a single thread.

Re: [nodejs] nodejs throughput verses custom server, scaling question to someone with experience.

2012-04-10 Thread Tim Caswell
What is the actual work you're trying to do. I suspect that either it is a serious misconfiguration or something that node is just not good at. On Tue, Apr 10, 2012 at 12:15 PM, timp wrote: > Greetings, > > I was wondering if someone who has experience with working with scaling > problems could

Re: [nodejs] "return callback(...);" vs "callback(...); return;"

2012-04-11 Thread Tim Caswell
I also initially preferred approach B "{callback();return}", but now use approach A "return callback()". Yes there is a slight difference under the hood, at least in the initial abstract syntax tree. Usually this is done in an async callback where the return value is going to be ignored anyway.

Re: [nodejs] Better async loop

2012-04-11 Thread Tim Caswell
That depends on what you want it to do. This seems to execute each item serially. You can do them all parallel and abort on the first error like this: function asyncForEach(array, worker, callback) { var len = array.length; var results = new Array(l); if (!len) return callback(null, result

Re: [nodejs] Better async loop

2012-04-11 Thread Tim Caswell
e wrote: > I Wanted to keep the items in serially, as im trying to break the stack. > Your asyncForEach is at the end of the day synchronous loop just like any > other forloop. > > On Wednesday, April 11, 2012 3:33:18 PM UTC-4, Tim Caswell wrote: >> >> That depends on wha

Re: [nodejs] Better async loop

2012-04-11 Thread Tim Caswell
you said "Your asyncForEach is at the end of the day synchronous loop just like any other forloop" I'm confused and somewhere one of your assumptions is wrong. On Wed, Apr 11, 2012 at 3:02 PM, Tim Caswell wrote: > If you just want to keep the stack from growing a simple while or for loo

Re: [nodejs] Better async loop

2012-04-11 Thread Tim Caswell
xample. > > With your asyncForEach would be the same as the forEach that is already > part of the language. > > Maybe you can see why i used the nextTick. > > > On Wednesday, April 11, 2012 4:08:10 PM UTC-4, Tim Caswell wrote: >> >> My point being that you'

Re: [nodejs] "return callback(...);" vs "callback(...); return;"

2012-04-12 Thread Tim Caswell
As I mentioned, JavaScript doesn't have tail call elimination because of how the language is designed. http://code.google.com/p/v8/issues/detail?id=457 On Wed, Apr 11, 2012 at 5:06 PM, Ken Woodruff wrote: > > Tim Caswell wrote: > >> Yes there is a slight difference under t

Re: [nodejs] Chat: Sockets + Http

2012-04-12 Thread Tim Caswell
Does it work if you connect directly to the tcp server using netcat or telnet? I'm not familiar with using plain tcp from a browser so I'm not much help there. On Wed, Apr 11, 2012 at 7:09 PM, sparky wrote: > I'm working to create a simple chat demo that will send messages to flash > clients ov

Re: [nodejs] Re: When threads_a_gogo beats node 2 to 1

2012-04-12 Thread Tim Caswell
What makes the main thread so slow in comparison? It's the same v8 right? On Thu, Apr 12, 2012 at 8:39 AM, Jorge wrote: > On Apr 12, 2012, at 2:57 PM, billywhizz wrote: > > > are we just seeing the benefit of using 2 cores instead of 1? > > No no no, not at all. You're seeing the same piece of

Re: [nodejs] [ANN] Protein

2012-04-12 Thread Tim Caswell
Very nice. I made a super simple connect compatable runner a while back called stack. But I like the extras you added here with the getters and custom methods. One question, how do you extend the prototypes once (not per request) without changing the http pr

Re: [nodejs] Re: When threads_a_gogo beats node 2 to 1

2012-04-12 Thread Tim Caswell
Ahh, it's the eval and not having closures and global scope. I'll bet that's why it's faster, because it's in a clean environment. Try the same with new Function() instead of eval locally. On Thu, Apr 12, 2012 at 12:32 PM, mscdex wrote: > On Apr 12, 1:29 pm, mscdex wrote: > > https://gist.git

Re: [nodejs] [ANN] Protein

2012-04-12 Thread Tim Caswell
Cool. Just be aware that __proto__ is both non standard and deprecated. I'm not sure how this would be done with pure ES5 or ES6 code though. I really like how protein just returns a function and doesn't mess with the HttpServer or subclass it like connect does. On Thu, Apr 12, 2012 at 2:06 PM,

Re: [nodejs] [ANN] Protein

2012-04-12 Thread Tim Caswell
r modules mutating __proto__ > though like express and socket.io so hopefully v8 will continue to > support it. > > On 12/04/2012, at 21.19, Tim Caswell wrote: > > Cool. Just be aware that __proto__ is both non standard and deprecated. > I'm not sure how this would be done w

Re: [nodejs] Re: When fibers beat handwritten callbacks by 10 to 1

2012-04-12 Thread Tim Caswell
Something productive came out of this thread. I learned the name of the trampoline technique and came up with a hand-written version of the benchmark that's 4x faster than the streamline-js version. var count = 100; function bench(cb) { var total = 0; function loop(i) { var async;

Re: [nodejs] SMTP client that works with Windows

2012-04-13 Thread Tim Caswell
John, it's not helpful to tell someone to change OS. Smtp is a network protocol. It's quite possible to implement the protocol in pure JS since node gives all the needed network primitives and works the same cross-platform. As far as specifics, I don't know of a good pure-js smtp implementation,

Re: [nodejs] Re: SMTP client that works with Windows

2012-04-13 Thread Tim Caswell
Binary modules are hard cross-platform, especially on windows. Is there anything in buffertools that can't be done with just js? If it's a speed concern then there should be a js implementation as fallback for the times that binary modules can't be used. Node 0.6.x added some nice goodies to the

Re: [nodejs] modulo 256 checksum

2012-04-13 Thread Tim Caswell
Looks like you're missing the two's compliment part and the upper case part. On Fri, Apr 13, 2012 at 3:54 PM, Kevin O wrote: > I am working on a node integration to a home automation device. The device > has an ASCII protocol that I am building a parser and a command generator > for. > > All of

Re: [nodejs] modulo 256 checksum

2012-04-13 Thread Tim Caswell
ase hex value var chars = sum.toString(16).toUpperCase(); if (chars.length ==1 ) chars = "0" + chars; return chars; } On Fri, Apr 13, 2012 at 4:03 PM, Tim Caswell wrote: > Looks like you're missing the two's compliment part and the upper case > part. > > > On

Re: [nodejs] Re: nodejs throughput verses custom server, scaling question to someone with experience.

2012-04-14 Thread Tim Caswell
It may be worth your while, to remove all the frameworks, and do a vanilla js file using node. ;) On Sat, Apr 14, 2012 at 4:30 PM, timp wrote: > Pretty much. > > Server authenticates, provides get/set for a user state. > Provides gets for related information. > > Does checks for obvious cheati

Re: [nodejs] Re: How to avoid callback hell?

2012-04-14 Thread Tim Caswell
I commented in long form on Bruno's blog, but it's not showing for some reason. Here are the highlights: ...(paragraphs talking about my experience helping newcomers)... Node had "promises" early on and we learned a very important lesson with them. Hiding the non-blocking nature of code is bad!

Re: [nodejs] mobile web ui with node

2012-04-16 Thread Tim Caswell
Also some popular frameworks are backbone.js and ember.js (aka sproutcore 2.0). Backbone has no ui widgets, and I ember doesn't have much. There are *many* mobile frameworks these days. On Mon, Apr 16, 2012 at 9:46 AM, David Whitten wrote: > I understand that Rob Tweed has a system for making S

Re: [nodejs] A Framework Author Throwdown

2012-04-16 Thread Tim Caswell
I laughed at the part where Mikeal says that connect doesn't deserve to exist. I agree that database connectors shouldn't be packaged (primarily) as middleware layers, but remember the reason I designed connect in the first place. There were several competing http frameworks that were duplicating

Re: [nodejs] A Framework Author Throwdown

2012-04-16 Thread Tim Caswell
. There is an http plugin that provides the http service (it can use connect-compatible middleware). Other plugins can register routes and expose API endpoints to the browser. On Mon, Apr 16, 2012 at 1:13 PM, Tim Caswell wrote: > I laughed at the part where Mikeal says that connect doesn't de

Re: [nodejs] node modules which load dynamic .so files

2012-04-16 Thread Tim Caswell
If it's complaining about a .so file then it's probably something the .node file wants to dlopen. Node's require system only dlopens the .node file. What is the exact error message? On Mon, Apr 16, 2012 at 5:58 PM, SteveCronin wrote: > i've gotten a node module to successfully build but it fails

Re: [nodejs] OOP styles and standards

2012-04-17 Thread Tim Caswell
The question isn't entirely off-topic. The type of code you're writing affects the style of code you write. In particular prototype based objects are one of the techniques to make async callbacks organized. On howtonode, I've written a few articles explaining the various OOP techniques in JavaSc

Re: [nodejs] OOP styles and standards

2012-04-17 Thread Tim Caswell
On Tue, Apr 17, 2012 at 7:16 AM, Axel Kittenberger wrote: > > If you cut away this hack > > if (!(this instanceof Tester)) { > > return new Tester(name); > > } > than what you did is the basic way prototypes work. > > BTW, this "hack" is what node does internally for all it's constructors

Re: [nodejs] Node stalls

2012-04-17 Thread Tim Caswell
> > >> this should only happen if you are doing too much sync processing. >> > Everything is async (i.e. any call that may take a non-predictable amount > of time is an async call). > > I don't understand what you mean here. An async function in node is a non-blocking function. This means that is

Re: [nodejs] async.map

2012-04-17 Thread Tim Caswell
I don't know the async lib, but rolling your own map function is very easy. See this utility I bundle with my new safeRreturn micro-library. https://github.com/creationix/safereturn/blob/master/safereturn.js#L68-94 Also I have few questions and comments. Why does the small function take an callb

Re: [nodejs] Re: Request events handlers must be added in the same tick of the http request handler execution (I guess)

2012-04-18 Thread Tim Caswell
Doesn't .pause() now buffer internally? In my testing I haven't missed any events as long as I .pause() on the first tick. I would like to know if this is supported behavior. On Wed, Apr 18, 2012 at 3:49 PM, Mark Hahn wrote: > There is a buffered stream available from Mikeal that solves this p

Re: [nodejs] Node.js in a beagleboard::beaglebone

2012-04-18 Thread Tim Caswell
The beaglebone comes with an older version of Cloud9 IDE preinstalled. (cloud9 is a node app) So I would say, yes, it can be done. I imagine it's fast enough relative to the CPU power. Node on smart phones could get > 1000 request/second on the simple http hello benchmark. Startup time will matt

Re: [nodejs] Node.js extension that adds new listeners to specific paths

2012-04-19 Thread Tim Caswell
Could you be more specific? What kind of paths are these. Are you talking a virtual filesystem, or http request urls or something else? On Thu, Apr 19, 2012 at 3:06 AM, Masiar wrote: > Hello everybody. Sorry for the meaningless title, I would like to > create a Node.js extension that extends t

<    1   2   3   4   >