Skip to content

Instantly share code, notes, and snippets.

@rorcraft
rorcraft / gist:4156de0301a326d7d497
Last active January 18, 2016 22:42
Lodash notes.

Lodash

  1. _() vs _.chain()
> _([1,2,3,4,5]).map(function (x) { return x * x }).first(3).value()
[ 1, 4, 9 ] // the same if first(3)
> _.chain([1,2,3,4,5]).map(function (x) { return x * x }).first(3).value()
[ 1, 4, 9 ] // the same if first(3)
> _.chain([1,2,3,4,5]).map(function (x) { return x * x }).first()
@rorcraft
rorcraft / .slate
Created June 26, 2014 18:19
Slate config
# This is the default .slate file.
# If no ~/.slate file exists this is the file that will be used.
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Resize Bindings
bind right:alt;ctrl resize +10% +0
bind left:alt;ctrl resize -10% +0
@rorcraft
rorcraft / gist:11407295
Created April 29, 2014 17:48
node module structure
// 1. bind every function
function foo(locale) {
return locale + '-foo';
}
module.exports = function helper(locale) {
return {
foo: foo.bind(null, locale)
}
@rorcraft
rorcraft / gulp-cwebp.js
Last active August 29, 2015 13:57
gulp plugin for cwebp, doesn't require imagemagick.
var through = require('through2')
, gutil = require('gulp-util')
function cwebp() {
var Webp = require('cwebp')
, File = require('vinyl')
return through.obj(function (file, enc, cb) {
this.push(file)
if (file.isBuffer()) {
brew update
brew tap homebrew/dupes
brew install apple-gcc42
export CC=gcc-4.2
curl https://gist.github.com/rorcraft/8815129/raw/f184726d7dd8d306d6f63acd97c39bb8ea6dbb84/jamesgolick-ruby > ~/.rbenv/plugins/ruby-build/share/jamesgolick
rbenv install jamesgolick
var assert = require('assert');
var helpers = {
view: function() {
return "viewing: " + this.msg;
}
}
// jade
// "h1= view()"
// compiled jade
@rorcraft
rorcraft / gist:8117308
Created December 24, 2013 20:02
Christmas tree
package main
import "fmt"
import "math/rand"
import "time"
func tree(width int, level int) {
rand.Seed(time.Now().UnixNano())
full_width := width + (2 * level)
tree_level(1, width, full_width)
@rorcraft
rorcraft / gist:7967310
Created December 15, 2013 01:03
Ruby Quine
lambda { |x| puts "#{x}.call(%q(#{x}))" }.call(%q(lambda { |x| puts "#{x}.call(%q(#{x}))" }))
module ActionController
module Railties
module Paths
def self.with(app)
Module.new do
define_method(:inherited) do |klass|
super(klass)
if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_helpers_paths) }
paths = namespace.railtie_helpers_paths
@rorcraft
rorcraft / gist:6598302
Last active December 23, 2015 07:08
dalli race_condition_ttl