Skip to content

Instantly share code, notes, and snippets.

View tjanczuk's full-sized avatar

Tomasz Janczuk tjanczuk

View GitHub Profile
res.writeHead(200);
var i = 0;
var interval = setInterval(function () {
res.write('line ' + i++ + '\n')
if (3 === i) {
clearInterval(interval)
res.end()
}
}, 1000)
//var http = require('http');
//http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
//}).listen(1337, "127.0.0.1");
//console.log('Server running at http://127.0.0.1:1337/');
@tjanczuk
tjanczuk / gist:1951872
Created March 1, 2012 18:19
blog: hello, world
res.writeHead(200)
res.end('Hello, world!')
@tjanczuk
tjanczuk / gist:2007899
Created March 9, 2012 18:27
sandbox tests
var tls = require('tls')
console.log(tls)
res.writeHead(200)
res.end()
@tjanczuk
tjanczuk / gist:2024390
Created March 12, 2012 20:10
Hello demo
res.writeHead(200)
res.end('Hello, world')
@tjanczuk
tjanczuk / interceptor.js
Created May 4, 2012 22:55
iisnode interceptor
(function () {
// refactor process.argv to determine the app entry point and remove the interceptor
var appFile;
var newArgs = [];
process.argv.forEach(function (item, index) {
if (index === 2)
appFile = item;
if (index !== 1)
@tjanczuk
tjanczuk / computeNodeJsVersion.js
Created June 29, 2012 17:50
computeNodeJsVersion.js
var path = require('path')
, fs = require('fs');
var existsSync = fs.existsSync || path.existsSync;
var nodejsDir = path.resolve(process.env['programfiles(x86)'] || process.env['programfiles'], 'nodejs');
if (!existsSync(nodejsDir))
throw new Error('Unable to locate node.js installation directory at ' + nodejsDir);
var wwwroot = process.argv[2];
@tjanczuk
tjanczuk / gist:3380414
Created August 17, 2012 16:34
wns example
var channel = '{channel_url}';
var currentAccessToken;
wns.sendToastImageAndText02(
channel,
{
image1src: 'http://foobar.com/dog.jpg',
image1alt: 'A dog',
text1: 'This is a dog',
text2: 'The dog is nice'
@tjanczuk
tjanczuk / gist:3420261
Created August 21, 2012 23:12
httpsys.ubr
scenario
{
name = "default";
warmup = 5;
duration = 10;
cooldown = 5;
default
{
@tjanczuk
tjanczuk / 202_sql.cs
Created March 14, 2013 06:45
Access SQL from node.js using http://github.com/tjanczuk/owin
//#r "System.dll"
//#r "System.Data.dll"
//#r "System.Web.Extensions.dll"
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;