Skip to content

Instantly share code, notes, and snippets.

View t-mart's full-sized avatar

Tim Martin t-mart

View GitHub Profile
@t-mart
t-mart / zsh.zsh
Created March 11, 2017 20:26
Function rename?
foo() {
echo "This is foo()"
}
bar=foo
bar
# --> zsh: command not found: bar
@t-mart
t-mart / netrw quick reference.md
Last active March 25, 2024 07:47
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
from itertools import combinations
UP = [[0,0,1,0,1,1,
1,1,1,1,0,1],
[1,0,1,0,1,0,
0,1,1,0,1,1]]
DOWN = [[0,1,1,0,0,1,
1,1,1,1,0,1],
[1,0,1,0,1,0,
0,1,0,0,0,1]]
@t-mart
t-mart / pull-submodules-to-origin-master.pre-commit-hook.sh
Last active October 15, 2015 04:27
A script to pull submodules to their origin/master. Meant to be used as a git hook.
#!/bin/sh
#
# To enable this hook, place this file at:
# <repo-base-dir>/.git/hooks/pre-commit
printf "Updating submodules to origin master..." >&2
git submodule update --rebase --remote
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "done" >&2
@t-mart
t-mart / rude.sh
Last active October 7, 2015 23:03
Say it with me: Random Uuids...R Uuid...Ruuid...rude!
#!/usr/bin/env python2
from base64 import b32encode
from uuid import uuid4
from sys import stdout
stdout.write(b32encode(uuid4().bytes)[:-6])
if stdout.isatty():
stdout.write('\n')
@t-mart
t-mart / fourget.sh
Created October 7, 2015 04:36
Download 4chan images to the current directory.
#!/usr/bin/env sh
# Download 4chan images to the current directory.
#
# example: fourget http://boards.4chan.org/int/thread/48964967
#
# requires httpie to be installed.
# The MIT License (MIT)
#
class MeteredSession(requests.Session):
"""
Creates a session where response downloads are shown graphically on the
terminal with `click.progressbar` meters. This session adds a hook to
responses that will attach 2 meter methods, described below.
To use these meter methods on a response obj `resp`, call
* `resp.iter_content_metered(chunk_size, label='\t' + resp.url)`
* `resp.consume_content_metered(chunk_size, label='\t' + resp.url)`
@t-mart
t-mart / -
Created February 5, 2015 07:26
from operator import mul
from functools import reduce
from itertools import permutations
def factorial(n):
return reduce(mul, range(1,n+1), 1)
def word_index(word):
index = 1
@t-mart
t-mart / xfce_terminalrc
Created January 17, 2015 11:01
terminal config for xfce's terminal (i.e. xubuntu) styled a la vim-hybrid (https://github.com/w0ng/vim-hybrid). put this in $HOME/.config/xfce4/terminal/terminalrc
[Configuration]
FontName=DejaVu Sans Mono 8
MiscAlwaysShowTabs=FALSE
MiscBell=FALSE
MiscBordersDefault=TRUE
MiscCursorBlinks=FALSE
MiscCursorShape=TERMINAL_CURSOR_SHAPE_BLOCK
MiscDefaultGeometry=80x24
MiscInheritGeometry=FALSE
MiscMenubarDefault=TRUE
From 49f5b2cb90dba546fc93e045311cf9f1d273050d Mon Sep 17 00:00:00 2001
From: Tim Martin <tim@timmart.in>
Date: Sat, 17 Jan 2015 02:15:01 -0500
Subject: [PATCH] fix coloring on urxvt
---
colors/hybrid.vim | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/colors/hybrid.vim b/colors/hybrid.vim