Skip to content

Instantly share code, notes, and snippets.

@maddiesch
maddiesch / auto.sh
Created October 15, 2013 22:09
Auto increment build numbers
echo "Bumping build number..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}
# increment the build number (ie 115 to 116)
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "No build number in $plist"
exit 2
fi
@maddiesch
maddiesch / start.sh
Created July 10, 2013 03:43
A simple bash script for starting a minecraft server. Allows passing a couple command line arguments for memory and game type.
#!/bin/bash
###
## A simple bash script for starting a minecraft server
##
## Options:
## -g : Sets the game mode. 0|1 (default 0)
## -m : Sets the amount of memory to start with. (default 756)
## -t : Sets the memory type. (default M)
##
@maddiesch
maddiesch / gist:4727403
Last active November 12, 2022 15:25
Create an animated UIImage from .gif data.
+ (UIImage *)imageFromGifData:(NSData *)data {
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFTypeRef)data, NULL);
if (!source) {
return nil;
}
CFDictionaryRef dict = CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSDictionary *metadata = (__bridge NSDictionary *)dict;
CGFloat offset = 0.0;
if (metadata[@"{GIF}"]) {
NSDictionary *meta = metadata[@"{GIF}"];
@maddiesch
maddiesch / NSString.m
Last active October 12, 2015 19:58
URL encode a string
- (NSString *)urlEncodeStringUsingEncoding:(NSStringEncoding)encoding {
return (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ", CFStringConvertNSStringEncodingToEncoding(encoding));
}
@maddiesch
maddiesch / .bash
Created April 6, 2012 23:28
SSH into minecraft server and create a screen or connect to a screen.
alias minecraft='ssh -t [email protected] "screen -dR"'