Skip to content

Instantly share code, notes, and snippets.

View aclissold's full-sized avatar

Andrew Clissold aclissold

View GitHub Profile
@aclissold
aclissold / move.sh
Created September 21, 2015 23:01
Rename <num>.c <num>/main.c
#!/bin/bash
for f in $(ls *.c)
do
echo $f
dir=$(echo $f | sed -e 's/.c//g')
mv $f $dir/main.c
done
@aclissold
aclissold / main.m
Created June 17, 2015 19:53
Objective-C from the command line
// cc -fobjc-arc -framework Foundation main.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"hello, world");
}
return 0;
}
@aclissold
aclissold / NSUserDefaults+UIColor.swift
Created June 1, 2015 14:52
Swift NSUserDefaults UIColor extension
extension NSUserDefaults {
func colorForKey(key: String) -> UIColor? {
var color: UIColor?
if let colorData = dataForKey(key) {
color = NSKeyedUnarchiver.unarchiveObjectWithData(colorData) as? UIColor
}
return color
}
@aclissold
aclissold / get.swift
Created May 31, 2015 19:21
Swift GET request using spam and Alamofire
import Foundation
import Alamofire // Alamofire/Alamofire
import Blocker // aclissold/Blocker
Alamofire.request(.GET, "http://httpbin.org/get").responseJSON {
(_, _, JSON, _) in
if let JSON = JSON as? [String: AnyObject] {
println(JSON)
}
@aclissold
aclissold / go.zsh
Created February 19, 2015 15:10
Fork of the deprecated Go Zsh plugin for my dotfiles
# Copyright (c) 2012 The Go Authors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
@aclissold
aclissold / crash.swift
Created February 18, 2015 03:55
Interesting way to crash Swift
class OneClass {}
class AnotherClass {}
let one = OneClass()
let another = AnotherClass()
let crash = one as AnyObject as AnotherClass
@aclissold
aclissold / ascii.txt
Created February 17, 2015 02:10
All visible ASCII characters
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
diff --git a/The Oakland Post/PostTableViewController.swift b/The Oakland Post/PostTableViewController.swift
index a2666ed..7f5c336 100644
--- a/The Oakland Post/PostTableViewController.swift
+++ b/The Oakland Post/PostTableViewController.swift
@@ -17,7 +17,7 @@ class PostTableViewController: BugFixTableViewController, MWFeedParserDelegate,
}
var baseURL: String!
- var feedParser: FeedParser!
+ var feedParser: MWFeedParser!
@aclissold
aclissold / after.swift
Created December 7, 2014 02:29
For github.com/Keithbsmiley/swift.vim/pull/30
// MARK: NHBalancedFlowLayoutDelegate
func collectionView(collectionView: UICollectionView!,
layout collectionViewLayout: NHBalancedFlowLayout!,
preferredSizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize {
if UIScreen.mainScreen().scale == 1.0 {
var size = photos[indexPath.item].size
size.width /= 2
size.height /= 2
return size
let fruits = ["apple", "bananananana"]
/*
var s: String
if fruits.count == 1 {
s = ""
} else {
s = "s"
}