Skip to content

Instantly share code, notes, and snippets.

@DanThomson
DanThomson / gist:d9f7bdf4a8108ea7185d09428dda6d88
Created May 10, 2017 14:43
Generic __repr__ for sqlalchemy models
@classmethod
def _repr_template(cls):
"""
Creates a class specific template for __repr__
"""
beginning, middle, end = ('{}(', "{}={{{}}}", ')')
table = cls.__table__
primary_fields = table.primary_key.columns_autoinc_first
" Run /vagrant/bin/start.sh in virtual machine.
nnoremap <silent> <F5> :sil! !ssh -i ~/.vagrant.d/insecure_private_key -p 2222 vagrant@localhost /vagrant/bin/start.sh<CR>
ps | grep spring | grep -v grep | cut -f1 -d ' ' | xargs kill
@DanThomson
DanThomson / Paste fix directions
Created November 11, 2015 17:43
Paste without formatting in os X
Open 'System Preferences -> Keyboard'
Select tab 'Shortcuts'
Select 'Application Shortcuts' from the left listbox
Click '+' below right listbox
Select 'All Applications' for 'Application' input box
Type 'Paste and Match Style' into the 'Menu Title' input box
In the 'Keyboard Shortcut' input box press ⌘v
Click 'Add'
@DanThomson
DanThomson / better_django_urls
Last active August 30, 2015 22:46
Better django urls
#This is a work in progress.
from django.conf.urls import patterns, url
from view_file_name import my_view
def kwarg(kwarg_name, kwarg_regex=r'[a-z0-9-]+'):
"""
:param kwarg_name: The key to which this kwarg will be assigned
:param kwarg_regex: The regular expression the keyword's value must match
@DanThomson
DanThomson / ssh_vagrant
Last active November 13, 2015 15:23
ssh config entry for vagrant
Host vagrant
Port 2222
Hostname 127.0.0.1
User vagrant
IdentityFile ~/.vagrant.d/insecure_private_key
@DanThomson
DanThomson / gist_howto.md
Last active August 29, 2015 14:02
Gist HowTo

Use gists for documentation!

Add gist to your ~/.ssh/config

Host gist
	Hostname gist.github.com
	User git