Skip to content

Instantly share code, notes, and snippets.

View swizzlr's full-sized avatar

Thomas Catterall swizzlr

View GitHub Profile
@swizzlr
swizzlr / profiling_swift_in_linux.md
Created November 15, 2017 19:51
Profiling Swift Apps on Linux

Profiling Swift in Linux

In order to profile memory leakage/heap growth in Swift on Linux, you need to a) run it on Linux b) use a profiling tool.

Docker and Valgrind to the rescue.

Installing Valgrind in a Linux container

We're using the official Swift image here: FROM swift:4.

@swizzlr
swizzlr / scaler.sh
Created January 12, 2013 00:14
Change your Retina Mac's screen scale from the Terminal!
#!/bin/bash
#An Applescript embedded in a shell script so I can do this on the command line. Sorry.
#Don't put this on a non retina Mac. Bad Things™ will happen.
#by @tomcatterall/@ares (Twitter/App.net). Say something nice to me if you use and like this, I'd love to know.
echo 'on run argv
try
set theDisplayArgument to item 1 of argv as number
@swizzlr
swizzlr / blockdeclsyntax.md
Created August 19, 2013 13:11
Block Declaration Syntax List, originally by [pcperini](http://stackoverflow.com/a/9201774/929581), parsed to markdown for printing with your favourite CSS (I recommend @ttscoff's Marked)

List of Block Declaration Syntaxes

Throughout, let

  • return_type be the type of object/primitive/etc. you'd like to return (commonly void)
  • blockName be the variable name of the block you're creating
  • var_type be the type object/primitive/etc. you'd like to pass as an argument (leave blank for no parameters)
  • varName be the variable name of the given parameter And remember that you can create as many parameters as you'd like.

Blocks as Variables

Possibly the most common for of declaration.

Keybase proof

I hereby claim:

  • I am swizzlr on github.
  • I am swizzlr (https://keybase.io/swizzlr) on keybase.
  • I have a public key ASA5tzDcY23K608c2PyNL1okwf-hhiGmpFDSlqLbTU6SOwo

To claim this, I am signing this object:

@swizzlr
swizzlr / gist:30c7de9d05b39b1da3dc
Created May 21, 2015 17:29
Swift AST Node Types
source.lang.swift.decl.function.free
source.lang.swift.ref.function.free
source.lang.swift.decl.function.method.instance
source.lang.swift.ref.function.method.instance
source.lang.swift.decl.function.method.static
source.lang.swift.ref.function.method.static
source.lang.swift.decl.function.method.class
source.lang.swift.ref.function.method.class
source.lang.swift.decl.function.accessor.getter
source.lang.swift.ref.function.accessor.getter
@swizzlr
swizzlr / LMLPlaintextResponseSerializer.m
Last active March 15, 2017 09:29
Plaintext response serializer for AFNetworking.
@interface LMLPlaintextResponseSerializer : AFHTTPResponseSerializer
@end
@implementation LMLPlaintextResponseSerializer
- (id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error {
[super responseObjectForResponse:response data:data error:error]; //BAD SIDE EFFECTS BAD BUT NECESSARY TO CATCH 500s ETC
NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)([response textEncodingName] ?: @"utf-8")));
return [[NSString alloc] initWithData:data encoding:encoding];

#How to Generate a Self Signed SSL Server Certificate on a Mac ###Open Keychain Access and go here ###Select SSL Server and name it ###??? ###PROFIT11!!!11!1!!

#!!! last updated 11/12/2013. git 1.8.5, BBEdit 10.5, OS 10.9, ruby 2, Xcode 5 !!!#

#Long Operations ##Dropbox and Sync https://www.dropbox.com/downloading

##Homebrew (req for RVM)

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

Hi there,

So you want to try out my sweet new change to Cocoapods?

You need to go to a working directory to clone my fork:

git clone https://github.com/swizzlr/CocoaPods.git

and cd CocoaPods. Then

//Do whatever you want with this except apply a GPL license to it.
//credit to @mattt for the below ifndef
//make sure you only give it things that respond to "Frame" and return a CGRect
@class NSArray;
#ifndef NS_ENUM
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type