Skip to content

Instantly share code, notes, and snippets.

@Evangenieur
Evangenieur / Readme.md
Created March 27, 2011 23:30 — forked from grosser/Readme.md
Ruby Server / Node.js Benchmark

Sinatra

ruby 1.9.2 + async_sinatra + thin thin start

ab -n 10000 -c 100 http://localhost:3000/
-> 49ms / request

Node

node server.js
@Evangenieur
Evangenieur / global_constant.rb
Created August 23, 2011 16:11
Resolve CONSTANT in instance_eval & Import CONSTANT from Module / Class
module GlobalConstant
AUTORESOLVE = []
AUTOIMPORT = []
def self.install
Object.instance_eval do
class << self
alias old_const_missing const_missing
def const_missing constant
to_check = GlobalConstant::AUTORESOLVE.keep_if { |m| m.singleton_class == self } + GlobalConstant::AUTOIMPORT
@Evangenieur
Evangenieur / sinatra_all_inline.rb
Created September 17, 2011 10:11
All in one file with sinatra : SASS, CoffeeScript, HTML inline
require "sinatra"
require "slim"
require "coffee-script"
require "sass"
require "eventmachine"
get "/" do
slim :html
end
@Evangenieur
Evangenieur / launch.sh
Created October 9, 2011 16:08
Thin, Sinatra, AMQP
#!/bin/bash
thin start -p 3000 -R test.ru
@Evangenieur
Evangenieur / ip.json
Created January 18, 2012 15:40
IPv4 & IPv6 Regexp
{
ip4_expression: /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
ip6_expression: /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-F
@Evangenieur
Evangenieur / myCoffeeRepl.coffee
Created January 19, 2012 00:52
Importing lib to Coffee-Script REPL
global.MyModule = require "MyModule"
PATH = "./" # Define your Path
require("#{PATH}/node_modules/coffee-script/lib/coffee-script/command.js").run()
@Evangenieur
Evangenieur / bm.html
Created January 22, 2012 13:56
Boomkarlet
<a href="javascript:(function(){ms=document.createElement('SCRIPT');ms.type='text/javascript';ms.src='http://mysite.com/script.js?';document.getElementsByTagName('head')[0].appendChild(ms);
})();">Drag & Drop to your Bookmark (or copy / paste link)</a>
@Evangenieur
Evangenieur / bash.coffee
Created October 14, 2012 22:01
Bash Wrapper in CoffeeScript + Node.js
spawn = require('child_process').spawn
bash = spawn "bash", ["-i"]
bash.stdin.write "export PS1=wrapped:$PS1\n"
process.stdin.pipe(bash.stdin)
process.stdin.resume()
require('tty').setRawMode(true)
bash.stderr.pipe(process.stderr)
bash.stdout.pipe(process.stdout)
@Evangenieur
Evangenieur / main.coffee
Created November 15, 2012 14:19
Node.js Javascript / CoffeeScript Stack Trace Obj with line from code
StackObjError = require "stack_trace_with_line_from_code"
first_func = ->
second_func = ->
console.log JSON.stringify(new StackObjError().stack)
second_func()
first_func()
@Evangenieur
Evangenieur / zipStream.coffee
Last active December 16, 2015 19:19
zipStream in Node.js
fs = require "fs"
es = require('event-stream')
zipstream = require("zipstream")
app = require("express")()
files = ["rt_p2p_server.coffee", "rt_p2p_server.screen"]
addFile = (files) ->
unless files.length
zip.finalize ->