Skip to content

Instantly share code, notes, and snippets.

View tomquas's full-sized avatar

tom quas tomquas

  • patugo GmbH
  • munich, germany
View GitHub Profile
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('.'))
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
/**
* A simple lease-based cache in javascript used for node.js
*
* This cache allows to insert key-value pairs that will be automatically removed after a distinct lease time.
* A cache object has a capacity. If the capacity limit is hit, it will automatically remove the oldest entries.
* Entries can't be removed from the cache. However, they can be overwritten.
*
* Note that this is not exactly the same than a LRU cache, although it works similar. It has been used for caching
* authentication data. Only after lookups fail, the data will be caught from the database. The additional time-out
* prevents the usage of too old entries and allows some efficient caching between distributed nodes sharing
@katylava
katylava / git-selective-merge.md
Last active February 27, 2024 10:18
git selective merge

Update 2022: git checkout -p <other-branch> is basically a shortcut for all this.

FYI This was written in 2010, though I guess people still find it useful at least as of 2021. I haven't had to do it ever again, so if it goes out of date I probably won't know.

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

@georgkreimer
georgkreimer / hash_intersection.rb
Created November 19, 2010 14:07
Hash intersection in Ruby
first = {"a" => 4, "b" => 1, "c" => 3, "g" => 201, "h" => 501}
second = {"d" => 19, "e" => 18, "c" => 17, "g" => 201, "h" => 501}
keys_intersection = first.keys & second.keys
merged = first.dup.update(second)
intersection = {}
keys_intersection.each do |k|
intersection[k]=merged[k] unless first[k] != second[k]
end
@unixmonkey
unixmonkey / Cucumber Plain Text Feature.tmLanguage
Created March 10, 2011 20:15
Cucumber Language definition file for TextMate; modified to work with Sublime Text 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>feature</string>
</array>
<key>firstLineMatch</key>
<string>기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd(.*)</string>
#!/usr/bin/env ruby
#
# Originally written by http://redartisan.com/tags/csv
# Added and minor changes by Gavin Laking
# Rewritten by Andrew Bennett for Ruby 1.9
#
# Usage: ruby csv_to_fixture.rb file.csv [--json]
#
# "id","name","mime_type","extensions","icon_url"
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif"
require 'benchmark'
class Simple
attr_accessor :next
end
def current_mem
`ps -o "%mem rss" -p #{$$}`.split("\n").last.split(/\s+/)[1..-1]
end
@simonmichael
simonmichael / gist:1070020
Created July 7, 2011 17:15
sample invoice layout in pandoc markdown
# INVOICE 20110706xx
------------------------------------- ---------------------------------
**To:**<br> **From:**<br>
Client XX<br> me<br>
address<br> address<br>
<br> <br>
<br> Email: ...<br>
<br> Phone: ...<br>
@tehmaze
tehmaze / vmdump.sh
Created July 31, 2011 16:37
tcpdump for VMWare Fusion
#!/bin/bash
if echo ${1} | grep -q '^vmnet[0-9]$'; then
ERRCOUNT='0'
PIDSNIFF='0'
PIDTDUMP='0'
CAPINTF="${1}"
CAPFILE="$(mktemp -t capture)"