Skip to content

Instantly share code, notes, and snippets.

View MattesGroeger's full-sized avatar

Mattes Groeger MattesGroeger

View GitHub Profile
if (tutorialMode)
{
var tutorialChain:ITutorialActionChain = TutorialChainBuilder.create(context)
.addAction(new WaitAction(2))
.addConcurrentChain()
.addAction(new MoveMapAction(new GridPoint(-6, -5), 3))
.addSequentialChain()
.addAction(new WaitAction(1))
.addAction(new ZoomMapAction(1, 2))
.finalizeSubChain()
@MattesGroeger
MattesGroeger / switch_branch.sh
Created May 16, 2011 20:31
Run this script to switch branches for multiple projects at the same time. Execute script with terminal command "sh switch_branch.sh".
#! /bin/sh
# path to local branch workspace
branch="/Users/user/Documents/workspaces/workspace_project_branch"
# path to remote branch
remotebranch="https://svnhoster/project/branches"
# modules
MODULE[0]="client_core"
@MattesGroeger
MattesGroeger / .zshrc
Created November 25, 2011 11:29
My .zshrc (part), gitconfig and diff_merge.sh for opening git diffs with DiffMerge app
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
plugins=(git osx brew svn)
# Normal aliases
alias gco='git co'
alias gci='git ci'
alias grb='git rb'
alias d='git diff --word-diff $@'
alias c='git commit -v $@'
alias s='git status -sb'
@MattesGroeger
MattesGroeger / NSNotificationMatcher.h
Created November 13, 2012 14:44
Matcher for Kiwi testing framework that allows testing notifications.
#import "KWHCMatcher.h"
#import "KWMessageTracker.h"
#import "Kiwi.h"
@interface NSNotificationMatcher : NSObject <HCMatcher>
{
NSDictionary *_userInfo;
}
+ (id)matcherWithUserInfo:(NSDictionary *)dictionary;
@MattesGroeger
MattesGroeger / UIImageView+Mask.h
Last active December 17, 2015 10:59
With this category of `UIImageView` you can apply a mask (grey-scale jpg) onto a given image. The mask is then applied on that existing image. With this technique you can use 2 compressed JPG's (not transparent image + mask) rather than one big PNG file.
#import <Foundation/Foundation.h>
@interface UIImageView (Mask)
- (void)applyMask:(NSString *)maskName;
@end
@MattesGroeger
MattesGroeger / Kiwi (new)
Created November 8, 2013 10:23
I just re-factored this OCUnit code to Kiwi
[[[user1Dict[@"highscores"] valueForKey:@"fb_id"] should] contain:fbId_user2];
[[[user2Dict[@"highscores"] valueForKey:@"fb_id"] should] contain:fbId_user1];
# http://www.mono-project.com/Compiling_Mono_on_OSX
require 'formula'
class Mono < Formula
url 'http://download.mono-project.com/sources/mono/mono-3.2.3.tar.bz2'
homepage 'http://www.mono-project.com/'
sha1 'e356280ae45beaac6476824d551b094cd12e03b9'
def install
@MattesGroeger
MattesGroeger / vb_bootcamp.sh
Created January 18, 2014 12:35
I use the following script to boot my Windows 7 bootcamp partition under OSX with VirtualBox. Replace the name of your Bootcamp partition and the name of your VirtualBox image accordingly. The script was written after following this description: http://www.kevinrockwood.info/2010/04/windows7-in-osx-with-bootcamp-and-virtualbox/
#!/bin/sh
# find and unmount volume (change 'BOOTCAMP' name accordingly)
amount=`diskutil list | grep BOOTCAMP | wc -l`
if [ $amount = 1 ]
then
path=`diskutil list | grep BOOTCAMP | sed -e 's/^\(.*\)\(disk0s.\)$/\/dev\/\2/g'`
sudo chmod 777 $path
diskutil unmount $path
fi
@MattesGroeger
MattesGroeger / Rakefile
Last active January 4, 2016 19:09
Run commands from Ruby (e.g. Rakefile) with real time output and exiting on non-0 exit codes.
desc 'Build'
task :build do
run("xbuild Project.sln", "Build failed")
run("nunit-console Tests/bin/Debug/Project-Tests.dll", "Tests failed")
run("mono Tests/vendor/NSpecRunner.exe Tests/bin/Debug/Project-Tests.dll", "Specs failed")
end
task :default => :demo
# This is the important method
@MattesGroeger
MattesGroeger / Example.swift
Created June 21, 2017 12:24
Generic in-memory cache implementation for Swift 3.0
// create a chache with 60 seconds expiration time
var cache: InMemoryCache = InMemoryCache<LocalUrl>(expirationInSeconds: 60)
// data will either be returned from cache or created via callback and then returned
let data = cache.cachedData {
// do the heavy object creation here
return MyHeavyObject()
}
// invalidate the cache, next call will have to re-create the heavy object