Skip to content

Instantly share code, notes, and snippets.

@michaek
michaek / .bash_aliases
Last active December 3, 2015 07:05
Bash Aliases
# here
alias vba='vim ~/.bash_aliases'
alias mba='mate ~/.bash_aliases'
alias sba='subl ~/.bash_aliases'
alias ba='source ~/.bash_aliases'
# profile
alias sbp='subl ~/.bash_profile'
alias bp='source ~/.bash_profile'
# bundle
alias bu='bundle'
@michaek
michaek / .bash_profile
Last active October 6, 2015 22:08
Bash prompt for git
source ~/.bashrc
source ~/.bash_aliases
source /usr/local/opt/chruby/share/chruby/auto.sh
source /usr/local/opt/chruby/share/chruby/chruby.sh
chruby 2
source /usr/local/Cellar/git/2.0.1/etc/bash_completion.d/git-completion.bash
source /usr/local/Cellar/git/2.0.1/etc/bash_completion.d/git-prompt.sh
// Takes a string and performs the count operation:
function counts(s) {
var reg = /([\u00BF-\u1FFF\u2C00-\uD7FF\w\d][^,]+),\s*(\d+)/;
// Reduce over each line in the string, modifying an accumulator object at every iteration
return s.split("\n").reduce(function (a, c) {
if (c = reg.exec(c)) { // The regex matches, so it's of the form NAME,NUM, at least in part
// c[0] = full regex string
// c[1] = the first match (the name)
@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@raine
raine / heroku-logs-with-bunyan.md
Last active August 3, 2018 19:14
Read heroku log output with bunyan

Read heroku logs output w/ bunyan

The stuff before the JSON in heroku logs output has to be cut off for bunyan to work.

$ heroku logs | sed -l 's/.*app\[web\..*\]\: //' | bunyan

Flag -l makes the output buffered by line.

@barneycarroll
barneycarroll / m.plugin.js
Last active August 4, 2022 11:08
A factory for Mithril DOM plugins to distinguish between initialisation, subsequent draw and teardown without the config API's semantic reliance on real DOM element lifecycle
// Config plugins with reliable setup & teardown in Mithril without relying on unique real DOM element lifecycle.
// This is meant to stand in for `config` in a way that's more suited to an application that continuously diffs the DOM.
import m from 'mithril'
// A plugin consists of 1 or more of the following methods:
// * init runs once when the plugin first executes
// * draw runs on every draw loop
// * exit runs at the beginning of the config cycle when the plugin instance has disappeared from view
//
// Each method is passed the element, the element context / state object, and the virtual DOM element.