Skip to content

Instantly share code, notes, and snippets.

View jballanc's full-sized avatar

Joshua Ballanco jballanc

View GitHub Profile
class SampleController < UIViewController
def viewDidLoad
super
self.view.backgroundColor = UIColor.whiteColor
frame = UIScreen.mainScreen.applicationFrame
origin = frame.origin
size = frame.size
text_view = UITextView.alloc.initWithFrame([[origin.x, origin.y],
@jballanc
jballanc / comp-map.clj
Created November 28, 2013 10:38
Compare nested maps
(defn comp-map [ma mb]
(reduce (fn [a [k v]]
(and a
(if (and (map? v) (map? (mb k)))
(comp-map v (mb k))
(= v (mb k)))))
true
ma))
(comp-map {:a {:b 2 :c 3}} {:a {:b 2 :c 3}})) ;=> true
(ns space-age)
(defn on-earth [seconds]
(/ seconds 31557600.0))
(def orbital-periods
{:mercury 0.2408467
:venus 0.61519726
:mars 1.8808158
:jupiter 11.862615
@jballanc
jballanc / gist:7354050
Last active December 27, 2015 16:19 — forked from smiler/gist:7353931
(let [dt (elapsed-time t)
balls (->> balls
(map #(move % dt))
(map #(keep-in-bounds dt ctx %)))]
;; Do stuff with balls
)

Background

  • MacRuby was going to be Ruby for OS X
  • JIT Compiler or AOT Compiler
  • Experimental static compilation
  • The Garbage Collector - libauto

Building an App

new-session
set -g default-command "reattach-to-user-namespace -l zsh"
set -g status-bg black
set -g status-fg green
setw -g window-status-current-bg yellow
setw -g window-status-current-fg black
set -g base-index 1
set -g renumber-windows on
set nocompatible " We're running Vim, not Vi!
syntax on " Enable syntax highlighting
filetype off " Disable filetype detection to keep Vundle happy
set shiftwidth=2 " That's a good tab width
set expandtab " ...and we don't like tab chars
set ts=8 " The only tabs we encounter should be in C code
set softtabstop=2
set tw=132 " Wrapping to 132, vt100 default
set wrap
set grepprg=/usr/local/bin/ag " Ag is best
require 'benchmark'
class TestBench
VALUES = { first: "A",
second: "B",
third: "C",
fourth: "D" }
def check_with_map(val)
VALUES.fetch(val, "not found")
@jballanc
jballanc / gist:5748205
Created June 10, 2013 11:50
Benchmarking ConcurrentCollectionOperations
Before abuse of C:
18.902s
18.798s
18.789s
18.921s
18.992s
=======
Avg: 18.880s
@jballanc
jballanc / SenTestCrazy.m
Created June 9, 2013 13:26
Add this to your SenTestCase subclass to name your tests something other than "test..." (in this case "benchmark...", but you can make it whatever you like by changing the "strncmp" line).
+ (NSArray *)testInvocations {
unsigned int methodCount;
Method *methods = class_copyMethodList(self, &methodCount);
assert(methodCount);
Method method;
SEL methodName;
NSMethodSignature *methodSig;
NSMutableArray *invocations = [[NSMutableArray alloc] init];