Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Clissold aclissold

View GitHub Profile
@aclissold
aclissold / move.sh
Created Sep 21, 2015
Rename <num>.c <num>/main.c
View move.sh
#!/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 Jun 17, 2015
Objective-C from the command line
View main.m
// 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 Jun 1, 2015
Swift NSUserDefaults UIColor extension
View NSUserDefaults+UIColor.swift
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
Swift GET request using spam and Alamofire
View get.swift
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 Feb 19, 2015
Fork of the deprecated Go Zsh plugin for my dotfiles
View go.zsh
# 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 Feb 18, 2015
Interesting way to crash Swift
View crash.swift
class OneClass {}
class AnotherClass {}
let one = OneClass()
let another = AnotherClass()
let crash = one as AnyObject as AnotherClass
@aclissold
aclissold / ascii.txt
Created Feb 17, 2015
All visible ASCII characters
View ascii.txt
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
View parser.diff
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 Dec 7, 2014
For github.com/Keithbsmiley/swift.vim/pull/30
View after.swift
// 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
View ternary.swift
let fruits = ["apple", "bananananana"]
/*
var s: String
if fruits.count == 1 {
s = ""
} else {
s = "s"
}