Skip to content

Instantly share code, notes, and snippets.

@Evangenieur
Evangenieur / p2p_server.coffee
Last active December 22, 2015 08:18
All-In-One-File : P2P (server 2 server) Cluster formation using multicast DNS, sharing documents with web clients and servers
browserify = require 'browserify-middleware'
mdns = require "mdns"
os = require "os"
util = require "util"
_ = require "underscore"
request = require "request"
require "colors"
PORT = parseInt(process.argv[2]) or 3001
require("zappajs") PORT, ->
@Evangenieur
Evangenieur / cs-component.html
Last active December 18, 2015 07:00
Polymer Project with inline CoffeeScript component
<element name="cs-component">
<template>
I am a {{ language }} component
</template>
<script type="text/coffeescript">
Polymer.register @,
language: "CoffeeScript"
ready: ->
console.log "READY", @
</script>
@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 ->
@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 / 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 / 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 / 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 / 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 / launch.sh
Created October 9, 2011 16:08
Thin, Sinatra, AMQP
#!/bin/bash
thin start -p 3000 -R test.ru
@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