Skip to content

Instantly share code, notes, and snippets.

View ptone's full-sized avatar

Preston Holmes ptone

View GitHub Profile
@ptone
ptone / extract.py
Created September 14, 2012 23:55
extracting test polygons from a illustrator sketch: http://cl.ly/image/3M111A2O1Y0j
from appscript import app, k
import json
il = app(u'Adobe Illustrator')
doc = il.documents[u'GeoPolySketch.ai']
generated_code = ''
poly_template = 'self.{obj_name} = Polygon({points})'
@ptone
ptone / gist:3490967
Created August 27, 2012 18:11
Using djangorestframework to get JSON given just a resource outside of a view
from django.http import HttpRequest
from djangorestframework.views import ListOrCreateModelView
from djangorestframework.response import Response
from djangorestframework import status
from djangorestframework.renderers import JSONRenderer
from colorpicks.resources import ColorResource
resource_view = ListOrCreateModelView(resource=ColorResource)

Thoughts on Core Dev Panel for DjangoCon

There is currently an outstanding stalled request from Sean for a new chair - I'm tempted to help, but looking for help/feedback from core dev members to make it something improved.

Challenges:

  • too many core devs for the old format - results in very few questions with
@ptone
ptone / .bash_profile
Created August 12, 2012 20:03
cd to current finder window
# cdf: cd to the directory in the Finder's front window
alias cdf='cd "$(~/UNIX/bin/posd)"'

App-loading refactor reviewer's notes

The concept of the app-loading refactor concept has been around for 4-5 years From Django's earliest days, there has always been a tight coupling of the notion of a Django "app" and its models module. In fact, internally the term "app" essentially was the models module. As Django has matured, an "App" has come to be understood as rough abstraction that encapsulates some set of features for a project, that may or may not involve models. To Django this abstraction is generally a python package created by startapp, with modules

/*
* fslogger.c
*
* Copyright (c) 2008 Amit Singh (osxbook.com).
* http://osxbook.com/software/fslogger/
*
* Source released under the GNU GENERAL PUBLIC LICENSE (GPL) Version 2.0.
* See http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt for details.
*
* Compile (Mac OS X 10.5.x only) as follows:
from __future__ import print_function
from lxml.html.soupparser import fromstring
import requests
from datetime import datetime, timedelta
from collections import defaultdict
start_date = datetime(2012, 8, 6)
end_date = start_date + timedelta(days=60)
@ptone
ptone / output.txt
Created August 6, 2012 07:53
camp-hack.py
from __future__ import print_function
from lxml.html.soupparser import fromstring
import requests
from datetime import datetime, timedelta
from collections import defaultdict
start_date = datetime(2012, 8, 6)
end_date = start_date + timedelta(days=60)
from __future__ import print_function
from lxml.html.soupparser import fromstring
import requests
from datetime import datetime, timedelta
start_date = datetime(2012, 8, 6)
end_date = start_date + timedelta(days=45)
url = 'http://www.reserveamerica.com/campsiteCalendar.do?page=calendar&contractCode=CA&parkId=120030&calarvdate={caldate}&sitepage=true&startIdx={page_index}&sitefilter=STANDARD'
myfirstproject/
django -> ./django-dist/django (symlink)
django-dist (full clone/dist)
manage.py
myfirstproject/
settings.py etc