Skip to content

Instantly share code, notes, and snippets.

View gist:aabd8cba41c23047477acb1047a488c8
pragma solidity ^0.4.0;
contract ContentCreatorScore {
address public owner = msg.sender;
struct Review { string journalistId;
string correctness;
string freeText;
string depth;
string url;
terhechte / sh
Created Aug 11, 2017
Kill sourcekit if it consumes more than N amount of memory
View sh
while true; do
fields=`ps aux -m | head | grep -i sourcekitd | tr -s ' '`
mem=`echo $fields | cut -d ' ' -s -f 6| awk '{$1=$1/1024; print $1;}' | cut -d '.' -f 1`
pid=`echo $fields | cut -d ' ' -s -f 2`
# how much mem before we're killing it. default 5000
if [ "$mem" -gt 5000 ]; then
echo "Killing sourcekitservice pid $pid with mem $mem"
kill -9 $pid
sleep 5
terhechte /
Created Oct 23, 2016
Fill Xcode Product with unused space so the app looks bigger than it is
# What crazy talk is this?
# See:
# In a world where everything has to be bigger, faster, higher and more,
# users seem to have developed the expectation that the bigger the software
# package, the better the software. However, if you fill up your binary with
# useless data, the app store size might be too high and your app will
# require download over wifi.
# The following script can be added to your Xcode target as a shell script.
View gist:e32587b783c3b8ef5fb8
print("Swiftstub Running XCode 7.1 Swift 2")
typealias Item = String
enum ObserverAction {
case Update(items: [Item])
case Delete(items: [Item])
case Insert(items: [Item])
terhechte / slow_kvo_dictionary_example2.m
Created Dec 7, 2011
Example 1 of slow and fast NSDictionary access
View slow_kvo_dictionary_example2.m
// Created by Benedikt Terhechte on 07.12.11.
#import <Foundation/Foundation.h>
#define AKeyPathDictionary(dictionary, A) [dictionary objectForKey:@A]
#define BKeyPathDictionary(dictionary, A, B) [AKeyPathDictionary(dictionary, A) objectForKey:@B]
#define CKeyPathDictionary(dictionary, A, B, C) [BKeyPathDictionary(dictionary, A, B) objectForKey:@C]
#define DKeyPathDictionary(dictionary, A, B, C, D) [CKeyPathDictionary(dictionary, A, B, C) objectForKey:@D]

Keybase proof

I hereby claim:

  • I am terhechte on github.
  • I am terhechte ( on keybase.
  • I have a public key whose fingerprint is 9637 08F2 4838 F953 6D90 FA3F 7CD9 6B05 258B 7980

To claim this, I am signing this object:

terhechte / gtk3-swift-package-issues.scala
Last active Jan 23, 2016
GTK3 Linux Swift header issues
View gtk3-swift-package-issues.scala
I tried to get GTK running with Swift. To run this, a Linux machine with a working GTK3
installation is needed (could also work with OSX && brew install gtk+3, however I did not try that);
`sudo apt-get install libgtk-3-dev`
Initially I tried with GTK but since GTK has dependencies to a lot of other things, I tried something
simpler, i.e. in this case GDK which has only dependencies to X11.
terhechte / urlschemetables.sql
Created Jan 25, 2014
postgresql url partition scheme setup
View urlschemetables.sql
CREATE TABLE urls_s (CHECK (ascii(url) in (115))) INHERITS (urls);
CREATE TABLE urls_ak (CHECK (ascii(url) in (97, 107))) INHERITS (urls);
CREATE TABLE urls_bl (CHECK (ascii(url) in (98, 108))) INHERITS (urls);
CREATE TABLE urls_cj (CHECK (ascii(url) in (99, 106))) INHERITS (urls);
CREATE TABLE urls_de (CHECK (ascii(url) in (100, 101))) INHERITS (urls);
CREATE TABLE urls_fg (CHECK (ascii(url) in (102, 103))) INHERITS (urls);
CREATE TABLE urls_hiv (CHECK (ascii(url) in (104, 105, 118))) INHERITS (urls);
CREATE TABLE urls_mr (CHECK (ascii(url) in (109, 114))) INHERITS (urls);
CREATE TABLE urls_np (CHECK (ascii(url) in (110, 112))) INHERITS (urls);
CREATE TABLE urls_txzyo (CHECK (ascii(url) in (116, 120, 122, 121, 111))) INHERITS (urls);
terhechte / postgresql-trigger.sql
Last active Jan 4, 2016
Postgresql url partition scheme action trigger function
View postgresql-trigger.sql
CREATE OR REPLACE FUNCTION url_insert_trigger()
IF (ascii(NEW.url) in (115)) THEN
ELSIF (ascii(NEW.url) in (97, 107)) THEN
ELSIF (ascii(NEW.url) in (98, 108)) THEN
View gist:4665223
import os
# go through the whole folder, and add all directories, that contain sourcecode
# Which directories to scan
directories = ("MyFantasticProject", "External", "libs")
def find_all_source_directories(parentDir):
def directories_contains_source(files):
for f in files: