Skip to content

Instantly share code, notes, and snippets.

cd Resources
find . -iname '*.png' | grep -v '@x2' | sed 's/.png/@x2.png/g' | xargs ls > /dev/null
@cyborch
cyborch / better_than_puny.sh
Created November 25, 2010 06:05
ImageMagick parameters which outdoes PunyPNG at compressing their own example png.
convert original_image.png +dither -deconstruct -layers optimize-transparency -matte -depth 7 \( -clone 0--1 -background none +append -colors 65536 -unique-colors -write mpr:cmap +delete \) -map mpr:cmap better_than_puny.png
@cyborch
cyborch / NSObject+AutoreleaseProperties.m
Created February 25, 2011 19:34
Why something like this isn't done by NSObject#dealloc is beyond me...
#import <objc/runtime.h>
@implementation NSObject (AutoreleaseProperties)
- (void)releaseAllProperties {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
unsigned int outCount, i;
objc_property_t *properties = class_copyPropertyList([self class], &outCount);
for (i = 0; i < outCount; i++) {
objc_property_t property = properties[i];
@cyborch
cyborch / beautify.pl
Created April 7, 2011 17:56
While not a robust beautify library - this small snippet takes care of most cases
#!/usr/bin/perl
@_=<STDIN>;
$_=join("",@_);
# fix K&R style code
s/\s*\n\s*{/ {/gs;
s/}\s*\n\s*else/} else/gs;
s/ ?\){/\) {/g;
# convert "if( something ){" to "if (something) {"
s/if\( ?/if \(/g;
# ensure that "{" at end of line is preceeded by a space
//
// BPNavigationController.h
// StatusBarSize
//
// Created by Anders Borch on 10/16/11.
// Copyright (c) 2011 Bump. All rights reserved.
//
#import <UIKit/UIKit.h>
How to freak out your friends in case you die:
Set up cron job which runs every six months and sends an email
to your friends if the modify time of a given file is more than
six months ago. The email should include the contents of the file.
Update the file once per month with notes and responses to your
latest conversations with your friends until the day you die.
Result: http://www.huffingtonpost.com/2012/03/14/dead-man-emails-jack-froese_n_1346194.html
@cyborch
cyborch / gist:3901127
Created October 16, 2012 18:35
UIViewController snippet
-(BOOL)shouldAutorotate {
return YES;
}
-(NSInteger)supportedInterfaceOrientations {
// For some reason this is implemented in iOS5 but I have to do it myself in iOS6.
UIInterfaceOrientationMask mask = 0;
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortrait])
mask |= UIInterfaceOrientationMaskPortrait;
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft])
@cyborch
cyborch / patent-fix.txt
Created December 11, 2013 16:31
How to fix the patent system
How to fix the patent system:
Each time a legal entity files a patent the fee doubles. When an entity with patents acquires another entity with patents then the patent fee is recalculated and the difference must be paid to acquire the patents of the new entity.
Example:
Legal entity A files for its first design patent. The fee is $180.
Legal entity A files for its second design patent. The fee is $360.
@cyborch
cyborch / resetsubmodules.sh
Created January 15, 2015 19:14
Xcodeserver before integration trigger to ensure that the correct submodule revision is checked out
#!/bin/bash
# Ensure that pwd is $XCS_SOURCE_DIR/my_checkout_folder when
# executing this script as a "Before Integration" run script
# trigger.
#
# This should fix an issue in Xcodeserver which causes
# submodules to be checked out at HEAD of master branch in stead
# of the correct revision as specified in the owning module.
for DIR in `git submodule status | awk '{print $2}'` ; do

Keybase proof

I hereby claim:

  • I am cyborch on github.
  • I am cyborch (https://keybase.io/cyborch) on keybase.
  • I have a public key whose fingerprint is BA58 BDC3 D178 6859 249C 1F71 69E6 4646 F78E 107A

To claim this, I am signing this object: