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
>>> import redbaron; redbaron.RedBaron(open(filename).read()).help() |
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
function parseQuery(qstr) { | |
var query = {}; | |
var a = (qstr[0] === '?' ? qstr.substr(1) : qstr).split('&'); | |
for (var i = 0; i < a.length; i++) { | |
var b = a[i].split('='); | |
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || ''); | |
} | |
return query; | |
} |
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
cat file |sort -k3nr | |
# -n -- sort numerically (not lexicographically) | |
# -k3 -- sort by the 3rd column | |
# -r -- sort in reverse order (bigger values first) | |
This is different to |sort -nk3r for some reason |
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
import argparse | |
def main(argv): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--no-build', dest="build", default=True, action="store_false") | |
return parser.parse_args(argv) | |
>>> main([]).build | |
True | |
>>> main(['--no-build'].build |
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
# Find commit that deleted a line, given some content in the line | |
$ git log -S<content> | |
# Show file at a particular revision | |
$ git show <revision>:<file_path> | |
# Abort a merge | |
$ git merge --abort | |
# Get commits in one branch that aren't in another branch |
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
# Http: | |
telnet localhost 80 | |
GET / HTTP/1.1 | |
HOST: gist.github.com | |
# Https: | |
openssl s_client -connect localhost 443 |
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
# http://stackoverflow.com/a/15936384/223486 | |
{command} 2> >({command} 1>&2) | |
eg. nvim-qt 2> >(grep -v "Unknown Neovim function" 1>&2) |
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
# https://ipython.org/ipython-doc/3/config/extensions/autoreload.html | |
>>> %load_ext autoreload | |
>>> %autoreload 2 | |
>>> from foo import some_function | |
>>> some_function() | |
>>> from foo import some_function | |
>>> some_function() |
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
# Current versions of Selenium are so silly that if an action on the page | |
# results in a new tab being opened, the browser will switch to the new tab, | |
# but the selenium driver will still think the old tab is visible, so if you | |
# try to access elements on the old tab, they will fail with 'element not visible' | |
# errors. | |
# One way to fix this is to explicitly switch to the new tab and close it | |
# (if you have an element that will close the tab). | |
driver.switch_to.window(driver.window_handles[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
# Inspiration from https://gist.github.com/nova77/5403446 | |
# Docs from http://ipython.readthedocs.io/en/stable/config/custommagics.html | |
from IPython.core.magic import Magics, magics_class, line_magic | |
from subprocess import Popen, PIPE | |
import json | |
@magics_class | |
class ClipJsonMagic(Magics): | |
@line_magic |
NewerOlder