Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
_command_prefix=${@:2}
echo '<openbox_pipe_menu>'
for i in `$1`; do
echo "<item label=\"$i\">"
echo '<action name="Execute">'
echo "<command>$_command_prefix $i</command>"
echo '</action>'
echo '</item>'
@grncdr
grncdr / build_artifact.py
Created August 10, 2011 00:20
script to pack up a python project and all of it's dependencies in a tarfile using virtualenv
import subprocess
import shutil
import os
import sys
import tarfile
def get_version(project_root):
process = subprocess.Popen(
['git', 'describe'],
stdout=subprocess.PIPE,
@grncdr
grncdr / uriTemplateMiddleware.coffee
Created October 23, 2011 02:29
Generate a set of URI Templates from the routes in an express app
makeTemplate = (path) ->
i = 0
path.replace(/\*(\w)?/g, "{+raw#{i++}}$1")
.replace(/:(\w+)/g, '{$1}')
.replace(/List}/g, 's*}')
uriTemplateMiddleware = (path='/') ->
spec = null
(req, res, next) ->
if req.path == path
vows = require 'vows'
assert = require 'assert'
{mock, expect, lastCall, verify, pred, isDeep, any, verifyNoMore} = require './mtfw'
suite = vows.describe('mtfw core').addBatch "A mock will":
topic: -> mock()
"be an object": (m) -> assert.isObject m
"create new mocks when properties are accessed": ->
m1 = mock()
@grncdr
grncdr / find-the-block.js
Created January 17, 2012 03:55 — forked from isaacs/find-the-block.js
just changing names
// block-lambda proponents: what does this program do?
function in_canadian (speak_cb) {
add_eh = {|y|
return y + ", eh?"
}
// now here comes a bunch of code.
// imagine there are 50 lines here
@grncdr
grncdr / config-loader.js
Created May 30, 2012 18:56
simple re-loadable configuration using JS modules
inspect = require('util').inspect
module.exports = function (config_path, opts) {
var settings = {
toJSON: function() { return this.__proto__ },
inspect: function() { return inspect(this.__proto__) },
}
opts || (opts = {})
if (!opts.error) {
@grncdr
grncdr / index.js
Created September 23, 2012 21:36 — forked from anonymous/index.js
Observable object properties in javascript
/**
* A quick proof-of-concept of observable objects using JS accessors
*
* Base observable objects are created with * `new Observable(names)`, where
* `names` is an array of property names that should be observable.
*
* Instances are created by calling .create(initial_data) on the resulting
* base object, and observed with their .observe(handler) method. See the bottom
* of this file for an example.
*/
@grncdr
grncdr / gist:4554165
Last active December 11, 2015 05:48 — forked from jlongster/gist:3881008
hygienic destructuring var assignments with sweet.js
macro $do {
case ($($x = $y) (,) ...) $body => {
(function ($x (,) ...) $body)($y (,) ...)
}
case $name ($($x = $y) (,) ...) $body => {
(function $name ($x (,) ...) $body)($y (,) ...)
}
}
macro $var {
DROP DATABASE IF EXISTS stupid_simple_test;
CREATE DATABASE stupid_simple_test;
USE stupid_simple_test;
CREATE TABLE users (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) -- Should be properly encrypted in a real application!
@grncdr
grncdr / gist:4712845
Last active December 12, 2015 04:18
Log of vim crashing when loading YouCompleteMe
chdir(/usr/local/Cellar/macvim/7.3-66/MacVim.app/Contents/Resources/vim)
fchdir() to previous dir
sourcing "$VIM/vimrc"
finished sourcing $VIM/vimrc
chdir(/Users/stephen)
fchdir() to previous dir
sourcing "$HOME/.vimrc"
Searching for "ftoff.vim" in "/Users/stephen/.vim,/usr/local/Cellar/macvim/7.3-66/MacVim.app/Contents/Resources/vim/vimfiles,/usr/local/Cellar/macvim/7.3-66/MacVim.app/Contents/Resources/vim/runtime,/usr/local/Cellar/macvim/7.3-66/MacVim.app/Contents/Resources/vim/vimfiles/after,/Users/stephen/.vim/after"
Searching for "/Users/stephen/.vim/ftoff.vim"