Skip to content

Instantly share code, notes, and snippets.

@rpavlik
rpavlik / fix_homebrew.rb
Created January 6, 2011 20:32 — forked from mxcl/install_homebrew.markdown
Fix permissions on /usr/local for Homebrew
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@jonathanpenn
jonathanpenn / unix_instruments.sh
Last active January 26, 2016 19:09
Make Instruments play nice with unix by returning > 0 status code if build fails
#!/usr/bin/env bash
#
# Copyright (c) 2013 Jonathan Penn (http://cocoamanifest.net)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@steipete
steipete / iOSDocumentMigrator.m
Created December 6, 2011 15:21
Helps migrating documents between iOS <= 5.0 and >= 5.0.1 to comply with Apple's iCloud guidelines. Follow @steipete on Twitter for updates.
#include <sys/xattr.h>
/// Set a flag that the files shouldn't be backuped to iCloud.
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath {
u_int8_t b = 1;
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available.
+ (NSString *)legacyStoragePath {
@mnem
mnem / nah_xcode_uncrustify.rb
Last active February 1, 2020 20:12
Script file to be run as an Xcode 4 behaviour which uncrustifies the project source using reasonable Objective-C formatting defaults. Alternatively, you can run it and pass a path to uncrustify.
#!/usr/bin/env ruby
###########################################################################
# Script to be called as an Xcode 4 behaviour which will attempt to
# uncrustify all source files in the open project.
#
# (c) Copyright 2012 David Wagner.
#
# Complain/commend: http://noiseandheat.com/
#
#*************************************************************************#
@cbowns
cbowns / api_keys.rb
Created February 21, 2012 22:54
A script for Xcode 4.x to use API keys stored in ~/.api_keys and insert them into your app bundle’s Info.plist (instead of committing them to a repository)
# An API keys script written by Patrick Gibson (@patr1ck) and Christopher Bowns (@cbowns)
# This script sets API keys in your app's Info.plist from an .api_keys file you keep in your home directory (~/.api_keys)
# This allows you to not check API keys into your source control system,
# or for different developers to use different keys without needing to patch their working copies.
# Installation directions:
=begin
1. Create a Run Script build phase in your Xcode project before Compile Sources
2. Copy and paste this whole script in.
3. Create or modify your .api_keys file to hold your API keys
@bignerdranch
bignerdranch / BNRTimeBlock.h
Created March 9, 2012 13:51
Timing Utility Post 20120308
CGFloat BNRTimeBlock (void (^block)(void));
@reinhrst
reinhrst / dct.c
Created March 20, 2012 19:46
DCT-II implementation using the vDSP on the iOS (and also OSX?)
/* This implementation does DCT-II on iOS, using the iOS vDSP FFT methods. Supposedly this is faster than in plain C (i.e. FFTW), but I didn't do any tests to support this claim. For one thing, as far as I understand it, doing DCT takes less clock cycles than FFT, and using this code we do an FFT of size 2N for a DCT of size N (and then some post processing. Anyone is welcome to comment :)
This code was developed using the following 2 sources, and I owe great gratitude to their authors: http://developer.apple.com/library/ios/#documentation/Performance/Conceptual/vDSP_Programming_Guide/UsingFourierTransforms/UsingFourierTransforms.html and http://www.hydrogenaudio.org/forums//lofiversion/index.php/t39574.html
I don't claim I understand everything I do, but the thing is, it works -- as in, it gives me the same result as jtransform with scaling on :) And it's fast enough for my use: on the iPhone 4S I can get 320 DCTs of length 2048 per second. Perhaps I can improve this with some further tweaking (although I'
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@Kr1sso
Kr1sso / gist:4244369
Created December 9, 2012 11:31
Enum debugging automation for Objective C, eg. with a TextExpander snippet
#!/usr/bin/ruby
def NSStringFromEnum(input)
inputArray = input.lines.collect
typeNameLine = inputArray[-1]
typeName = typeNameLine.match(/(\w+);/)[1]
output = "NSString* NSStringFrom#{typeName}(#{typeName} value) {\n switch (value) {\n";
constantLines = inputArray[1..-2]
@BenedictC
BenedictC / gist:4246759
Created December 9, 2012 20:03
A marco for creating enums with values which can be logged (inspired by http://rentzsch.tumblr.com/post/37512716957/enum-nsstring and long train journey).
#define EMKStringableEnum(ENUM_NAME, ENUM_VALUES...) \
\
typedef enum { \
ENUM_VALUES \
} ENUM_NAME; \
\
\
\
static NSString * ENUM_NAME##ToString(int enumValue) { \
static NSString *enumDescription = @"" #ENUM_VALUES; \