Skip to content

Instantly share code, notes, and snippets.

View oschrenk's full-sized avatar

Oliver Schrenk oschrenk

View GitHub Profile
@oschrenk
oschrenk / AbstractFlatTreeParser.java
Created January 13, 2012 15:35
FlatTree - Example for parsing a flat file with hierarchical structure
public abstract class AbstractFlatTreeParser<T> implements Parser<T> {
/**
* Gets the tree reader.
*
* @param root
* the root
* @param path
* the path
* @return the tree reader
@oschrenk
oschrenk / Switch to User.scpt
Created March 19, 2012 16:25
"Very" Fast User Switching with OS X
--This script MUST be named "Switch to User.scpt", where User is the name of the user to switch to.
--You must first make a password item (a.k.a. a key) for the other user's password using Keychain Access, and call it "", where "user" is the other user's name and with the description "User Login". The script assumes that you make this key in your login.keychain, which is the default one.
--The first time you run this script, you will be prompted to allow Keychain Scripting to access the password of the key.
--This script requires "Enable access for assistive devices" to be enabled in the Universal Access system preference pane.
set username to word -1 of my findReplace(".scpt", "", (path to me as text))
-- Invoke Fast User Switching. The `id -ur username` part gets the uid number that corresponds to the username and substitutes it at the end of the CGSession command
do shell script "/System/Library/CoreServices/'Menu Extras'/User.menu/Contents/Resources/CGSession -switchToUserID `id -ur " & username & "`"
@oschrenk
oschrenk / Lock Screen.scpt
Created March 19, 2012 16:36
Switch to Login Screen
do shell script "'/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend"
@oschrenk
oschrenk / cairo.log
Created April 10, 2012 17:01
cairo installation log
==> Downloading http://www.cairographics.org/releases/cairo-1.10.2.tar.gz
Already downloaded: /Users/Oliver/Library/Caches/Homebrew/cairo-1.10.2.tar.gz
==> ./configure --prefix=/usr/local/Cellar/cairo/1.10.2 --with-x --enable-xcb
==> make install
make install-recursive
Making install in src
make install-am
CC cairo-arc.lo
CC cairo-analysis-surface.lo
/bin/sh ../libtool --silent --tag=CC --mode=compile /usr/bin/clang -DHAVE_CONFIG_H -I. -I.. -I. -D_REENTRANT -I/usr/local/Cellar/pixman/0.24.4/include/pixman-1 -I/usr/X11/include -I/usr/X11/include/freetype2 -I/usr/X11/include -I/usr/local/Cellar/libpng/1.2.44/include/libpng12 -I/usr/X11/include -I/usr/X11/include -I/usr/X11/include -I/usr/X11/include -Wall -Wextra -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Werror-implicit-function-declaration -Wnested-externs -Wpointer-arith -Wwrite-strings -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes -Wpacked -Wswitch-enum -Wmissing-format-at
@oschrenk
oschrenk / system.log
Created April 16, 2012 14:32
OSX Lion freezes when changing network location
Apr 16 10:05:31 schmendrick configd[14]: network configuration changed.
Apr 16 10:05:31 schmendrick UserEventAgent[11]: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - PreProbe
Apr 16 10:05:31 schmendrick configd[14]: network configuration changed.
Apr 16 10:05:34 schmendrick applepushserviced[63]: <APSCourier: 0x10c837260>: Stream error occurred for <APSTCPStream: 0x7fc4fb519ca0>: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)
Apr 16 10:05:36 schmendrick loginwindow[50]: kCGErrorIllegalArgument: CGSGetDisplayBounds: Invalid display 0x042720c0
Apr 16 10:05:36 schmendrick loginwindow[50]: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Apr 16 10:05:36 schmendrick loginwindow[50]: _NXGetScreenRect: error getting display bounds (1001)
Apr 16 10:05:36 schmendrick loginwindow[50]: kCGErrorIllegalArgument: CGSGetCurrentDisplayMode: Invalid display 0x042720c0
Apr 16 10:05:36 schmendrick Dropbox[255]: CPSGetFrontProcess(): This call is depreca
@oschrenk
oschrenk / debug-with-node-v0.6.12.log
Created April 16, 2012 16:46
npm: SyntaxError: Unexpected end of input [...] at Packer.readRules
info it worked if it ends with ok
verbose cli [ 'node', '/usr/local/bin/npm', 'install', '-g', 'webmake' ]
info using npm@1.1.16
info using node@v0.6.12
verbose /usr/local/bin/node node symlink
verbose config file /Users/Oliver/.npmrc
verbose config file /usr/local/etc/npmrc
verbose config file /usr/local/lib/node_modules/npm/npmrc
verbose cache add [ 'webmake', null ]
silly cache add: name, spec, args [ undefined, 'webmake', [ 'webmake', null ] ]
@oschrenk
oschrenk / Transformations.java
Created May 25, 2012 11:50
Transforming a WGS84 coordinate into geocentric cartesian coordinate
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeocentricCRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
/*
* Adapted from <a
* href="http://www.movable-type.co.uk/scripts/latlong.html">JavaScript
* version</a> created by <a href="http://www.movable-type.co.uk/">Chris
* Veness<a/> under the <a
* href="http://creativecommons.org/licenses/by/3.0/">Create Commons Attribution
* 3.0</a> licencse.
*/
package com.oschrenk.humangeo.calc;
@oschrenk
oschrenk / Switch to User.scpt
Created June 26, 2012 13:18
Keyboard Shortcut for Fast User Switching
--This script MUST be named "Switch to <User>.scpt", where <User> is the name of the user to switch to.
--You must first make a password item (a.k.a. a key) for the other user's password using Keychain Access,
--and call it "<user>", where "<user>" is the other user's name.the field "Kind" must be "User Login" (without quotes).
--The script assumes that you make this key in your login.keychain, which is the default one.
--The first time you run this script, you will be prompted to allow Keychain Scripting to access the password of the key.
--This script requires "Enable access for assistive devices" to be enabled in the Universal Access system preference pane.
set username to word -1 of my findReplace(".scpt", "", (path to me as text))
-- Invoke Fast User Switching. The `id -ur username` part gets the uid number that corresponds to the username and substitutes it at the end of the CGSession command
@oschrenk
oschrenk / Dijkstra.java
Created August 15, 2012 21:12
Problems with JOCL version of Dijkstra
program = clCreateProgramWithSource(context, 1,
new String[] { SOURCE }, null, null);
clBuildProgram(program, 0, null, null, null, null);
final int vertexCount = graph.getVertexCount();
final int edgeCount = graph.getEdgeCount();
final int[] vertexArray = graph.getVertexArray();
final int[] edgeArray = graph.getEdgeArray();