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 / 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++) {
a = (1,2)
foo = set()
a in foo
foo.add(a)
a in foo
(1,2) in foo
(2,1) in foo

· 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)

@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
{
"installed_packages":
[
"GoSublime",
"Stylus",
"nginx"
]
}
@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/[email protected] original.png
sips -Z 80 --out build/[email protected] original.png
sips -Z 120 --out build/[email protected] original.png
sips -Z 58 --out build/[email protected] original.png
sips -Z 40 --out build/iPadSpotlight-40x40.png original.png
sips -Z 80 --out build/[email protected] original.png
sips -Z 76 --out build/iPadApp-76x76.png original.png
@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 / 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 / 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 / InfiniteUIScrollView.m
Created February 7, 2014 23:54
Infinite UIScrollView with dynamically added/removed views
//
// RootViewController.m
// ScrollTest
//
// Created by Marcus Westin on 2/7/14.
// Copyright (c) 2014 Marcus Westin. All rights reserved.
//
#import "RootViewController.h"