Skip to content

Instantly share code, notes, and snippets.

@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:
@lightstrike
lightstrike / parsley_selectors
Created October 28, 2014 20:12
Experimenting with how to customize django-parsley
def get_selector(*args):
return ''.join([a for a in args])
def get_parsley_errors_data(parsley_attr, fields):
parsley_extras = dict()
for field in fields:
field_dict = {}
field_slug = slugify(field)
field_dict[parsley_attr] = get_selector(
@lightstrike
lightstrike / _parsley.scss
Created October 20, 2014 23:20
Adapting base Parsley CSS into SASS mixins
/* Adapting base Parsley CSS into SASS mixins - http://parsleyjs.org/src/parsley.css */
/*
Use this mixin to define success and error classes
Default class names: parsley-success, parsley-error
*/
@mixin parsleyValidated($name, $textColor, $bgColor, $borderColor) {
input.#{$name},
select.#{$name},
textarea.#{$name} {
@lightstrike
lightstrike / icons.html
Last active August 29, 2015 14:05
Embedded Icon in Bootstrap 3 Input
<!--
See http://codepen.io/lightstrike/pen/tswme for demo
Example markup and inspiration from http://jsfiddle.net/KyleMit/cyCFS/
-->
<p>Full Size:</p>
<div class="left-inner-addon ">
<i class="glyphicon glyphicon-user"></i>
<input type="text"
class="form-control"
@lightstrike
lightstrike / get_classes_from_html.py
Last active August 29, 2015 14:04
Simple CSS class extraction script from HTML file
"""
Usage: get_classes_from_html.py path/to/file.html
"""
def convert_html_to_string(html_file_path):
html_file = open(html_file_path, 'r')
return html_file.read()
def get_css_classes(html_string, attribute='class'):