Skip to content

Instantly share code, notes, and snippets.

View matths's full-sized avatar
💻
In a former live I was a flash developer.

Matthias Dittgen matths

💻
In a former live I was a flash developer.
View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@TooTallNate
TooTallNate / n8.io.sh
Created October 31, 2012 20:07
The init.d startup script used for http://n8.io
#!/bin/bash
# n8.io daemon
# chkconfig: 345 20 80 (NR: what is this???)
# description: Nate's blog
# processname: n8.io
# original template from: http://werxltd.com/wp/2012/01/05/simple-init-d-script-template/
# working dir
DAEMON_PATH="/home/pi/n8.io"
@pyrtsa
pyrtsa / gist:4504593
Created January 10, 2013 18:36
Boxing with Objective-C
// Public domain. (You're welcome.)
/// BOX(expr)
///
/// Macro. Box simple things like `CGPoint` or `CGRect` into an `NSValue`.
///
/// (Compare with the use of `@` in `@YES`, @123, @"abc" or `@(1 + 2)`.)
#define BOX(expr) ({ __typeof__(expr) _box_expr = (expr); \
[NSValue valueWithBytes:&_box_expr objCType:@encode(__typeof__(expr))]; })
@pyrtsa
pyrtsa / blocks_not_delegates.mm
Created January 15, 2013 12:29
Blocks instead of delegates
// Widget.h
#import <UIKit/UIKit.h>
@interface Widget : UIView
@property (nonatomic, copy) void (^action)(Widget *widget, NSUInteger someArg);
@end
// Widget.m
@bnoordhuis
bnoordhuis / http-and-https-proxy.js
Created February 8, 2013 16:31
A node.js proxy that accepts HTTP and HTTPS traffic on the same port.
var fs = require('fs');
var net = require('net');
var http = require('http');
var https = require('https');
var httpAddress = '/path/to/http.sock';
var httpsAddress = '/path/to/https.sock';
fs.unlinkSync(httpAddress);
fs.unlinkSync(httpsAddress);
@RReverser
RReverser / better-console-log.js
Last active May 9, 2019 21:07
Better console.log in Node
// UPD:
// Now available as npm module!
// Check out https://github.com/RReverser/better-log for details.
console.log = (function (log, inspect) {
return function () {
return log.apply(this, Array.prototype.map.call(arguments, function (arg) {
return inspect(arg, { depth: 1, colors: true });
}));
};
@SleepWalker
SleepWalker / swipe.js
Created September 30, 2015 04:59
A simple swipe detection on vanilla js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
@Avaq
Avaq / combinators.js
Last active June 21, 2026 12:42
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@Fil
Fil / .block
Last active July 10, 2024 19:45
Painting Euclidian Voronoi
license: mit