Skip to content

Instantly share code, notes, and snippets.

Torsten Becker torsten

Block or report user

Report or block torsten

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am torsten on github.
  • I am torsten (https://keybase.io/torsten) on keybase.
  • I have a public key whose fingerprint is E054 EF92 AC0F B3E7 9BA3 5F8A 6B9B FA0C CE67 02B9

To claim this, I am signing this object:

View expanding-json-arrays-to-rows.sql
-- Related blog post to this Gist:
-- https://torsten.io/stdout/expanding-json-arrays-to-rows
-- Run these commands on a interactive RedShift session:
CREATE TEMP TABLE clusters AS (
SELECT 1 AS id, '[1, 2]' AS node_sizes UNION ALL
SELECT 2 AS id, '[5, 1, 3]' AS node_sizes UNION ALL
SELECT 3 AS id, '[2]' AS node_sizes
);
@torsten
torsten / EC2 Instance Types.md
Created Oct 31, 2013
AWS EC2 Instance specs and price in one table: http://git.io/ec2-prices
View EC2 Instance Types.md

Combine http://aws.amazon.com/ec2/pricing/ and http://aws.amazon.com/ec2/instance-types/#selecting-instance-types into one f*cking table.

Type | Arch | vCPU | ECU | Mem | Storage | EBS-optimized | Network | Price ------|------|------|------|-----|-----|---------|---------------|---------------------|-------- General ||||||||| t1.micro | 32/64 | 1 | Variable | 0.615 | EBS only | - | Very Low | $0.020 m1.small | 32/64 | 1 | 1 | 1.7 | 1 x 160 | - | Low | $0.065 m1.medium | 32/64 | 1 | 2 | 3.75 | 1 x 410 | - | Moderate | $0.130 m1.large | 64 | 2 | 4 | 7.5 | 2 x 420 | Yes | Moderate | $0.260

@torsten
torsten / check-non-latin.m
Created Dec 2, 2012
iOS: Heuristic to check for non latin languages
View check-non-latin.m
// clang -framework Foundation check-non-latin.m && ./a.out
#import <Foundation/Foundation.h>
int main (int argc, char const *argv[])
{
@autoreleasepool
{
NSDictionary *langToText = @{@"arabic": [NSString stringWithUTF8String:"العربي"],
@"japanese": [NSString stringWithUTF8String:"日本"],
@torsten
torsten / delete-all-objects.m
Created Oct 30, 2012
Delete all objetcts in a MOC
View delete-all-objects.m
NSArray *entities = self.managedObjectContext.persistentStoreCoordinator.managedObjectModel.entities;
for (NSEntityDescription *desc in entities)
{
NSFetchRequest *allObjectsRequest = [NSFetchRequest fetchRequestWithEntityName:desc.name];
NSError *fetchError;
NSArray *allObjects = [self.managedObjectContext executeFetchRequest:allObjectsRequest error:&fetchError];
if (allObjects)
{
@torsten
torsten / OpenDash.tmCommand
Created Sep 27, 2012
TextMate Command to Open Dash for Selection/Current Word
View OpenDash.tmCommand
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>open "dash://${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}"</string>
<key>input</key>
<string>none</string>
@torsten
torsten / fix-whitespace.sh
Created Sep 12, 2012
Pre-commit hook script for git to fix whitespace and long lines.
View fix-whitespace.sh
#!/bin/sh
# Pre-commit hook for git which removes trailing whitespace, converts tabs to spaces, and enforces a max line length.
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@torsten
torsten / test-cycle-warnings.m
Created Jul 9, 2012
Retain cylcle warnings
View test-cycle-warnings.m
// Illustrates that not all causes of retain cycles are detected by clang. Compile with:
// clang -fobjc-arc -Wall -framework Foundation test-cycle-warnings.m && ./a.out
#import <Foundation/Foundation.h>
@interface Foo : NSObject
typedef void (^Block)();
@property (readwrite, copy) Block asd;
@torsten
torsten / annti_blockSelf.m
Created Jun 12, 2012
Experiment if __block causes a retain.
View annti_blockSelf.m
// Run with:
// clang -fobjc-arc -Wall -framework Foundation blockself.m && ./a.out
// Further reading:
// http://www.mikeash.com/pyblog/friday-qa-2009-08-14-practical-blocks.html
// http://clang.llvm.org/docs/AutomaticReferenceCounting.html#misc.blocks
// http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html
#import <Foundation/Foundation.h>
@torsten
torsten / BetterTestCase.m
Created May 15, 2012
Bugfix for SenTestCase when using base classes for test cases.
View BetterTestCase.m
// OCUnit/SenTestCase's vanilla testInvocations method does not produce a unique list of methods
// when you inherit from a common test base class. Currently it will call the same test methods
// multiple times, depending on the number of base classes.
//
// To prevent these duplicate test method calls, override testInvocations like this.
//
// Written in 2012 by Torsten Becker <torsten.becker@gmail.com>
@interface BetterTestCase : SenTestCase
You can’t perform that action at this time.