Skip to content

Instantly share code, notes, and snippets.

View langford's full-sized avatar

Michael Langford langford

View GitHub Profile
@langford
langford / resize_icons.sh
Created April 29, 2011 16:54
Make other icons from 512x512
#!/bin/bash
export CONVERSIONAPP="/Applications/ImageMagick-6.5.8//bin/convert"
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Applications/ImageMagick-6.5.8//lib"
export MAGICK_HOME="/Applications/ImageMagick-6.5.8/"
$CONVERSIONAPP SpecificArtAssets/icons/512x512.png -resize 57x57 GeneratedFiles/Icon.png
$CONVERSIONAPP SpecificArtAssets/icons/512x512.png -resize 114x114 GeneratedFiles/Icon@2x.png
$CONVERSIONAPP SpecificArtAssets/icons/512x512.png -resize 72x72 GeneratedFiles/Icon-72.png
$CONVERSIONAPP SpecificArtAssets/icons/512x512.png -resize 29x29 GeneratedFiles/Icon-Small.png
$CONVERSIONAPP SpecificArtAssets/icons/512x512.png -resize 50x50 GeneratedFiles/Icon-Small-50.png
@langford
langford / InternetFailoverPlan
Created April 29, 2011 19:40
$212 upfront/ $624 Annual Internet failover plan
I've been having some connectivity problems off and on the last few
weeks due to storms taking out some combination of power/internet or
damaging some of the networking equipment here (in spite of the surge
protectors, etc in place) as well as a incident with bad wiring
getting worse due to storms/electrical shorts.
While the iPhone's tethering was a stopgap measure that helped in the
meanwhile, it was by no means a final solution, nor did it allow
efficient completion of the tasks at hand nor good communication while
things were going on as the phone would overheat if I left it running
@langford
langford / gist:1045517
Created June 24, 2011 19:42
Why is my UI frozen during this?
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionBeginFromCurrentState animations:^(void){
self.clippingContainerView.alpha = 1.0;
} completion:^(BOOL finished){
[UIView animateWithDuration:0.5 delay:5.5 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionBeginFromCurrentState animations:^(void){
self.clippingContainerView.alpha = 0.0;
} completion:^(BOOL finished){
self.state = cvcStateHiddenControls;
}];
}
];
#include "limits.h"
volatile int char_min = CHAR_MIN;
void limitPrint(void) {
printf("Size of Boolean type is %d byte(s)\n\n",
(int)sizeof(_Bool));
printf("Number of bits in a character: %d\n",
@langford
langford / gist:6165405
Last active December 20, 2015 16:59
.profile script to make git colorize and show what state your repo is in.
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function parse_git_branch_remote {
git rev-parse --git-dir > /dev/null 2>&1
if [ $? -eq 0 ]; then
@langford
langford / Apple.style
Created January 2, 2014 17:54
This format file does 99% of what I want out of my code's formatting It's only big flaw is that it overindents blocks (which will need to be fixed by the tool writer). There is a workaround for for another bug as well in the spec. All and all, pretty good. strictcodeapp.com
! DO NOT CHANGE THIS FILE MANUALLY !
STYLE_NAME=Apple
S_NAME=array
S_BEG
name[SOME]
S_END
@langford
langford / gist:9008754
Last active August 29, 2015 13:56
Cause IBOutletCollectionss are useful, but painful and ill supported by IB. You will want this code.
- (NSArray*)sortArrayByY:(NSArray*)array{
return [array sortedArrayUsingComparator:^NSComparisonResult(id label1, id label2) {
if ([label1 frame].origin.y < [label2 frame].origin.y) return NSOrderedAscending;
else if ([label1 frame].origin.y > [label2 frame].origin.y) return NSOrderedDescending;
else return NSOrderedSame;
}];
}
- (void)clearTextInArray:(NSArray*)array{
for (UILabel* label in array){
@implementation SwiperViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIScreenEdgePanGestureRecognizer *edgePanLeft = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleEdgePanLeft:)];
edgePanLeft.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:edgePanLeft];
@langford
langford / 0_reuse_code.js
Created April 3, 2014 14:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@langford
langford / gist:0e26ed9d46246b9546fb
Last active August 29, 2015 14:02
My .clang-format that comes pretty close to Apple style using Tony Arnold's build of clang-format
BasedOnStyle: Chromium
AlignTrailingComments: true
BreakBeforeBraces: Stroustrup
ColumnLimit: 0
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
AllowShortIfStatementsOnASingleLine: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerBindsToType: false