Skip to content

Instantly share code, notes, and snippets.

View jballanc's full-sized avatar

Joshua Ballanco jballanc

View GitHub Profile
@jballanc
jballanc / flatteno.clj
Last active January 2, 2016 13:18
Utility functions for Clojure's core.logic that can unwrap or flatten an arbitrarily deeply nested list (or list of lists).
(ns core.logic.util.flatteno
(:require [clojure.core.logic :as cl]))
(cl/defna unwrapo
"Unwrapps an arbitrarily deeply nested list"
[l o]
([[e] o]
(unwrapo e o))
([[f . r] o]
(cl/conso f r o)))
// So, ECMAScript 6 Harmony arrow_function_syntax says:
// ----8<----8<----8<----
// ''=>'' has only lexical ''this'', no dynamic ''this''
const obj = {
method: function () {
return () => this;
}
};
assert(obj.method()() === obj);
#include <stdlib.h>
#include <stdio.h>
#include <luajit-2.0/lua.h>
#include <luajit-2.0/lualib.h>
#include <luajit-2.0/lauxlib.h>
#include "main.h"
#define CHECK_LOADED(i) if(i) {\
fprintf(stderr, "Problem loading: %s\n",\
lua_tostring(L, -1));\
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