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
>>> x = '0123456789' | |
>>> a, b = [{} for _ in x], [{}] * len(x) | |
>>> a[0]['test'], b[0]['test'] = 1, 1 | |
>>> p(a) | |
[{'test': 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}] | |
>>> p(b) |
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
# Discard local changes | |
git checkout -f (git co -f) | |
# This will change the current parent revision if you're not at a branch tip. | |
# The fact that it discards local changes is just a side effect. | |
hg update --clean (hg co -C) | |
# What you really want is the command *designed* to throw away changes: revert. | |
hg revert --all [--no-backup] (hg rev -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
#!/usr/bin/env bash | |
# cd to the root of the current Mercurial repo | |
# | |
# usage: | |
# Add the following function to your `.bashrc` or `.bash_profile` file, | |
# or save it somewhere (i.e. `~/.cdg.sh`) and source it in `.bashrc` | |
cdh () { | |
hg root >/dev/null && cd "`hg root`" |
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
#!/bin/bash | |
# Plant rope vim's plugin | |
# This is a script to install or update 'ropevim' | |
# Copyright Alexander Artemenko, 2008 | |
# Contact me at svetlyak.40wt at gmail com | |
function create_dirs | |
{ | |
mkdir -p src |
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
" folding for Markdown headers, both styles (atx- and setex-) | |
" http://daringfireball.net/projects/markdown/syntax#header | |
" | |
" this code can be placed in file | |
" $HOME/.vim/after/ftplugin/markdown.vim | |
func! Foldexpr_markdown(lnum) | |
let l1 = getline(a:lnum) | |
if l1 =~ '^\s*$' |
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
(ns jquerytest.core) | |
(def jquery (js* "$")) | |
; Can you not use the short form? | |
(jquery | |
(fn [] | |
(-> (jquery "div.meat") | |
(.html "This is a test.") | |
(.append "<div>Look here!</div>")))) |
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
" Motion for "next/last object". For example, "din(" would go to the next "()" pair | |
" and delete its contents. | |
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr> | |
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr> | |
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr> | |
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr> | |
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr> | |
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr> |
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
unisubs.streamer.StreamBox.prototype.transcriptScrolled_ = function(e) { | |
if (this.videoScrolling_) { | |
this.videoScrolling_ = false; | |
} else { | |
this.showResyncButton_(true); | |
this.ignoreVideoScrolling_ = true; | |
} | |
}; | |
unisubs.streamer.StreamBox.prototype.scrollIntoView_ = function(streamSub) { |
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
(defn ^:export prependChild | |
[parent node] | |
(dom/insertChildAt parent node 0)) |
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
var http = require('http') | |
var fork = require('child_process').fork; | |
function fib(n) { | |
if (n < 2) { | |
return 1; | |
} else { | |
return fib(n - 2) + fib(n - 1); | |
} | |
} |
OlderNewer