Skip to content

Instantly share code, notes, and snippets.

/**
* By TooTallNate, originally posted at https://gist.github.com/1785026
* A quick little thingy that takes a Stream instance and makes
* it emit 'line' events when a newline is encountered.
* Modified by Max Weller to accept custom line feed characters (e.g. \r\n)
*
* Usage:
* ‾‾‾‾‾
* var emitLines = require('./emitLines');
* emitLines(process.stdin, "\n")
@luelista
luelista / prettyprint.php
Created February 28, 2013 16:22
Pretty Printer for PHP source code
<?php
// Pretty Printer for PHP source code
// Edit the (relative or absolute) path to your project here:
$root = "../../Notendb/notendb2/";
// Edit the page title here:
$pageTitle = "Notendb - Anhang B: Quelltext";
@luelista
luelista / gist:6691138
Created September 24, 2013 20:58
Crash report for node-webkit: Trying to display popup menu (context menu) on OS X 10.9
2013-09-24 22:49:42.625 node-webkit[94806:3513] assertion on /SourceCache/DataDetectorsCore/DataDetectorsCore-354/Sources/Lookup/DDABSource.m:226 "(typeAsNumber != NULL) && (CFGetTypeID(typeAsNumber) == CFNumberGetTypeID()) && (CFNumberGetType(typeAsNumber) == kCFNumberSInt64Type)" failed :DDABAddRecord should not be called with NULL type
2013-09-24 22:49:42.625 node-webkit[94806:3513] DDABAddRecord should not be called with NULL type
2013-09-24 22:49:42.625 node-webkit[94806:3513] An uncaught exception was raised
2013-09-24 22:49:42.625 node-webkit[94806:3513] condition "DDABAddRecord should not be called with NULL type"
2013-09-24 22:49:42.626 node-webkit[94806:3513] (
0 CoreFoundation 0x9bf706b1 __raiseError + 193
1 libobjc.A.dylib 0x9ac7a091 objc_exception_throw + 162
2 CoreFoundation 0x9bf705cb +[NSException raise:format:] + 139
3 DataDetectorsCore 0x91a88e72 DDRaiseException + 66
4 DataDetectorsCore
Imports System.Text.RegularExpressions
Imports System.Reflection
Public Class BatchProcessor
Event TraceEvent(ByVal varName As String, ByVal varData As String, ByVal codeLine As Integer)
Event PrintEvent(ByVal text As String, ByVal codeLine As Integer, ByVal lineBreak As Boolean)
Private Shared rJumpTarget As New Regex("^\s*([a-zA-Z0-9_]+):\s*")
Private Shared rCall As New Regex("^\s*[a-zA-Z]+\s+(([a-zA-Z0-9_]+(\[.*\])?)\s*=\s*)?(([a-zA-Z0-9_.]+::)|([a-zA-Z0-9_]+\.))([a-zA-Z0-9_]+)\s*(.*)")
Private Shared rCallSet As New Regex("^\s*SET\s+(([a-zA-Z0-9_.]+::)|([a-zA-Z0-9_]+\.))([a-zA-Z0-9_]+)\s*(.*)\s*=\s*(.*)", RegexOptions.IgnoreCase)
@luelista
luelista / fgdi-dfautomaton.js
Last active August 29, 2015 14:00
Deterministic Finite Automata to search for the substrings '01', '010' and 'hallo'
#!/usr/bin/node
// A = (alphabet, states, q0, Delta, Z)
//--> Deterministic Finite Automaton
function Automaton(alphabet, Q, q0, Delta, Accept) {
this.alphabet = alphabet;
this.Q = Q;
this.q0 = q0;
@luelista
luelista / workingdays.c
Last active August 29, 2015 14:01
Workingdays - Calculate the number of business days in a given year
// Workingdays - Calculate the number of business days in a given year
// Copyright (c) 2014 Max Weller
// COMPILE AND RUN:
// $ gcc -o workingdays workingdays.c
// $ ./workingdays -h
// Tested with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) (x86_64-apple-darwin13.1.0)
// and gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) (x86_64-linux-gnu)
@luelista
luelista / change_wallpaper
Last active November 24, 2019 05:02
Use the recent "Astronomy Picture of the Day" by NASA as your desktop wallpaper (Python script for Mac OS X, should be easy do adapt for Linux or Windows)
#!/usr/bin/python
# Downloads the current "Astronomy Picture of the Day" from nasa.gov and sets as wallpaper
#
# Installation steps:
# - store this file somewhere and take note of the path
# - change WALLPAPER_DIR to some folder in your home directory
# and create the folder
# - make it executable:
# chmod a+x /path/to/change_wallpaper
# - follow instructions given in the .plist file to make it run daily
@luelista
luelista / gist:eba639ee62900ab41193
Created June 25, 2014 13:36
Parser for matching parentheses and strings
function check_parens(str) {
var br=0,skip=false,instr=false;
for(var i = 0, len = str.length; i<len; i++) {
if(skip) { skip=false; continue; }
var z = str[i];
switch(z) {
case "[":case "{":case "(": if(!instr)br++;break;
case "]":case "}":case ")": if(!instr)br--; if(br==0)return i; break;
case "\"":case "'": instr=!instr;
case "\\": skip=true; break;
@luelista
luelista / export_rsnapshot.sh
Last active August 29, 2015 14:07
export_rsnapshot
#!/bin/bash
RSNAPDIR=/.private/.snapshots
EXPDIR=$1
if [ -z "$EXPDIR" ]; then
echo Please give folder
exit 12
fi
@luelista
luelista / Makefile
Created January 28, 2015 19:00
Zone transfer to secondary name server via mysqldump...
zone.txt: last_change
pdnssec rectify-all-zones
echo "SELECT name,type,content from records;" | mysql pdns > new_zone.txt
diff zone.txt new_zone.txt > zone.diff
rm zone.txt
mv new_zone.txt zone.txt
gzip --stdout zone.diff > diffs/zone.diff.$(date +"%Y%m%d%H%M")
mysqldump pdns | ssh -i /root/.ssh/copydns_key ns3.teamwiki.net "mysql pdns"