Skip to content

Instantly share code, notes, and snippets.

@luisgerhorst
luisgerhorst / docs.txt
Last active December 22, 2015 04:38
A useful universal documentation file I've created over the last year. Contains a lot of shell commands I use (and forget) regulary. About LAMPP, Ubuntu, Mac OS X, Finder, AVR, ejabberd, MySQL, Git, Heroku.
About: Development, Command Line, Server, Hardware
# Zeichen
~ = ALT N
# Bash
*Symbolic Link erstellen*
ln -s /path/to/file /path/to/symbolic-link
@luisgerhorst
luisgerhorst / Monterey.chocice
Last active December 22, 2015 09:49
Monterey text editor theme for Chocolat.app
(!default
(caret [rgba(0.000000, 0.000000, 0.000000, 1.000000)])
(selection [rgba(0.737255, 0.835294, 0.980392, 1.000000)])
(line-highlight [rgba(0.975300, 0.975271, 0.975288, 1.000000)])
(invisibles [rgba(0.600000, 0.600000, 0.600000, 1.000000)])
(color [rgba(0.000000, 0.000000, 0.000000, 1.000000)])
(background [rgba(1.000000, 1.000000, 1.000000, 1.000000)]))
(apply [text source] Source)
@luisgerhorst
luisgerhorst / .slate.js
Last active December 22, 2015 12:48
My Slate (github.com/jigish/slate) configs
slate.configAll({
gridBackgroundColor: [50, 50, 50, 0.95],
gridRoundedCornerSize: 3,
gridCellBackgroundColor: [0, 0, 0, 0.5],
gridCellSelectedColor: [70, 150, 255, 0.5],
gridCellRoundedCornerSize: 3
});
slate.bindAll({
@luisgerhorst
luisgerhorst / Alarm.rb
Last active December 22, 2015 16:49
Creating my first Mac app with MacRuby
#
# AppDelegate.rb
# Alarm
#
# Created by Luis Gerhorst on 09.09.13.
#
class AppDelegate
attr_accessor :window, :datePicker, :createAlarmButton, :deleteAlarmButton
@luisgerhorst
luisgerhorst / url.js
Created October 5, 2013 10:17
*Very* simple URL parser.
function URL(href) {
var element = document.createElement('a');
element.href = href;
this.protocol = element.protocol; // "http:"
this.hostname = element.hostname; // "example.com"
this.port = element.port; // "3000"
this.pathname = element.pathname; // "/pathname/"
this.search = element.search; // "?search=test"
@luisgerhorst
luisgerhorst / multiple-async.js
Last active December 26, 2015 08:39
Perform multiple async operations at once and handle the data when everything is finished.
var toLoad = 2, // number of chunks to receive
data = {}; // here we'll save the data, you could also use an array or multiple vars
$.ajax({
url: 'a.txt',
error: function (jqXHR, textStatus, errorThrown) {
// handle error
},
success: function (dataA, textStatus, jqXHR) {
data['a.txt'] = dataA; // so you can later access it in chunkReceived()
@luisgerhorst
luisgerhorst / detectCSVDelimiter.m
Created December 28, 2013 20:52
Detect CSV delimiter in Objective-C
#define COMMA ','
#define SEMICOLON ';'
#define COLON ':'
#define TAB '\t'
#define SPACE ' '
BOOL delimiterOrNothing(unichar character) {
return character == COMMA || character == SEMICOLON || character == COLON || character == TAB || character == SPACE || character == 0;
}
@luisgerhorst
luisgerhorst / split.m
Last active January 2, 2016 11:39
Split a text into nice lines with a maximum length.
NSString *text = @"Text to split, with newlines, spaces and very long words.";
NSUInteger maxLength = 55; // max length of one line
NSRegularExpression *wordLengthRegExp = [NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@".{1,%lu}", (unsigned long)maxLength] options:0 error:nil];
NSArray *inputLines = [text componentsSeparatedByString:@"\n"];
NSMutableArray *lines = [NSMutableArray array]; // output
for (NSString *line in inputLines) {
if ([line length] <= maxLength) {
[lines addObject:line];
} else { // line too long
NSArray *words = [line componentsSeparatedByString:@" "]; // split into words
@luisgerhorst
luisgerhorst / GitHub2 Edit.css
Created January 8, 2014 11:26
Improved version of Mou GitHub2 CSS for Markdown. Using Menlo for code and fixed some bugs.
body {
font-family: Helvetica, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px;
}
@luisgerhorst
luisgerhorst / GitHub2 Clone.css
Last active January 2, 2016 14:19
GitHub Markdown CSS Clone (should look exactly the same).
/*
Trying to rewrite the original GitHub Markdown CSS
Last Update 14-01-08 by Luis Gerhorst
*/
body {
font-family: Helvetica, sans-serif;
font-size: 15px;
line-height: 1.7;
background-color: white;