Skip to content

Instantly share code, notes, and snippets.

View mattjmorrison's full-sized avatar

Matthew J Morrison mattjmorrison

View GitHub Profile
@mattjmorrison
mattjmorrison / caps_lock.md
Last active August 29, 2015 14:00
Caps Lock

How to use Caps Lock as both Ctrl and Esc on OS X

  1. Get [Homebrew][homebrew]
  2. Get [Homebrew Cask][cask]
  3. Install Seil using brew cask install seil
  4. Install Karabiner using brew cask install karabiner
  5. Disable Caps Lock
    • Open System Preferences
    • Open Keyboard Preferences
  • On the Keyboard Tab click "Modifier Keys..."
@mattjmorrison
mattjmorrison / prototypes.md
Created May 30, 2014 13:46
6-10-2014 DSMJS Prototype Talk

Prototypes

@mattjmorrison
mattjmorrison / templates.md
Last active August 29, 2015 14:02
Pyowa - Django Templates

Template Loaders

TEMPLATE_LOADERS = (
    ('django.template.loaders.cached.Loader', (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    )),
)
https://gist.github.com/mattjmorrison/2712d13932da8b35b187/edit
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.box = "ubuntu-14.04"
config.vm.provision "shell",
inline: <<-CMD
sudo apt-get install git vim python-virtualenv -y
sub _t{if(uc(ref($_[1]))=~m/^HASH/g){$s.='{';for(keys%{$_[1]}){$s.=$_.'=>';$_[0]->_t($_[1]->{$_});$s.=',';}$s.='},';}elsif(uc(ref($_[1]))=~m/^ARRAY/g){$s.='[';for(@{$_[1]}){$_[0]->_t($_);$s.=',';}$s.='],';}elsif(ref($_[1])){$s.='bless(';$_[0]->_t(scalar{%{$_[1]}});$s.=ref($_[1]).');';}else{$s.=qq|'$_[1]'|;}}
@mattjmorrison
mattjmorrison / chess_clock.sh
Created October 3, 2014 02:44
Tmux Chess Clock Pairing
#!/bin/bash
`tmux set-option -g display-time 2000`
IFS=$'\n'
CLIENTS=()
for CLIENT in $(tmux list-clients); do
CLIENTID="${CLIENT%:*}"
if [[ $CLIENT == *\(ro\) ]]
then
@mattjmorrison
mattjmorrison / models.py
Created February 20, 2011 04:43
Simple django mocking test example 1
from django.db import models
class SampleManager(models.Manager):
def get_by_user(self, user):
self.filter(user=user)
class Sample(models.Model):
pass
@mattjmorrison
mattjmorrison / tests.py
Created February 20, 2011 05:24
Simple django mocking test example 2
@mock.patch('django_testing.models.SampleManager.filter', mock.Mock())
def test_filters_by_user_with_patch(self):
user = mock.Mock()
models.Sample.objects.get_by_user(user)
models.Sample.objects.filter.assert_called_with(user=user)
@mattjmorrison
mattjmorrison / tests.py
Created February 20, 2011 05:49
Simple django mocking test example 4
@mock.patch('django_testing.models.SampleManager.get_last')
@mock.patch('django_testing.models.SampleManager.get_first')
def test_result_of_one_query_in_args_of_another(self, get_first, get_last):
result = models.Sample.objects.get_first_and_last()
self.assertEqual((get_first.return_value, get_last.return_value), result)