Skip to content

Instantly share code, notes, and snippets.

View greglinch's full-sized avatar

Greg Linch greglinch

View GitHub Profile
@greglinch
greglinch / doccloud_delete_docs_in_project.py
Last active December 21, 2015 11:39
This Python script uses Ben Welsh's python-documentcloud API wrapper (http://datadesk.github.io/python-documentcloud) to delete every document in a specific DocumentCloud.org project. To use, enter in command: line $ pip install python-documentcloud. To execute, type: $ python ./doccloud_delete_docs_in_project.py
from documentcloud import DocumentCloud
"""
Delete each document in the specified project
"""
# define your variables
username = "USERNAME_HERE"
password = "PASSWORD_HERE"
@greglinch
greglinch / add-to-page.js
Last active December 15, 2015 15:41
Tired of verbose code embeds? Insert HTML, CSS or JS onto a page using one line per code block. Also handy when sharing across sites: you just update the main JS file and don't need to re-send updated embed codes. NOTE: I'd recommend renaming the variables and IDs to things that relate to the content so it's better self-documenting code.
//// JAVASCRIPT ////
// Set the vars
// be sure to minify the code: http://www.willpeavy.com/minifier
var cssContentOne = 'CSS HERE';
var htmlContentOne = 'HTML HERE';
var htmlContentTwo = 'HTML HERE';
@greglinch
greglinch / udacity-cs101-unit-1-final-quiz.py
Created March 1, 2012 03:20
Example of how to extract a link in Python using only the find() function
page ='<div id="top_bin"><div id="top_content" class="width960"><div class="udacity float-left"><a href="http://www.xkcd.com">'
start_link = page.find('<a href=')
start_quote = page.find('"', start_link)
end_quote = page.find('"', start_quote+1)
url = page[start_quote+1:end_quote]
@greglinch
greglinch / arduino_input_incrementer
Created June 4, 2011 20:51
To measure the output of my desk pedals at work using an Arduino
// ARDUINO INPUT INCREMNENTER
// To measure the output of my desk pedals at work
// Adapted from Example 03A from "Getting Started with Ardunio" by Massimo Banzi
// Greg Linch
// http://www.greglinch.com
#define BUTTON 7 // input pin where the push button is connected; this will soon be replaced with alternative method to measure output of pedals
int val = 0; // store the state of the input pint