Skip to content

Instantly share code, notes, and snippets.

txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (!self.tabBarIsShowing) {
self.tabBar.hidden = YES;
}
}
@alonecuzzo
alonecuzzo / FunctionalOfFuture.swift
Last active August 29, 2015 14:26
Code from Functional Presentation
// paperlesspost.com/api/v100/event?id=3948
//{
// id: 3948,
// eventName: "The Party For the LOLZ",
// hostName: "datFoolCuzzo"
//
//}
protocol JSONDecodable {
static func decode(json: JSON) -> Self?
@alonecuzzo
alonecuzzo / curry.swift
Last active August 29, 2015 14:27
Curry Swift
//adding without currying
func add(a: Int, b:Int) -> Int {
return a + b
}
//when we use the swift curry form this is what is happening behind the scenes
func addCurry(a: Int) -> (Int -> Int) {
@alonecuzzo
alonecuzzo / validIndicies.swift
Created August 13, 2015 03:14
Valid Selected Indicies
struct Datasource {
static let _items = ["Cats", "Dogs", "Crows", "Lions", "Owls", "Hawks", "Fish"]
static let items = Datasource._items + Datasource._items
static func validIndiciesForSelectedIndex(index: Int) -> (Int, Int) {
var offset: Int = 0
@alonecuzzo
alonecuzzo / RAC.swift
Created August 20, 2015 19:24
RAC presentation
import UIKit
import ReactiveCocoa
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
:param: delay The delay before execution.
:param: handler A closure to execute after `delay`.
public class DataHandler extends EventDispatcher {
private static var _instance:DataHandler;
private static var allowInstantiation:Boolean;
private var xmlPath:String;
private var xml:XML;
private var xmlLoader:URLLoader;
private static var _xmlpath:String;
public function setXMLPath (thisXML:String) : void {
_xmlpath = thisXML;
@alonecuzzo
alonecuzzo / OMFG
Created November 9, 2010 22:22
OMFG PAUL
public class DataHandler extends EventDispatcher {
private static var _instance:DataHandler;
private static var allowInstantiation:Boolean;
private var xmlPath:String;
private var xml:XML;
private var xmlLoader:URLLoader;
private static var _xmlpath:String;
public function setXMLPath (thisXML:String) : void {
_xmlpath = thisXML;
@alonecuzzo
alonecuzzo / gist:1401446
Created November 28, 2011 18:35
full text search, multi indexing mongo - ruby
class Recipe < MongoRecord::Base
collection_name :recipes
fields :name, :directions, :words
def to_s
"recipe: #{name} directions: #{directions[0..20]}..."
end
def Recipe.make collection, name, directions
collection.insert({:_id => Mongo::ObjectID.new, :name => name,
:directions => directions,
:words => (name + ' ' + directions).split.uniq})
@alonecuzzo
alonecuzzo / gist:1402206
Created November 28, 2011 21:42
mongoid wrapping
if(strcasecmp(get_class($id), "mongoid")) {
$_id = $_id->{'$id'};
}
$this->data=Db::$tours->findOne(array('_id'=>new MongoId($_id)));