Skip to content

Instantly share code, notes, and snippets.

View bbuecherl's full-sized avatar

Bernhard Bücherl bbuecherl

View GitHub Profile
@bbuecherl
bbuecherl / fix-bin-links.js
Last active February 13, 2017 13:57 — forked from novascreen/fix-bin-links.js
Workaround for Yarn bin links problem
@bbuecherl
bbuecherl / cleanapps.sh
Created July 22, 2015 20:16
script to delete unnecessary apple apps (use "sudo sh cleanapps.sh" to execute)
# script to delete unnecessary apple apps
rm -Rvf /Applications/FaceTime.app
rm -Rvf /Applications/Game\ Center.app
rm -Rvf /Applications/Chess.app
rm -Rvf /Applications/Dashboard.app
rm -Rvf /Applications/iBooks.app
rm -Rvf /Applications/Messages.app
rm -Rvf /Applications/Photos.app
rm -Rvf /Applications/DVD\ Player.app
@bbuecherl
bbuecherl / macro.h
Created July 5, 2015 17:14
random node native addon macros (using nan)
#define JSEXPORT_METHOD(tpl, name, cb) do { \
v8::Local<v8::FunctionTemplate> t = NanNew<v8::FunctionTemplate>(cb); \
tpl->InstanceTemplate()->Set(NanNew<v8::String>(name), \
t->GetFunction(), v8::ReadOnly); \
} while (0)
#define JSTOSTRING(handle) \
(new v8::String::Utf8Value(handle->ToString()))->operator*()
#define MUTEX_LOCK(mutex, action) do { \
@bbuecherl
bbuecherl / macros.h
Last active August 29, 2015 14:22
some utility macros for c++
#ifndef INCLUDE_MACROS_H_
#define INCLUDE_MACROS_H_
// concat arguments
#define CONCAT(a, b) a ## b
// macro to count passed arguments (maximum 63 arguments)
#define NUM_ARGS(...) NUM_ARGS_(,__VA_ARGS__, 63, 62, 61, 60, 59, 58, 57, 56, \
55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, \
36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, \
17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
@bbuecherl
bbuecherl / example.js
Last active August 29, 2015 14:14
JS-classes with multiple inheritance, super method and more
var ExampleClass = utils.Class(function(con, struc, tor) {
this.super([], [struc]);
this.con = con;
this.tor = tor;
}, [events.EventEmitter, OtherClass], {
print: function() {
return this.con + this.tor;
}
});
@bbuecherl
bbuecherl / lifereload.js
Last active August 29, 2015 14:12
11 LOC lifereload for node-webkit
var chokidar = require("chokidar"),
win = require("nw.gui").Window.get(),
watcher = chokidar.watch(process.cwd(), { persistent: true }),
reloader = function() {
win.reload();
};
watcher.on("ready", function() {
watcher.on("add", reloader)
.on("addDir", reloader)
.on("change", reloader);
@bbuecherl
bbuecherl / LDAP.java
Created December 12, 2014 09:58
Simple LDAP Connection-Class for java
import java.util.ArrayList;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
@bbuecherl
bbuecherl / about-this-pen.markdown
Last active August 29, 2015 14:09
A Pen by Bernhard Bücherl.
@bbuecherl
bbuecherl / normalizeEvent.js
Created May 15, 2014 20:17
normalize pointer/mouse/touch events
var normalizeEvent = ( function( ) {
var getPixels = function( style ) {
switch( style ) {
case "thick":
return 6;
case "medium":
return 4;
case "thin":
return 2;
default:
{
"always_show_minimap_viewport": true,
"caret_extra_bottom": 2,
"caret_extra_top": 2,
"caret_style": "solid",
"color_scheme": "Packages/User/Br4ckets/Br4ckets (Day).tmtheme",
"theme": "Edgy.sublime-theme",
"detect_indentation": false,
"ensure_newline_at_eof_on_save": true,