Skip to content

Instantly share code, notes, and snippets.

View mbaltrusitis's full-sized avatar
🕴️
-

Matthew Baltrusitis mbaltrusitis

🕴️
-
View GitHub Profile
@mbaltrusitis
mbaltrusitis / gist:b5d0fc563d8e02b6fec7
Created March 9, 2015 20:35
CODE Keyboard Karabiner Settings
<item>
<name>CODE/WASD Keyboard Media Keys (Mac)</name>
<appendix>This will bind CODE/WASD the printed values on the media keys to their actual software function.
* Insert : Pause / Play
* Delete : Previous SOng
* End : Next Song
* Pause : Mute Volume
* Page Up : Volume Up
* Page Down : Volume Down
</appendix>
@mbaltrusitis
mbaltrusitis / bash_profile
Created May 21, 2015 04:15
Basic Mac OS X .bash_profile
if [ $(id -u) -eq 0 ];
then # you are root, make the prompt red
PS1="┌─[\e[01;34m\u @ \h\e[00m]---[\e[01;34m$(pwd)\e[00m]\n└─>\e[01;31m#\e[00m "
else
PS1="┌─[\e[0;31m\u @ \h\e[00m]$\n└─>"
fi
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# Settings via http://hackercodex.com/guide/mac-osx-mavericks-10.9-configuration/
@mbaltrusitis
mbaltrusitis / sftp-config.json
Created July 3, 2015 20:49
Sublime SFTP package settings for remote server development
{
// Matt's Sublime SFTP settings for developing on a remote server
// This setup assumes you are using both an SSH key (as you should) and SFTP
// sftp, ftp or ftps
"type": "sftp",
"sync_skip_deletes": false,
"sync_same_age": true,
"confirm_downloads": false,
@mbaltrusitis
mbaltrusitis / main.py
Last active October 26, 2015 15:27
Update Variable Depth Dictionary
import collections
from pprint import pprint
my_dict = {
'one': {
'one-one': True,
'one-two': False,
'one-three': {
'one-three-one': True,
},
@mbaltrusitis
mbaltrusitis / git-new-workdir.sh
Created November 4, 2015 23:11
The contribute/git-new-workdir script from the git source. Super useful GitHub pages workflow.
#!/bin/sh
usage () {
echo "usage:" $@
exit 127
}
die () {
echo $@
exit 128
@mbaltrusitis
mbaltrusitis / arg_stomp.py
Last active February 1, 2016 21:14
Keep running a method until I have enough arguments.
#!/usr/local/bin/python3
import inspect
import random
class Foo(object):
def a_method(self, x, y, z):
print('Your method ran:\n', x, y, z)
@mbaltrusitis
mbaltrusitis / pip-virtualenv.sh
Last active March 15, 2016 22:00
Get pip and virtualenv into your system Python if they aren't already. This will also create a virtualenv as an example at $APP_Path.
#!/bin/bash
APP_PATH=$HOME/app
PYTHON_KERNEL=$APP_PATH/venv/bin/python
function install_pip {
echo -e 'downloading pip...'
curl -SLO https://bootstrap.pypa.io/get-pip.py
echo -e 'installing pip...'
python get-pip.py
@mbaltrusitis
mbaltrusitis / bracket-madness.py
Last active March 17, 2016 18:29
A random bracket selector.
#!/usr/bin/python
"""Randomly select your March Madness bracket.
"""
import random
south = (
(
@mbaltrusitis
mbaltrusitis / py-request.py
Last active February 6, 2017 20:07
A quick and dirty URL request and JSON decoding/deserialization.
import json
from urllib import request
from pprint import pprint
def main():
weather_req = request.urlopen("http://api.wunderground.com/api/872a930f94a85692/conditions/q/UK/London.json")
# read the request and decode the bytes into sensible UTF-8 strings
weather_data = weather_req.read().decode("utf-8")
# take a peak at the mess of it
@mbaltrusitis
mbaltrusitis / pascals_triangle.py
Created March 19, 2017 20:54
Given n, generate that many lines of Pascal's Triangle.
#!/usr/bin/env python3
import sys
def PascalsTriangle(row):
max_row = int(row)
triangle = []
current_row = 0