Skip to content

Instantly share code, notes, and snippets.

View mechanicalgirl's full-sized avatar

barbara shaurette mechanicalgirl

View GitHub Profile
@mechanicalgirl
mechanicalgirl / redvblue_public
Created August 28, 2012 18:01
Playing around with the Sunlight Labs 'openstate' API
"""
This script pulls from the Sunlight Labs "openstates" API
to get information about legislators at the state level,
do a count of their party affiliations,
and return that information as
1) a JSON object for visualizations
2) a table suitable for embed into an HTML page
Information about the specific API used can be found here:
http://python-sunlight.readthedocs.org/en/latest/services/openstates.html
@mechanicalgirl
mechanicalgirl / gist:4119167
Created November 20, 2012 16:46
sample TX legislator data from the sunlight API
[
{ u'+capital_address': u' P.O. Box 12068, Capitol Station\nAustin, TX 78711\n(512) 463-0102',
u'+district_address': u' 18601 LBJ Freeway, Ste. 400\nMesquite, TX 75150\n(972) 279-1800',
u'active': True,
u'chamber': u'upper',
u'country': u'us',
u'created_at': u'2010-06-19 03:51:42',
u'district': u'2',
u'first_name': u'Bob',
u'full_name': u'Bob Deuell',
@mechanicalgirl
mechanicalgirl / gist:4946306
Last active December 13, 2015 17:18
Drag and drop js
jQuery(document).ready(function() {
var $ = jQuery;
/*
Execute revealDropzone() every 1000 milliseconds
Identify all of the input fields - once all of them have been populated,
reveal the drop zone
If any of the text inputs becomes empty again, hide the drop zone again
*/
setInterval(revealDropzone, 1000);
def _month_bounds(date):
"""
Helper: return the first and last days of the month for the given date.
"""
first_day = date.replace(day=1)
if first_day.month == 12:
last_day = first_day.replace(year=first_day.year + 1, month=1)
else:
last_day = first_day.replace(month=first_day.month + 1)
@mechanicalgirl
mechanicalgirl / YC
Created August 12, 2014 14:23
Doing more with Young Coders
This was the easiest way I could think of to reply to all of you in under 140 characters. :)
My hope for 2015 is to take Young Coders beyond what we're doing with it already. It's great that we're reaching kids at Python conferences. But those kids are, by and large, the children of programmers and probably already have some exposure to what we're teaching them and access to the tools they need to succeed.
What I really want to do, though, is take the class out to underserved kids, kids who maybe wouldn't get the opportunity to be exposed to programming otherwise. I'm happy to arrange all the details - venues, signups, even my own travel to some extent (although I'll start small and work local). But teaching programming to underserved kids means giving them computers - not just the RPis and cards, but all the peripherals, and maybe even books, that they'd need to get set up at home and keep going on their own.
It's the costs for that equipment, of course, that's holding me back. I could apply for a PSF g
export CMG_CONF=/your/path/to/mediaserver/mediaserver/apimage/test_config.json
python2.6 manage.py test apimage --settings='nodb_settings'
++ deactivate nondestructive
2016-06-13 15:18:50,729 [INFO] ++ unset pydoc
2016-06-13 15:18:50,729 [INFO] ++ '[' -n '' ']'
2016-06-13 15:18:50,729 [INFO] ++ '[' -n '' ']'
2016-06-13 15:18:50,729 [INFO] ++ '[' -n /bin/bash -o -n '' ']'
2016-06-13 15:18:50,729 [INFO] ++ hash -r
2016-06-13 15:18:50,729 [INFO] ++ '[' -n '' ']'
2016-06-13 15:18:50,729 [INFO] ++ unset VIRTUAL_ENV
2016-06-13 15:18:50,729 [INFO] ++ '[' '!' nondestructive = nondestructive ']'
2016-06-13 15:18:50,729 [INFO] ++ VIRTUAL_ENV=/opt/cmgd/venv
(venv)[ec2-user@ip-172-30-4-121 ~]$ /opt/cmgd/venv/src/weathervane/weather/manage.py weatherctl fetch all
Traceback (most recent call last):
File "/opt/cmgd/venv/src/weathervane/weather/manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/opt/cmgd/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/opt/cmgd/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/cmgd/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 263, in fetch_command
app_name = get_commands()[subcommand]
The code I have now that doesn't work (I only know it's not working because the map changed - the script isn't reading the coordinates I'm trying to pass in):
var testData = {
max: 8,
data: null
};
$.getJSON('traffic_fatalities.json', function(traffic_data) {
console.log(traffic_data);
testData.data = traffic_data;
This file has been truncated, but you can view the full file.
{
"count": 5760,
"filters": {
"dates": "20150401:20161203",
"tags": "game_preview|chr:entryGroup"
},
"ts": [
{
"distance": 72,