Skip to content

Instantly share code, notes, and snippets.

@heymatthew
heymatthew / so-many-promises.js
Created August 20, 2012 21:07
Chaining Promises with JQuery in Javascript
// Prereq: underscore.js and jquery loaded
var p1 = $.Deferred();
var p2 = $.Deferred();
// We want something that chains promises, so something like...
//p1.done(
// function addNext() {
// p2.done(
// function addNext() {
@heymatthew
heymatthew / gist:5282912
Created April 1, 2013 02:26
Testing then statement in the Q framework to assert then() return's a wrapped promise callback. "Give me a callback for this promise and I'll give you a promise that represents the result of that callback."
(function() {
q = require('q');
var one,two,three;
function asyncOne() {
console.log('one called');
var allDone = q.defer();
setTimeout(allDone.resolve, 1000);
return allDone.promise;
}
[alias]
co = checkout
br = branch
sb = show-branch --current --color
ci = commit -v
hist = log --pretty=format:\"%C(cyan)%h%Creset %Cgreen%ad%Creset | %C(yellow)%s%d%Creset [%C(white)%an%Creset]\" --graph --date=short
who = shortlog -s --
dump = cat-file -p
ri = rebase --interactive
smf = submodule foreach git fetch --all
@heymatthew
heymatthew / gist:5700996
Created June 3, 2013 20:13
A working samba config.
#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example
#
# Some options that are often worth tuning have been included as
To get Git to diff between your odt/odp/ods files you will need to do the following things:
Install a conversion tool
$ sudo yum install odt2txt
Create your git config info directory if it's not already there
$ mkdir -p ~/.config/git/info
Add in attributes (you can paste this straight in or edit the file accordingly)
$ cat > ~/.config/git/info/attributes <<DELIM
@heymatthew
heymatthew / .vimrc
Last active December 27, 2015 01:19
vimrc
" .vimrc configuration file
" Copyright (C) 2013 Matthew B. Gray
"
" Permission is granted to copy, distribute and/or modify this document
" under the terms of the GNU Free Documentation License, Version 1.3
" or any later version published by the Free Software Foundation;
" with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
" A copy of the license is included in the section entitled "GNU
" Free Documentation License".
@heymatthew
heymatthew / gist:2590df4124b4d474d37a
Created May 20, 2014 00:04
Help?! Compressed spooler :(
[ root@283615a69847:/data ]$ cat /data/logstash.conf
input {
stdin {}
}
output {
stdout {
codec => compress_spooler {
compress_level => 6
spool_size => 50
@heymatthew
heymatthew / proxy.js
Created June 19, 2014 22:46
Simple Reusable Proxy with Partial Application
var express = require('express');
var extend = require('extend');
var q = require('q');
var request = q.denodeify( require('request') );
var makeRequester = function makeRequester(opts) {
return function requester(path) {
var retrieveResponse =
request({
'strictSSL': opts.selfsigned !== true, // for snakeoil certs

Launch a one-off git server from any local repository.

I [tweeted this already][1] but I thought it could use some expansion:

Enable decentralized git workflow: git config alias.serve "daemon --verbose --export-all --base-path=.git --reuseaddr --strict-paths .git/"

Say you use a git workflow that involves working with a core "official" repository that you pull and push your changes from and into. I'm sure many companies do this, as do many users of git hosting services like Github.

Say that server, or Github, goes down for a bit.

@heymatthew
heymatthew / latest_ruby.rb
Created November 20, 2016 18:44
Quickly find if you're running the latest rbenv
#!/usr/bin/env ruby
def get_lines(output)
output.lines.map(&:chomp).map(&:strip)
end
available = get_lines(`rbenv install -l`).select { |v| v.match(/^[\d\.]+$/) }
installed = get_lines(`rbenv versions`)
puts