Skip to content

Instantly share code, notes, and snippets.

Sveinung Røsaker sveisvei

Block or report user

Report or block sveisvei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View regex-match-group.js
/**
* Given we have a regex with one more matching groups.
* The regex should capture those groups from an 'input'
* string and replace the matched values in an 'template'
* string.
*
* Example:
* regex: /([1-9]{8})/([1-9]{8})?/
* input string: '/some-magic/path/12122211/22112211'
* template string: 'http://someurl?adId=$1&adId=$2'
View gist:7672773
/Users/sverosak/Code/git/pasties-validator-web/node_modules/hapi/lib/server.js:95
this._loadBench = new Utils.Bench();
^
TypeError: undefined is not a function
View console
console.log("console.loggin");
View gist:3806414
var readStream = fs.createReadStream(filepath);
readStream.on('data', function(data){
console.log('data event', filepath);
});
readStream.on('end', function(){
console.log('end event', filepath);
// I never get an end event when I use pipe
View collect.js
function collectData(){
function copy(src, obj, keys){
for(var name, i = 0, len = keys.length; i < len; i++){
name = keys[i];
if(typeof src[name] !== 'undefined'){
if (typeof src[name] === 'function') { // function this and that
} else if (typeof src[name] === 'object'){
for(var subkey in src[name]){ obj[name+'_'+subkey] = src[name][subkey]; }
} else {
obj[name] = src[name];
View gist:1299173
express = require("express")
app = module.exports = express.createServer()
app.configure ->
app.use express.bodyParser()
app.use app.router
ans =
tallErStorst:
rex: /^(.*)\: hvilket av disse tallene er storst\:\s(.*)/,
View gist:594292
var sys = require('sys');
var path = require('path');
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!\n');
console.log('servi');
}).listen(1337, "localhost");
View watcher.coffee
io = require 'socket.io'
fs = require 'fs'
sys = require 'sys'
http = require 'http'
path = require 'path'
colors = require 'colors'
events = require 'events'
connect = require 'connect'
cs = require './coffee-script/lib/coffee-script'
View gist:455192
// This is a design doc for adding two methods to node via monkey patching
// that I find useful in all the little bits of HTTP glue I make. The point
// is to create a useful abstraction for forwarding requests and linking
// responses. In the most trivial case for building a reverse proxy, but
// see below for other use cases.
// API
http.ServerRequest.prototype.forward(port, host, dataFilter=null)
http.ServerResponse.prototype.attach(requestOrResponse, responseFilter=null, dataFilter=null)
View builderrorfedora12
[66/67] cxx: src/node_crypto.cc -> build/default/src/node_crypto_5.o
../src/node_crypto.cc: In static member function ‘static v8::Handle<v8::Value> node::SecureContext::Init(const v8::Arguments&)’:
../src/node_crypto.cc:392: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
../src/node_crypto.cc:401: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
../src/node_crypto.cc:403: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
../src/node_crypto.cc:405: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
../src/node_crypto.cc:407: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
../src/node_crypto.cc:409: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
../src/node_crypto.cc:411: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
../src/node_crypto.cc:413: error: invalid conversion from ‘const SSL_METHOD*’ to ‘SSL_METHOD*’
You can’t perform that action at this time.