This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <stdlib.h> | |
| using namespace std; | |
| int main() { | |
| int i; | |
| for(i = 0; i < 50; i++) { | |
| cout << rand() % 2 << endl; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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:" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| lpr = subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE) | |
| lpr.stdin.write(your_data_here) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import os, time | |
| import wikipedia | |
| from datetime import datetime | |
| import smtplib | |
| user = '[email protected]' | |
| pwd = 'SECRET' | |
| path = '/Users/dejay/Dropbox/IFTTT/SMS/shell.iftt.txt' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urwid | |
| def show_or_exit(key): | |
| if key in ('q', 'Q'): | |
| raise urwid.ExitMainLoop() | |
| txt.set_text(repr(key)) | |
| banner = u""" | |
| ____ __ __ __ | |
| / __ \__ __/ /_/ /_ ________ ____ _/ /__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import floor, log10 | |
| def sigfigs(x): | |
| while((x % 10) == 0): | |
| x = x / 10 | |
| return int(floor(log10(abs(x))) + 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from outbreak import Game | |
| import inspect | |
| game = Game(3 , 0) | |
| player = game.players[0] | |
| inspect.getargspec(player.drive)[0] # => ['self', 'city'] | |
| inspect.getargspec(inspect.getmembers(player, predicate=inspect.ismethod)[3][1])[0] # => ['self', 'city'] | |
| methods = [ x for x in inspect.getmembers(player, |