Skip to content

Instantly share code, notes, and snippets.

@dheaney
dheaney / test.py
Last active December 30, 2015 21:19
import urwid
def show_or_exit(key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()
txt.set_text(repr(key))
banner = u"""
____ __ __ __
/ __ \__ __/ /_/ /_ ________ ____ _/ /__
#!/usr/bin/env python
import os, time
import wikipedia
from datetime import datetime
import smtplib
user = 'hi@example.com'
pwd = 'SECRET'
path = '/Users/dejay/Dropbox/IFTTT/SMS/shell.iftt.txt'
import subprocess
lpr = subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE)
lpr.stdin.write(your_data_here)
@dheaney
dheaney / Autonomous
Created January 10, 2014 03:21
Autonomous
Pseudocode for Autonomous Period
Start with block in arm. Position robot.
0. Start timer.
1. Travel forward until IR beacon is in section 5.
2. Stop timer. Save value as n.
2. Rotate 90 degrees.
3. Travel forward until distance is less than ___.
4. Raise arm.
@dheaney
dheaney / Rakefile
Last active January 2, 2016 23:09
Set your Gravatar account image to your Address Book entry on your Mac.
# Copyright (c) 2012 David Heaney
require 'erb'
UNAME = ENV['USER']
AGENT = "/Users/#{UNAME}/Library/LaunchAgents/com.dejay.gravatar-mac.plist"
desc "Install Gravatar-Mac!"
task :install do
puts "Please enter the email that you wish to use for Gravatar-Mac:"
class RSPD(object):
def __init__(self, base10):
#if base10 > 210:
# raise NotImplemented
self.values = []
self.value = str()
remainder = int()
self.primes = primes_less_than(base10)
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
int i;
for(i = 0; i < 50; i++) {
cout << rand() % 2 << endl;
}
@dheaney
dheaney / first_default_arg.py
Last active August 29, 2015 13:56
Get the name of the first default argument from a python function
import inspect
def first_default_arg(func):
try:
argspec = inspect.getargspec(func)
return zip(argspec.args[-len(argspec.defaults):], argspec.defaults)[0][0]
except:
return None
# def action(one, two, three=3): pass
@dheaney
dheaney / -
Last active August 29, 2015 13:57
$.getJSON( https://roon.io/api/v1/blogs/tux/posts, function( data ) {
var posts = []
$.each( data, function( key, val ) {
console.log(key);
console.log(val.url);
posts.push(val.content_html);
$("<p/>", { html: val.content_html }).appendTo('body');
});
});
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os, sys
import curses
import outbreak
from emoji import emoji
def get_bool_input(message):