Skip to content

Instantly share code, notes, and snippets.

View whalesalad's full-sized avatar
🖨️
PC LOAD LETTER

Michael Whalen whalesalad

🖨️
PC LOAD LETTER
View GitHub Profile
{
"type" : "record",
"name" : "eventtype",
"doc:" : "Schema for describing events in sensor messages",
"namespace" : "com.endgame.sensor.avro",
"fields" : [
{
"name" : "key",
"doc" : "name of the event",
"type" : "string"
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/Made of Code.tmTheme",
"font_face": "Inconsolata",
"font_size": 16.0,
"gutter": true,
"highlight_line": true,
"hot_exit": false,
"ignored_packages":
[
@whalesalad
whalesalad / gist:af3f6eb82e53b98ebae8
Created May 1, 2014 22:40
A sample IAM role for read-only EC2 access.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:Describe*",
"Resource": "*"
},
{
"Effect": "Allow",
@require_POST
def update_password(request):
payload = json.loads(request.body)
password = payload.get('password', None)
password_confirm = payload.get('password_confirm', None)
unique = set([password, password_confirm])
if len(unique) > 1:
@whalesalad
whalesalad / views.py
Last active May 28, 2019 09:13
Doing Server-Side Events with Django (hint: it's easy)
import redis
from django.conf import settings
from django.http import StreamingHttpResponse as HttpResponse
def new_connection():
"""
At some point this will evolve into using a connection pool,
but for now it opens a new connection for each user.

Keybase proof

I hereby claim:

  • I am whalesalad on github.
  • I am whalesalad (https://keybase.io/whalesalad) on keybase.
  • I have the public key with fingerprint 0456 CF50 2680 EE1C 3F65  6794 FDE6 496A BCE5 EF27

To claim this, I am signing this object:

set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
"Bundle 'chriskempson/base16-vim'
@whalesalad
whalesalad / gist:7404432
Last active December 27, 2015 23:09
DIY Dynamic DNS for DNSimple (running on my pfSense firewall) You need to acquire a domain API token from DNSimple.com, and you'll also need the record id # of the specific record that you want to update. This will figure out your IP with the command on line #7, then fire off an API call to DNSimple to update your record. I have this running on …
#!/bin/bash
DOMAIN_TOKEN="XXXXXXXXXXXXXXXXXXXXX"
DOMAIN_ID="example.com"
RECORD_ID="12345678"
IP="`curl -s -f http://icanhazip.com/`"
curl -s -S \
-H "X-DNSimple-Domain-Token: $DOMAIN_TOKEN" \
@whalesalad
whalesalad / Rakefile
Created August 6, 2013 17:01
Quick and dirty Rakefile for a Wordpress project I maintain. Automates the conversion of .po files to .mo files. In this example, it uses all the .po files in the ./lang directory. Also note that I installed gettext via homebrew so the msgfmt binary is not on my path. Rather than muck with my path and risk screwing up OS X's built-in gettext stu…
MSGFMT = "/usr/local/Cellar/gettext/0.18.2/bin/msgfmt"
task :export_mo do |t|
po_files = Dir.glob(File.dirname(__FILE__) + '/lang/*.po')
po_files.each do |po|
mo = po.gsub(/.po\Z/, '.mo')
sh "#{MSGFMT} -o '#{mo}' '#{po}'"
end
end
@whalesalad
whalesalad / gist:5771984
Created June 13, 2013 08:01
Installing Ruby + Rails

rbenv

From your home directory

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

Crack open your ~/.bash_profile and modify your $PATH. Below is an example:

export PATH="$HOME/.rbenv/bin:$PATH"