Skip to content

Instantly share code, notes, and snippets.

View andrewberls's full-sized avatar

Andrew Berls andrewberls

View GitHub Profile
class NoSuchElementException < StandardError; end
class Option
def initialize(val)
@val = val
end
def present?
!@val.nil?
end
// Functional Programming in C++
http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/
# lib/cache_proxy.rb
class CacheProxy
class << self
attr_accessor :cache
end
def initialize(obj)
@obj = obj
end
Aug 23 00:46:04 app-3 kernel: [958008.758126] Killed process 3599 (ruby) total-vm:12240780kB, anon-rss:402668kB, file-rss:0kB
Aug 23 00:46:04 app-3 kernel: [958008.761313] in:imklog invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Aug 23 00:46:04 app-3 kernel: [958008.761316] in:imklog cpuset=/ mems_allowed=0
Aug 23 00:46:04 app-3 kernel: [958008.761319] CPU: 0 PID: 418 Comm: in:imklog Tainted: GF 3.13.0-24-generic #46-Ubuntu
Aug 23 00:46:04 app-3 kernel: [958008.761320] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Aug 23 00:46:04 app-3 kernel: [958008.761321] 0000000000000000 ffff880079eb9980 ffffffff81715a64 ffff88007f90dfc0
Aug 23 00:46:04 app-3 kernel: [958008.761325] ffff880079eb9a08 ffffffff8171039f ffffffff81067876 ffff880079eb99e0
Aug 23 00:46:04 app-3 kernel: [958008.761327] ffffffff810c74dc 0000000000000000 ffff88007fffae28 0000000000000000
Aug 23 00:46:04 app-3 kernel: [958008.761330] Call Trace:
Aug 23 00:46:04 app-3 kernel: [958008.761334] [<ffffffff81715a64>] du
import Control.Monad
import Data.Maybe
import Text.Printf
import qualified Data.DateTime as DT
data Interval = Interval { start :: DT.DateTime
, end :: DT.DateTime }
deriving (Show)
-- TODO: this shouldn't exist
@andrewberls
andrewberls / scrollTo
Created February 5, 2012 19:15
jQuery Scrolling Function
function scrollTo(id) {
$('html,body').animate({scrollTop: $("#" + id).offset().top}, 'slow');
}
(require '[clj-btable.core :as btable])
(def labels ["Login" "View_Cat_Food" "Purchase_Cat_Food"])
(def rows [[5.0 3.0 1.0] [2.0 0.0 0.0] [0.0 0.0 0.0]])
(btable/write "out.btable" labels rows)
; => #<File out.btable>
(btable/labels "out.btable")
; => ["Login" "View_Cat_Food" "Purchase_Cat_Food"]
@andrewberls
andrewberls / Gemfile
Created July 15, 2012 21:56
Rakefile for building and minifying a CoffeeScript project
source 'http://rubygems.org'
gem "rake", "~> 0.9.2.2"
gem "uglifier", "~> 1.2.6"
gem "listen", "~> 0.4.7"
@andrewberls
andrewberls / ex.coffee
Created July 30, 2012 20:16
Nested functions
@fadeWith = (sound, duration) ->
return @ if !supported
@fadeOut duration, ->
@stop()
sound.play().fadeIn(duration)
return @
@andrewberls
andrewberls / list_remove.c
Created August 13, 2012 03:47
Remove linked list node
static int
list_remove(node* root, node* n) {
node* temp = (node*) malloc(sizeof(node));
temp = root;
node* garbage = (node*) malloc(sizeof(node));
int found = -1;
while (temp) {
if (temp->next->val == n->val) {
garbage = temp->next;