This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ForeignFunctionInterface #-} | |
import System.Win32.Types | |
import Foreign | |
import Foreign.C | |
foreign import stdcall unsafe "windows.h GetUserNameW" | |
c_GetUserName :: LPTSTR -> LPDWORD -> IO Bool | |
getUserName :: IO String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkrumins@stackvm:~/projects/node-lazy$ cat tests/filter.js | |
var Lazy = require('lazy'); | |
var EventEmitter = require('events').EventEmitter; | |
function range(i, j) { | |
var r = []; | |
for (;i<j;i++) r.push(i); | |
return r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkrumins@stackvm:~/projects/stackvm$ rm data/*db | |
pkrumins@stackvm:~/projects/stackvm$ node server.js | |
9 Oct 00:59:37 - socket.io ready - accepting connections | |
StackVM running at http://localhost:9000 | |
^C | |
pkrumins@stackvm:~/projects/stackvm$ node server.js | |
9 Oct 01:00:11 - socket.io ready - accepting connections | |
StackVM running at http://localhost:9000 | |
^C | |
pkrumins@stackvm:~/projects/stackvm$ node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = Prompt; | |
function Prompt(question, cb) { | |
if (!(this instanceof Prompt)) return new Prompt(question, cb); | |
if ((question && cb) !== undefined) prompt(question, cb); | |
var self = this; | |
var vars = {}; | |
var queue = []; | |
self.ask = function (question, into) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <node.h> | |
#include <node_buffer.h> | |
using namespace v8; | |
using namespace node; | |
class RetBuf : public ObjectWrap { | |
public: | |
RetBuf() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi Dionysios. | |
Thanks for the questions. My answers appear after each of the questions. | |
On Thu, Jul 22, 2010 at 10:55 AM, Dionysios G. Synodinos <[email protected]> wrote: | |
Hi Peter, | |
My name is Dionysios Synodinos, I'm an editor for InfoQ and since we're doing an article on Node.js, we'd love to have your feedback. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// annoyingly many browsers don't have these: | |
if (!Object.keys) Object.keys = function (obj) { | |
var keys = []; | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
keys.push(key); | |
} | |
} | |
return keys; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
trap 'echo; echo Aborting; exit 1' 2 | |
for module in node-{video,png,jpeg,base64} | |
do | |
( | |
cd $module | |
rm -rf build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node> o = { foo : 'bar' } | |
{ foo: 'bar' } | |
node> Object.defineProperty(o, 'moo', { value : 'cows', enumerable: false }) | |
{ foo: 'bar' } | |
node> Object.keys(o) | |
[ 'foo' ] | |
node> o.moo | |
'cows' | |
node> Object.getOwnPropertyDescriptor(o, 'moo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned char * | |
rgba_to_rgb(unsigned char *rgba, int rgba_size) | |
{ | |
int rgb_size = rgba_size/4*3; | |
unsigned char *rgb = malloc(sizeof(unsigned char)*rgb_size); | |
if (!rgb) return NULL; | |
int i, j; | |
for (i=0,j=0;i<rgba_size;i+=4,j+=3) { | |
rgb[j] = *(rgba+i); | |
rgb[j+1] = *(rgba+i+1); |
NewerOlder