Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# led.py - Sample classes and methods to get you started with LED's the OOP way.
def send_val_to_pin(pin, colorval):
print "Pin: %s | ColorVal: %s" % (str(pin), str(colorval))
class LED:
def __init__(self, pin_r, pin_g, pin_b):
self.pin_r = pin_r
self.pin_g = pin_g
import pickle
data1 = {'a': [1, 2.0, 3, 4+6j],
'b': ('string', u'Unicode string'),
'c': None}
selfref_list = [1, 2, 3]
selfref_list.append(selfref_list)
output = open('data.pkl', 'wb')
from django.http import HttpResponseRedirect
def has_perm_or_redirect(permission, redirect):
def wrapper(function):
def wrapped_function(request, *args, **kwargs):
if request.user.has_perm("tpd4.NONE"):
print request.user.has_perm("blah")
return function(request, *args, **kwargs)
else:
return HttpResponseRedirect(redirect)
@agscala
agscala / vine2gif.py
Created January 30, 2013 21:28
python vine2gif.py [vine_url] [output_file] Scrapes vine url, downloads video, and converts the file to a gif with mplayer
from pyquery import PyQuery as pq
import sys
import subprocess
import os
from urllib2 import urlopen, URLError, HTTPError
def convert(input_file, output_gif):
print "CONVERT", input_file, " => ", output_gif
subprocess.call(["mplayer", input_file, "-ao", "null", "-ss", "0:0:0", "-endpos", "6", "-vo", "gif89a:fps=8:output=%s" % output_gif, "-vf", "scale=240:180"])
@agscala
agscala / gist:6188347
Created August 8, 2013 20:24
Search directories for unused header files
import os
import re
from collections import defaultdict
# Directories to inspect all .h, .c, .cpp files inside
TARGET_DIRECTORIES = ["source", "include"]
def getfilepaths(target_directory):
all_files = []
"
" | |
" . , . . ,---. ,---| | ,---.
" \ / | | | | | | | |---'
" ' '---' ' ' `---' '--- `---
"
" -----------------------------------
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
Ariel Pink's Haunted Graffiti - Only In My Dreams
Beach Fossils - What A Pleasure
Belle & Sebastian - Get Me Away From Here, I'm Dying
Best Coast - The Only Place
Deerhunter - Desire Lines
Diiv - Human
Dirty Gold - California Sunrise
Dom - Rude As Jude
Fools Gold - Surprise Hotel
Future Islands - Balance
/** @jsx React.DOM */
var React = require('react');
var Store = require('./Store.js');
var actions = require('./actions.js');
var Cell = React.createClass({
getInitialState: function () {
console.log("Cell init")
return {
function process_image(image_data) {
}
function get_imgur_image(params, callback) {
$.get("imgur url", params, function(data) {
if(data === not what you're looking for) {
get_imgur_image(updated_params, callback);
}
else {
callback(data)
var seen_images = [...]
var process_image = function() { /* render */ };
var find_image = function(page_num, callback) {
$.get('url', {page: page_num}, function(image_list) {
var new_image_found = false;
for(var i = 0; i < image_list.length; ++i) {
if(seen_images.indexOf(image_list[i]) == -1) {