Skip to content

Instantly share code, notes, and snippets.

memoize = require 'memoizee'
endpoint = (done) ->
console.log "remote call"
setTimeout () ->
console.log "volam done"
done "vysledek"
, 1000
endpoint (x) ->
@falsecz
falsecz / request-tracing.coffee
Created May 7, 2014 09:09
Wrap request for zipkin tracing
22 start { uri: 'http://false.cz' }
33 start { uri: 'http://false.cz/notfound' }
22 end 200 { date: 'Wed, 07 May 2014 09:09:40 GMT',
server: 'Apache/2.4.7 (Debian) SVN/1.8.5 mod_fcgid/2.3.9 mod_jk/1.2.37 PHP/5.5.8-2 OpenSSL/1.0.1g mod_perl/2.0.8 Perl/v5.18.2',
'x-powered-by': 'PHP/5.5.8-2',
vary: 'Accept-Encoding',
'content-length': '869',
'keep-alive': 'timeout=5, max=100',
connection: 'Keep-Alive',
'content-type': 'text/html' }
r = (require 'easy-amqp') 'amqp://guest:guest@localhost'
r.queue('fro', durable: yes, autoDelete: no).bind('#').subscribe (m) ->
console.log m
r.on 'error', (err) ->
console.log 'amqp', err
# je to trosku hack, ale funguje to
r.conn.on 'end', () ->
r.conn.reconnect()
@falsecz
falsecz / gist:9597549
Created March 17, 2014 11:16
Standalone hbase
wget http://mirror.hosting90.cz/apache/hbase/hbase-0.94.17/hbase-0.94.17.tar.gz
tar -xvzf hbase-0.94.17.tar.gz
HBASE_MANAGES_ZK=true ./hbase-0.94.17/bin/start-hbase.sh
...
./hbase-0.94.17/bin/stop-hbase.sh
@falsecz
falsecz / .bashrc
Created March 5, 2014 20:03
jenkins-cli
function _jenkins() {
local cur tasks
cur="${COMP_WORDS[COMP_CWORD]}"
tasks="$(/Users/bender/bin/jenkins --jobs)"
COMPREPLY=( $(compgen -W "$tasks" $cur) )
}
complete -o default -F _jenkins jenkins c
{
"logs": {
"dynamic": "strict",
"properties": {
"@timestamp": {
"type": "date",
"index": "analyzed",
"format": "dateOptionalTime"
},
"@version": {
fs = require 'fs'
crypto = require 'crypto'
publicKey = fs.readFileSync './pub.pem'
plaintext = fs.readFileSync './plaintext'
cipertext = fs.readFileSync './ja.sig'
verify = (publicKey, text, cipher) ->
for h in ['rsa-sha1', 'rsa-sha1-2', 'sha1']
try
<?php
class Logger {
private $fd;
public function __construct() {
$this->fd = @fopen('php://fd/3', 'w');
}
public function log($o) {
if($this->fd) {
return fputs($this->fd, "3:" . $o ."\n");
<?php
class Logger {
private $fd;
public function __construct() {
$this->fd = @fopen('php://fd/3', 'w');
}
public function log($o) {
if($this->fd) {
return fputs($this->fd, "3:" . $o ."\n");
tty = require 'tty'
loggerFd = () ->
fd = 3
return {log: console.log.bind console} unless tty.isatty fd
log: (o) ->