Skip to content

Instantly share code, notes, and snippets.

View davidbalbert's full-sized avatar

David Albert davidbalbert

View GitHub Profile
require 'singleton'
class NothingClass
include Singleton
def bind
self
end
def map
@davidbalbert
davidbalbert / created_at.rb
Last active December 31, 2015 20:49
A bad idea
module CreatedAt
module ClassMixin
def new(*)
obj = super
obj.instance_variable_set(:@_created_at, Time.now)
obj
end
end
@davidbalbert
davidbalbert / cps-map.js
Created December 11, 2013 21:43
Three implementations of `map` in continuation passing style.
(function () {
"use strict";
var first = function (arr, c) {
c(arr[0]);
};
var rest = function (arr, c) {
c(arr.slice(1));
};
@davidbalbert
davidbalbert / Gemfile
Created November 1, 2013 20:21
A silly little URL shortener.
source "https://rubygems.org"
gem "sinatra"
@davidbalbert
davidbalbert / gist:6815258
Last active June 3, 2026 02:25
How to install custom SSL certificates on an ASUS RT-N66U running asuswrt-merlin
###########################################
# IMPORTANT NOTE:
#
# As of asuswrt-merlin 380.67 Beta, you
# can now configure SSL certificates from
# the Webui, making these instructions
# unnecessary.
###########################################
@davidbalbert
davidbalbert / actual results (Homebrew go)
Last active December 24, 2015 02:39
Homebrew `go tool` and `go doc` bug
$ brew install go
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/go-1.1.2.mountain_lion.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.1.2.mountain_lion.bottle.tar.gz
==> Pouring go-1.1.2.mountain_lion.bottle.tar.gz
==> Caveats
<snip>
==> Summary
/usr/local/Cellar/go/1.1.2: 3918 files, 110M
$ echo $GOROOT
/usr/local/Cellar/go/1.1.2
@davidbalbert
davidbalbert / conditional_hash.rb
Last active December 21, 2015 02:38
Syntax idea: conditionals in hash literals
# If the conditionals evaluate to false, the key wouldn't be present in the hash
Person.new(
first_name: params[:first_name],
last_name: params[:last_name],
age: params[:age] if params[:age].to_i > 18,
bio: params[:bio] unless params[:bio].blank?)
# This would be equivalent to
@davidbalbert
davidbalbert / pyqwt.sh
Last active June 22, 2019 19:59
PyQwt in a virtualenv
brew install qt # should already be done
brew install qwt # should already be done
brew install portaudio # should already be done
brew install wget # makes some downloading easier
# set up your virtualenv (`workon friture` if you've already created it)
mkvirtualenv friture
cd /tmp
@davidbalbert
davidbalbert / put_this_in_your_repl.rb
Last active December 17, 2015 20:19
Ruby should have more multimedia!
>> load 'string_sayer.rb'
>> "Hello, world!"
=> "Hello, world!"
@davidbalbert
davidbalbert / COPYING
Last active December 10, 2015 02:08
A little Lisp
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for