Skip to content

Instantly share code, notes, and snippets.

bundle.register('.html', function (body, path) {
return 'module.exports = Handlebars.template(' + handlebars.precompile(
fs.readFileSync(path, 'utf8')
) + ');';
});
var set = [[0, 0], [1, 1], [2, 3], [3, 4.3], [4, 4.2], [5, 4.6], [6, 4.1], [6, 1.6], [8, 0.5], [9, 0]];
var mean = (function (v) {
return v[0] / v[1];
}(set.reduce(function (a, b) {
return [a[0] + b[0] * b[1], a[1] + b[1]];
})));
var stdv = (function (v) {
return Math.sqrt(v[0] / v[1]);
[color]
ui = true
[branch]
autosetuprebase = always
[alias]
k = log --graph --pretty=format:'%Cred%h%Creset %C(blue)%cN%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
[merge]
ff = false
[push]
default = tracking
@munro
munro / 0_ERROR
Last active December 25, 2015 21:58
$ cat orig_syslog_events | head -n 1 | java -jar logstash-1.2.1-flatjar.jar agent --pluginpath . -f logstash.rb
Exception in thread "LogStash::Runner" org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- pg
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at Kernel.require(jar:file:/Users/rmunro/Desktop/logstash-1.2.1-flatjar.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)
at Kernel.require(file:/Users/rmunro/Desktop/logstash-1.2.1-flatjar.jar!/logstash/JRUBY-6970.rb:22)
at Kernel.require(file:/Users/rmunro/Desktop/logstash-1.2.1-flatjar.jar!/polyglot.rb:63)
at RUBY.register(/Users/rmunro/Desktop/logstash/outputs/postgresql.rb:41)
at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1617)
at RUBY.outputworker(file:/Users/rmunro/Desktop/logstash-1.2.1-flatjar.jar!/logstash/pipeline.rb:208)
at RUBY.start_outputs(file:/Users/rmunro/Desktop/logstash-1.2.1-flatjar.jar!/logstash/pipeline.rb:140)
@munro
munro / field_compare.js
Created October 23, 2013 19:36
Foundation abide compare field, for confirm password, verify password
var parse_patterns = Foundation.libs.abide.parse_patterns;
Foundation.libs.abide.parse_patterns = function (els) {
var form = $(els[0]).closest('form'),
errors = parse_patterns.apply(this, arguments);
form.find('[field-match]').each(function () {
var $field = $(this),
$compare = form.find('[name="' + form.find('[field-match]').attr('field-match') + '"]');
if ($field.val() === $compare.val()) {
$field.removeAttr('data-invalid').parent().removeClass('error');
@munro
munro / setup.md
Last active December 26, 2015 20:09
Mac Configuration

here's my mac setup, it's pretty simple but works extremely well!

  • brew (apt-get for mac)
  • iTerm 2 (better terminal)
  • Alfred (goto anything, so you can open/switch windows with just your keyboard)
  • KeyRemap4Macbook (swap the fn & ctrl keys… drives me crazy)
  • create 6 workspaces, and update keyboard shortcuts so you can switch windows, also turn off
  • turn capslock into alt key, and use that as your primary modifier
  • remove every default shortcut, keep only the 5 that you use
import GHC.Unicode
strToTitle str = [if isSpace (fst ch) then toTitle (snd ch) else snd ch | ch <- (zip (" " ++ str) str)]
data Box = Box { box_x1 :: Integer, box_y1 :: Integer, box_x2 :: Integer, box_y2 :: Integer } deriving Show
subdivideNW Box { box_x1 = x1', box_y1 = y1', box_x2 = x2', box_y2 = y2'} = Box {
box_x1 = x1',
box_y1 = y1',
box_x2 = x1' + half_width,
box_y2 = y1' + half_height
}
where
half_width = (x2' - x1') `div` 2
@munro
munro / empty
Last active August 29, 2015 13:58
SublimeGraphvizPreview
zz