Skip to content

Instantly share code, notes, and snippets.

@dtjm
dtjm / join_test.go
Last active November 26, 2023 13:18
Benchmarking various ways of concatenating strings in Go
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
@spoike
spoike / reactjs_componentapi_cheatsheet.md
Created May 13, 2014 07:51
React JS Cheatsheets for Component API, Specifications and Lifecycle

ReactJS Component Cheatsheet

To create a ReactComponent:

ReactComponent React.createClass(object proto)

Basic JSX example:

var TitleComponent = React.createClass({

// REQUIRED

@nabucosound
nabucosound / heroku_env_copy.sh
Created December 30, 2013 12:40
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
(ns react-cljs.core
(:require React))
(declare render)
(defn handle-change [e]
(render {:text (.. e -target -value)}))
(defn render [{:keys [text]}]
(React/renderComponent
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
; Comments start with semicolons.
; Clojure is written in "forms", which are just
; lists of things inside parentheses, separated by whitespace.
;
; The clojure reader assumes that the first thing is a
; function or macro to call, and the rest are arguments.
;
; Here's a function that sets the current namespace:
(ns test)
@hardbap
hardbap / ninja.rb
Created August 8, 2012 15:24
cool block passing from girl_friday
class Ninja
def initialize(name, &block)
@name = name
@move = block
end
def attack
@move.call
end
end
@rmurphey
rmurphey / gist:3185390
Created July 27, 2012 00:27
shiftOut in javascript
var five = require("johnny-five"),
board;
board = new five.Board();
board.on("ready", function() {
(new five.Led(13)).on();
var dataPin = 2;
var clockPin = 3;
@avdi
avdi / apology101.markdown
Created March 22, 2012 17:36
How to apologize

Chances are your head's spinning right now. That accusation of bias caught you off guard, you got kind of defensive, and now all hell has broken loose. You're feeling attacked on all sides. You're a good person at heart, and having all these people treat you like the antichrist is pretty upsetting.

You need to say something, but you're probably not in the best headspace to write copy right now. So to help you along, here's my 100% guaranteed-or-you-money-back scandal defusement apology template:

You may be asking yourself "why didn't this idiot just use Sphinx, Xapian or Hyper Estraier?". The decision to use MySQL Full-Text Search was based on the fact that this is a smallish project with minimal full-text searching needs. I felt that the requirements didn't warrant downloading/compiling/installing software, monitoring daemons/processes, rebuilding indices, and all the other crap that comes with the big boys of full-text indexing. Don't get me wrong I love Sphinx and Xapian, having used both on several projects, but I wanted something with a little less ceremony. Plus I'm always up for learning something new.

migration

The first thing you need to do is convert the storage engine from the Rails default **In