Skip to content

Instantly share code, notes, and snippets.

@kevinmcmahon
kevinmcmahon / gist:2295471
Created April 3, 2012 20:59
Create a 1x1 UIImage from a UIColor
- (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@jbgo
jbgo / git-recover-branch.md
Last active March 29, 2024 05:04
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@cloudhead
cloudhead / haskell-fiddling.hs
Created August 28, 2009 01:50
learning haskell
doubleMe x = x + x
doubleUs x y = doubleMe x + doubleMe y
doubleSmallNumber x = if x < 100
then x * 2
else x
eoeo xs = [if mod x 2 == 0 then 'e' else 'o' | x <- xs]
length'' xs = sum [1 | _ <- xs]
combo xs ys = [x ++ " " ++ y | x <- xs, y <- ys]
nestedEven xxs = [[ x | x <- xs, even x] | xs <- xxs]