Skip to content

Instantly share code, notes, and snippets.

@bokwoon95
bokwoon95 / comments.sql
Last active March 22, 2024 22:31
how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- The comment tree:
-- [1]
-- / \
-- [2] [4]
-- / \ \
-- [3] [7] [6]
-- /
-- [5]
@gaqzi
gaqzi / test_views.py
Last active March 12, 2021 08:29
SNS subscription and handler for django
import re
from django.core.urlresolvers import reverse
import responses
AWS_URL = re.compile('.*amazonaws.com.*')
class TestSNSSubscription(object):
@elle
elle / 2015-poodnyc-notes.md
Last active September 12, 2021 11:05
Notes from Poodnyc 2015 workshop

Rules for Horizontal Refactoring

  • If you go red, undo
  • Only change one line at a time
  1. Find two strings that are the most alike
  2. Find the smallest difference
  3. Make the smallest change that make the tests pass

How to make a small change

@gabehollombe
gabehollombe / .vimrc
Created November 19, 2013 12:56
Simple function to zoom Vimux's runner pane to fullscreen from Vim.
" If you use Vim, and tmux, you should be using Vimux: https://github.com/benmills/vimux
" This snippet will let you easily zoom Vimux's runner pane to fullscreen.
" It's really helpful for seeing more of a stack trace.
" Requires tmux >= 1.8
" Function to tell Vimux to have make tmux zoom its runner pane.
function! VimuxZoomRunner()
call VimuxInspectRunner()
call system("tmux resize-pane -Z")
endfunction
@gabehollombe
gabehollombe / gist:7365170
Created November 8, 2013 02:10
SSH Tricks
TUNNELING
Expose server port 456 on local port 123
$ ssh -L 123:localhost:456 user@yourserver.com
Transparent SOCKS proxy on localhost:12345
$ ssh -D 12345 user@yourserver.com
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z_][A-Za-z0-9_]+\.)*([A-Za-z_][A-Za-z0-9_]+)( extends ([A-Za-z][A-Za-z0-9_.]*)+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,field/
--regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/f,field/
@tychobrailleur
tychobrailleur / gist:5712504
Last active July 11, 2020 17:23
Capybara/Selenium/Firefox/Proxy.
require 'capybara/firebug'
# Disable Webmock if needed.
WebMock.disable_net_connect!(allow_localhost: true)
# Same thing for VCR if it has been imported somewhere.
VCR.configure do |c|
c.ignore_localhost = true
end
ENV['NO_PROXY'] = ENV['no_proxy'] = '127.0.0.1'
@pda
pda / ctags-post-commit.sh
Created May 1, 2013 04:03
Git post-commit hook to build ctags file. Backgrounding/mutex could be useful as codebase grows. See http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html for fancier options.
#!/bin/sh
set -e
PATH="/usr/local/bin:$PATH"
tmpfile=tags.$$
trap "rm -f $tmpfile" EXIT
ctags --tag-relative -Rf$tmpfile --exclude=.git --languages=ruby
mv $tmpfile tags
@gabehollombe
gabehollombe / gist:2468822
Created April 23, 2012 04:10
SSH tunnel between two NATed machines via a third SSH host
Useful for when you need to have two hosts talk to each other on a specific port but they're both NATed (behind routers).
For example, you want to be able to SSH into your friend's machine to pair program with them.
host-machine$ ssh -R 55555:localhost:22 myaccount@my_ssh_server.com
connecting-machine$ ssh -L 55555:localhost:55555 myaccount@my_ssh_server.com
connecting-machine$ ssh -p 55555 user_on_host_machine@localhost
@cstrahan
cstrahan / pair.md
Created April 11, 2012 00:22 — forked from wm/pair.md
TMUX Pairing

SSH setup for remote pairing

If Animal and Fozzie wanted to pair on Animals machine and they both have access to shared.muppets.com then they could use the following setup

  • Animal will have the following in ~/.ssh/config
Host tunnel_from_muppets
  Hostname space.muppets.com
 RemoteForward 1235 localhost:22