This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" adapted from https://github.com/aaronjensen/vimfiles/blob/2a88ef0b92f5a628e898189e612eb0feb34b1419/vimrc#L449-483 | |
" save as ~/.vim/plugin/bracketed_paste.vim to use | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Tmux wrapping borrowed from vitality.vim: https://github.com/sjl/vitality.vim | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function WrapForTmux(s) | |
if !exists('$TMUX') | |
return a:s | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- on Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production | |
CREATE TABLE left(lid INTEGER, pid INTEGER); | |
INSERT INTO left VALUES (1,1); | |
INSERT INTO left VALUES (2,2); | |
INSERT INTO left VALUES (3,3); | |
INSERT INTO left VALUES (4,4); | |
INSERT INTO left VALUES (5,5); | |
CREATE TABLE right(rid INTEGER, pid INTEGER); | |
INSERT INTO right VALUES (1,1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# solver for http://numb3rs.wolfram.com/516/puzzle.html | |
# a node in the graph | |
Node = Struct.new(:label, :color, :edges) | |
class Node | |
# hash equalit for nodes is only dependent on label (which is unique) | |
def hash | |
label.hash | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zsh function to recursively ascend the path tree until we hit root or find a makefile, then make | |
function makeup() | |
{ | |
if ([[ $PWD == "/" ]] || [[ -f Makefile ]] || [[ -f makefile ]] ) ; then | |
make $* | |
else | |
(pushd .. >/dev/null ; makeup $*) | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:%s/.*/\=tr(submatch(0),'abcdefghijklmnopqrstuvwxyz','nopqrstuvwxyzabcdefghijklm') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Refactor the given lines using a dictionary | |
" replacing all occurences of each key in the dictionary with its value | |
function! Refactor(dict) range | |
execute a:firstline . ',' . a:lastline . 's/\C\<\%(' . join(keys(a:dict),'\|'). '\)\>/\='.string(a:dict).'[submatch(0)]/ge' | |
endfunction | |
command! -range -nargs=1 Refactor :<line1>,<line2>call Refactor(<args>) | |
" Example of use | |
" :%Refactor {'duck':'frog', 'frog':'rabbit', 'rabbit':'duck', 'I':'Noah'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ~/.vim/plugin/nextunused.vim | |
" find the next unused filename that matches the given pattern | |
" counting up from 0. The pattern is used by printf(), | |
" so use 'temp%d.txt' for 'temp0.txt' to 'temp99999.txt' and | |
" 'temp%04d.txt' for 'temp0000.txt' to 'temp9999.txt'. | |
function! GetNextUnused( pattern ) | |
let i = 0 | |
while filereadable(printf(a:pattern,i)) | |
let i += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name clearonclick | |
// @namespace http://rampion.myopenid.com | |
// @description clear onclick behaviour from html links | |
// @include http://andrewsullivan.theatlantic.com/the_daily_dish/* | |
// ==/UserScript== | |
try { | |
GM_log("called"); | |
const links = document.getElementsByTagName('a'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+--------------------------------+--------------------------------------------------------------------+ | |
| name | address | | |
+--------------------------------+--------------------------------------------------------------------+ | |
| Evagation Governessy | 803 Asbestous St, Uneradicated Stannous MP 37441 | | |
| Civilizee Fangle | 997 Cerebrotonic Hwy, Ulex Lynceus ZQ 07893 | | |
| Terebenic Parandrus | 687 Veneralia Way, Frivoler Myospasm NC 14839 | | |
| Loaminess Pezizaceous | 859 Dustcloth Way, Drivepipe Miolithic XV 26760 | | |
| Dominican Ozostomia | 73 Dichasial Way, Moniker Utilizable RS 84766 | | |
| Autobiology Impishly | 602 Dynamize Way, Lernaeidae Macrochemical CB 42656 | | |
| Exopodite Unendamaged | 139 Osteolysis Hwy, Synergist Leally TO 05002 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WeightedSelection | |
# input is an Enumerable of (item,frequency) pairs | |
# | |
# (takes O(n) time) | |
def initialize(input) | |
# set up the alias method for selection | |
# http://prxq.wordpress.com/2006/04/17/the-alias-method/ | |
@n = input.size | |
@m = input.inject(0) { |sum,(item,freq)| sum + freq } |