Skip to content

Instantly share code, notes, and snippets.

inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
@mikeal
mikeal / gist:293922
Created February 3, 2010 19:23
walk(pathname,callback) for node.js
var http = require('http'),
sys = require('sys'),
path = require('path'),
posix = require('posix'),
events = require('events');
var listdir = function (pathname) {
var p = new events.Promise();
var ls = process.createChildProcess("ls", [pathname]);
ls.addListener("output", function (data) {
@paulirish
paulirish / gist:366184
Created April 14, 2010 18:59
html5 geolocation with fallback.
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
// doublecheck the ClientLocation results because it may returning null results
;(function(geolocation){
if (geolocation) return;
@tanepiper
tanepiper / twitter_oauth_getter.js
Created September 11, 2010 16:14
A small command line nodejs script for doing Twitter OAuth.
#!/usr/bin/env node
var argv = require('optimist')
.usage('Usage: --key=[consumer key] -secret=[consumer secret]')
.demand(['key', 'secret'])
.argv
;
var OAuth = require('oauth').OAuth;
var Step = require('step');
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
:model
form(user)
p
field(name)
p
field(email)
p
field(summary, as: 'textarea')
buttons
@thisismedium
thisismedium / load-YAML.js
Created September 30, 2010 18:22
Evaluate a YAML document in Node.JS using Python.
// Evaluate a YAML document.
//
// + text - String YAML document
// + next - Function callback
//
// For example:
//
// loadYAML("this: is\nyaml:", function(err, obj) {
// if (err) throw err;
// console.dir(obj);
@tpitale
tpitale / notification_center_example.rb
Created October 26, 2010 04:24
Quick NSDistributedNotificationCenter Example in MacRuby
framework 'Cocoa'
framework 'Foundation'
class NotificationHandler
def handle(notification)
puts notification.name
puts notification.object.inspect
puts notification.userInfo.inspect
end
end
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@fcalderan
fcalderan / inception-javascript.js
Created November 2, 2010 09:42
inception explained as a 4 nested javascript closures
/*
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02
* I had an idea: could Inception movie be explained by a few javascript closures
* and variable resolution scope (just for fun)?
*
* Activate javascript console =)
*/
<script>
console.group("inception movie");