Skip to content

Instantly share code, notes, and snippets.

View looselycoupled's full-sized avatar

Allen Leis looselycoupled

  • United States
View GitHub Profile
@looselycoupled
looselycoupled / gist:4773235
Created February 12, 2013 20:46
Global (user) .gitconfig for color
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
@looselycoupled
looselycoupled / resize.py
Last active August 29, 2015 14:12
Quick script to resize a folder of images
##########################################################################
## Imports
##########################################################################
import os
from PIL import Image
##########################################################################
@looselycoupled
looselycoupled / screencap_website.py
Last active August 29, 2015 14:12
Sample code to screencap a website
"""
This is an example of how to take a screen capture using Selenium and
PIL. The code uses the PhantomJS driver so be sure to install
per the requirements section below.
Note that Selenium can save a screen capture directly to disk but the
code here saves it as a StringIO object so we can demonstrate how to
get the data into PIL. From there we can edit it, store in a database,
save out to s3, etc. without needing to create a file on disk
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
#!/usr/bin/env python
"""
Model answer for RSS exercise
NOTE: In order to use this program, be sure to create a sub-directory
called 'articles'
"""
##########################################################################
## Imports
#!/usr/bin/env python
"""
Model answer for REST Workshop
NOTE: In order to use this program, be sure to create a sub-directory
called 'releases'
"""
##########################################################################
## Imports
##########################################################################
#!/usr/bin/env python
"""
Model answer for REST workshop using OpenCalais
"""
##########################################################################
## Imports
##########################################################################
import requests
"""
SQLite workshop to get comfortable with SQL and the operations
required for managing data. Check out the pymotw link below under
Resources for further explanations and code samples
Resources:
http://pymotw.com/2/sqlite3/
https://docs.python.org/2/library/sqlite3.html
"""
"""
SQLite workshop to get comfortable with SQL and the operations
required for managing data. Check out the pymotw link below under
Resources for further explanations and code samples
Resources:
http://pymotw.com/2/sqlite3/
https://docs.python.org/2/library/sqlite3.html
"""
@looselycoupled
looselycoupled / clock.py
Last active August 29, 2015 14:23 — forked from bbengfort/clock.py
#!/usr/bin/env python
# clock
# Prints out the time specially formatted
#
# Author: Benjamin Bengfort <benjamin@bengfort.com>
# Created: Sat Mar 08 15:29:47 2014 -0500
#
# Copyright (C) 2014 Bengfort.com
# For license information, see LICENSE.txt
#