Skip to content

Instantly share code, notes, and snippets.

View lightstrike's full-sized avatar
🎯
Focusing

Geoffrey Sechter lightstrike

🎯
Focusing
View GitHub Profile
@lightstrike
lightstrike / admin.py
Created June 8, 2016 23:20
Student Record Brainstorming
class StudenAdmin(admin.ModelAdmin):
inlines = (StudentRecordInline,)
@lightstrike
lightstrike / admin.py
Last active December 21, 2022 03:11
Before Import Customization for Django-Import-Export
class OrganizationImportExportResource(ModelResource):
types = widgets.ManyToManyWidget(model=graph_models.OrganizationType,
field='name')
class Meta:
model = Organization
fields = [
'name',
]
import_id_fields = ['name']
@lightstrike
lightstrike / .vimrc
Created February 18, 2016 00:40
Vimrc Config
" Initialize pathogen for flake8
execute pathogen#infect()
syntax on
filetype plugin indent on
" remove trailing spaces in Python & Markdown
autocmd BufWritePre *.py :%s/\s\+$//e
autocmd BufWritePre *.md :%s/\s\+$//e
" call flake8 at every save
@lightstrike
lightstrike / add_to_settings.py
Created January 19, 2016 17:39
Setting up model mommy generators for custom fields
from model_mommy import generators
MOMMY_CUSTOM_FIELDS_GEN = {
'easy_thumbnails.fields.ThumbnailerImageField': generators.gen_image_field,
'model_utils.fields.AutoCreatedField': generators.gen_datetime,
'model_utils.fields.AutoLastModifiedField': generators.gen_datetime,
'django_extensions.db.fields.AutoSlugField': generators.gen_slug,
}
@lightstrike
lightstrike / instructions.md
Created January 11, 2016 18:27
How to Get a Direct Link to an Image Saved on Google Drive
  1. Make sure the image file you'd like to use is shared publicly.
2. Go to the image file, right click and select *Get link* 3. Inspect the link and get the ID. 4. The new link will be //googledrive.com/host/{FILE_ID}.
@lightstrike
lightstrike / README.md
Created May 26, 2015 03:21
Python Rolodex Formatter

Rolodex Formatter

Run program with python rolodex.py [file_name] - python rolodex test_input.txt will show a working example

Run tests with python -m unittest discover -v

@lightstrike
lightstrike / venvwrapinstall
Created March 8, 2015 19:39
Install Python virtualenvwrapper
#!/bin/bash
# installs virtualenvwrapper and adds initialization logic for .bashrc file
# change RC_FILE value as needed
RC_FILE=~/.bashrc
# global install of virtualenvwrapper
sudo pip install virtualenvwrapper
# creation of directory to store Python virtual environments
@lightstrike
lightstrike / developer_focus.py
Created February 28, 2015 22:42
Pivotal Tracker Developer Focus Metric
# -*- coding: utf-8 -*-
"""
Calculates the following 'Developer Focus' metric using
data from the Pivotal Tracker API:
# unique developers actively working on active projects /
Open stories ("started" state) from active projects
For this first pass, the IDs of active projects and
developers are set as environment variables.
In the future, it may be possible to determine these
@lightstrike
lightstrike / harvest_trackers.py
Last active August 29, 2015 14:10
Determine if a user is tracking time in Harvest
# http://docs.python-requests.org/en/latest/
import requests
from datetime import datetime, timedelta
domain_name = 'domain'
username = 'username'
password = 'password'
# lookup past 3 days along with today in case someone left a timer running
today = datetime.now()
@lightstrike
lightstrike / CBV Access
Created November 3, 2014 18:38
User View Mixins
class UserDetailAccessMixin(UserPassesTestMixin):
def test_func(self, user):
"""
Tests if user should be allowed access to DetailView if one of two conditions:
1. Has staff permissions
2. Is the customer associated with the object in a DetailView
"""
if user.is_staff:
return True
else: