Skip to content

Instantly share code, notes, and snippets.

View marcuswestin's full-sized avatar

Marcus Westin marcuswestin

  • New York
View GitHub Profile
@marcuswestin
marcuswestin / UIColor+fun.m
Created February 11, 2014 19:20
UIColor creators
// UIColor* red = rgb(255,0,0);
// UIColor* steelblue = [UIColor fromHex:0x4682B4];
// UIColor* shade = rgba(150,150,150,0.5);
UIColor* rgba(CGFloat r, CGFloat g, CGFloat b, CGFloat a) {
return [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
}
UIColor* rgb(CGFloat r, CGFloat g, CGFloat b) {
return rgba(r, g, b, 1.0);
}
@marcuswestin
marcuswestin / mysql-emoji-charset.sql
Created February 28, 2014 13:01
Mysql charset fix for emojis in text columns.
CREATE TABLE message (
body TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL
);
-- Then add to conf: `character-set-server = utf8mb4`
@marcuswestin
marcuswestin / Defaults list domains for preferences & settings OS X
Last active August 29, 2015 14:05
List apps with stored preferences
defaults domains | tr ',' '\n' | grep Foo
defaults delete `defaults domains | tr ',' '\n' | grep Reveal`
@marcuswestin
marcuswestin / generate-ios-icon.sh
Created August 26, 2014 03:25
Generate iOS app icons from a single source
mkdir -p build
sips -Z 58 --out build/iPhoneSettings-29x29@2x.png original.png
sips -Z 80 --out build/iPhoneSpotlight-40x40@2x.png original.png
sips -Z 120 --out build/iPhoneApp-60x60@2x.png original.png
sips -Z 58 --out build/iPadSettings-29x29@2x.png original.png
sips -Z 40 --out build/iPadSpotlight-40x40.png original.png
sips -Z 80 --out build/iPadSpotlight-40x40@2x.png original.png
sips -Z 76 --out build/iPadApp-76x76.png original.png
{
"installed_packages":
[
"GoSublime",
"Stylus",
"nginx"
]
}
@marcuswestin
marcuswestin / rename-recursive.sh
Created September 16, 2014 21:06
Change extension of all files
find . | grep .css | while read file; mv ${file/.css/.styl} $file; done

· Create xcode Framework (MySDK) · Create xcode Project (MyDemo) · Create workspace · Add projects to workspace (Must close them first!)

· Create MySDK.h/.m in framework. · In SDK project Build Phases > Headers > Move MySDK.h from Project to Public.   Create new target in SDK project (Aggregate Target, e.g MySDK_ALL)   Under new target "Build Phases" select "Add Run Script" and copy the contents of the script below   Select Aggregate Target scheme, then build (cmd+b)

a = (1,2)
foo = set()
a in foo
foo.add(a)
a in foo
(1,2) in foo
(2,1) in foo
@marcuswestin
marcuswestin / download.js
Created November 28, 2014 03:24
Download a bunch of files in parallel. Depends on `npm install request`
var fs = require('fs'),
request = require('request');
var download = function(uri, filename, callback){
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
}
var urls = JSON.parse(fs.readFileSync('./urls.json'))
for (var i=0; i<25; i++) {
@marcuswestin
marcuswestin / gist:9a8154cb97c03b5243db
Created December 12, 2014 02:49
How to paint walls fast, without tape
First, corners and edges (same as with windows really):
https://www.youtube.com/watch?v=g-uBQrbs6Ls
Then, the walls:
https://www.youtube.com/watch?v=bvJ90XnO2KM