Skip to content

Instantly share code, notes, and snippets.

@bigs
bigs / curry.js
Last active December 13, 2015 17:38
A cute currying function written in pure JavaScript for FUNZIES.
var curry = function (f, args, binding) {
if (typeof f !== 'function' ||
toString.call(args) !== '[object Array]') {
throw new Error('Invalid parameters');
return;
}
if (typeof binding !== 'object') {
binding = this;
}
@bigs
bigs / paperclip-rackspace.rb
Last active October 10, 2017 17:55
Uploading files to Rackspace in a Rails app using Paperclip + Fog
# config/initializers/paperclip.rb
#######################################
RACKSPACE_CONFIG = {
'production' => {
path: '',
storage: :fog,
fog_credentials: {
provider: 'Rackspace',
rackspace_username: ENV['RACKSPACE_USERNAME'],
$data['trackList'] = array(
(object) array(
'track_num' => 1,
'track_title' => 'You\'re No Good (feat. Santigold, Vybz Kartel, Danielle Haim & Yasmin)',
'track_time' => '4:32'
),
(object) array(
'track_num' => 2,
'track_title' => 'You\'re No Good (feat. Santigold, Vybz Kartel, Danielle Haim & Yasmin)',
'track_time' => '5:35'
@bigs
bigs / one_of_us.rb
Last active December 18, 2015 04:19
form conformity. wouldn't it be cool if forms just fit in?
# even with form helpers, creating forms is a pain in the butt
# for web developers every where. so... tedious...
#
# what if there was a better way?
#
# what if forms could... FIT... IN?
#
# what if forms conformed to the rest of your elegant rails workflow?
# that would be pretty nice is what i am thinking.
#
@bigs
bigs / defer.js
Last active December 22, 2017 09:46
a very quickly hacked implementation of go's defer in javascript
var deferWrap = function (f) {
return function () {
var cbs = [];
var d = function (cb) {
cbs.push(cb);
};
var args = Array.prototype.slice.call(arguments);
args.push(d);
f.apply(this, args);
@bigs
bigs / angular-debounce.js
Last active December 24, 2015 22:59
a debounce directive for angular.js
/*
Usage
----------------
HTML
<input type="text"
ng-model="fooVal"
ng-debounce="foo()"
ng-debounce-millis="500">
@bigs
bigs / lenses.md
Last active November 24, 2019 00:55
Musings on Lenses

Cole Brown

SPJ recently gave a fantastic talk on Edward Kmett's wildly useful lens library. Simon,a brilliant programmer and one of Haskell's designers, had little to no experience with lens prior to this talk and, resultingly, is able to offer a shockingly fresh perspective.

In his talk, he walks the audience through his deconstruction of the library — an illuminating journey. There is a lot of insight exposed, but there was one (perhaps unspoken) sentiment that struck me:

Functional programmers tend to prefer simple, versatile data structures like lists and trees. The reasoning is often times simple: simple data types yield powerful abstractions. One can implement a mind-boggling number of algorithms using maps and folds over lists (and associative lists).

While Haskell caters to this simplified model of programming, Haskell's type system and record syntax also encourage the use of abstract data ty

@bigs
bigs / lambda.js
Last active August 29, 2015 13:56
lambda functions in javascript
var lambda = function (str) {
var res = str.match(/^\s*([a-z]+(?:\s+[a-z]+)*)\s*\->\s*(.+?)\s*$/);
if (!res) {
throw new Error('Invalid lambda expression');
}
var args = res[1].replace(/\s{2,}/g, ' ').split(' ')
, body = 'return ' + res[2] + ';';
@bigs
bigs / replace_sel_in_file.el
Last active August 29, 2015 14:05
replace instances of the word at the cursor (or current selection) with a new word
(defun cole-foo-balls (beg end r)
(interactive "r\nsReplace sel. with: ")
(let ((s (if (use-region-p)
(buffer-substring-no-properties beg end)
(word-at-point))))
(progn
(goto-char 0)
(replace-regexp s r))))
#ifndef BOLT_SUBPROCESS_HARNESS_HPP
#define BOLT_SUBPROCESS_HARNESS_HPP
#include <gtest/gtest.h>
#include <glog/logging.h>
#include <folly/Subprocess.h>
#include <folly/String.h>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>