Skip to content

Instantly share code, notes, and snippets.

View saschagehlich's full-sized avatar

Sascha Gehlich saschagehlich

View GitHub Profile
getSize = (filename, callback) ->
fs.stat filename, (err, stat) ->
if err
if err.errno == process.ENOENT
return callback null, 0
return callback err
callback null, stat.size
getTotal = (filename, num, callback) ->
finish = ->
CREATE TABLE `servers` (
`id` int(11) NOT NULL auto_increment,
`subdomain` varchar(20) NOT NULL,
`ip` varchar(15) NOT NULL,
`cpu` varchar(255) NOT NULL,
`workdir` varchar(100) NOT NULL,
`mode` varchar(3) NOT NULL,
`monitoring` int(1) default '0',
`status_webserver` int(1) default '0',
`status_ping` int(1) default '0',
@saschagehlich
saschagehlich / i18n.coffee
Created September 14, 2010 00:48
Simple i18n with node.js and express.js
exports.I18n =
en:
title: "Free YouTube video download"
navi:
home: "Home"
howto: "Tutorial"
blog: "Blog"
termsofuse: "Terms of Use"
support: "Support"
imprint: "Imprint"
@saschagehlich
saschagehlich / httpfix.coffee
Created October 25, 2010 16:55
Since ClientResponse does only return the first Cookie in Set-Cookie, here is a workaround:
old = HTTP.IncomingMessage.prototype._addHeaderLine
HTTP.IncomingMessage.prototype._addHeaderLine = (field, value) ->
if field is 'set-cookie' and @headers['set-cookie']
@headers['set-cookie'] += "; #{value}"
else
old.apply this, arguments
'node' failed, cannot open a connection to INET[127.0.0.1:3000] via TCP
//
// APAppDelegate.h
//
// Created by Sascha Gehlich on 27.04.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
$ curl -I "http://www.dailymotion.com/cdn/H264-848x480/video/xkqom7.mp4?auth=1339455426-72402614d667d2124f5234b17db6055a" -v -H "User-Agent:" -H "Accept:"
* About to connect() to www.dailymotion.com port 80 (#0)
* Trying 195.8.215.138... connected
* Connected to www.dailymotion.com (195.8.215.138) port 80 (#0)
> HEAD /cdn/H264-848x480/video/xkqom7.mp4?auth=1339455426-72402614d667d2124f5234b17db6055a HTTP/1.1
> Host: www.dailymotion.com
>
< HTTP/1.1 302 Found
HTTP/1.1 302 Found
< Server: DMS/1.0.42
net = require 'net'
socket = net.connect host: 'bin-short.whatsapp.net', port: 5222
socket.setKeepAlive true
socket.on 'connect', ->
console.log "Successfully connected to whatsapp server"
socket.on 'timeout', ->
console.log "Connection to whatsapp server timed out"
socket.on 'close', ->
console.log "Connection closed"
sascha ~/sources/rtmpdump (master)$ rtmpdump -r "rtmpe://myvideo2fs.fplive.net/myvideo2flash" -a "myvideo2flash" -f "MAC 11,4,402,287" -W "http://is1.myvideo.de/de/player/mingR12m/cartridge/video/video.swf" -p "http://www.myvideo.de/watch/7849115/Rihanna_featuring_Drake_What_s_My_Name" -y "flv:movie11/79/7849115.flv" -o "rihanna.flv"
RTMPDump v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
WARNING: HandShake: Type mismatch: client sent 6, server answered 9
INFO: Connected...
ERROR: rtmp server sent error
ERROR: rtmp server requested close
@saschagehlich
saschagehlich / arrow.styl
Created February 17, 2014 20:33
An arrow mixin for Stylus, based on @shojberg's "cssarrowplease.com"
/**
* An arrow mixin for Stylus, based on @shojberg's "cssarrowplease.com"
* @param {Position} position
* @param {size, color} arrow
* @param {size, color} border (optional)
*/
arrow(position, arrow, border = 0 white)
// Resolve arguments
$arrowSize = arrow[0]
$arrowColor = arrow[1]