Skip to content

Instantly share code, notes, and snippets.

View zstumgoren's full-sized avatar

Serdar Tumgoren zstumgoren

View GitHub Profile
@zstumgoren
zstumgoren / gist:2f1a4866d5f93d9d78cb
Created January 30, 2015 17:19
example of modifying python module search path
>>> import sys,pprint
>>> pprint.pprint(sys.path)
['',
'/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg',
'/Library/Python/2.7/site-packages/six-1.8.0-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
@zstumgoren
zstumgoren / mv_files.rb
Created December 22, 2014 18:47
Quick/dirty script to organize files by year/month.
#!/usr/bin/env ruby
# Quick-and-dirty script that moves HTML files produced by Thunderbird
# into year/month directories;
#TODO: Update script to be more memory-efficient
require 'fileutils'
# COMMENTING THIS OUT. WE NEED TO UPDATE IMPLEMENTATION
# TO ONLY CREATE FOLDERS FOR MONTHS WHERE EMAIL EXISTS#years = (2010..2014).to_a.collect { |year| year.to_s }
#months = (1..12).to_a.collect { |num| num.to_s.rjust(2,'0') }#years.each do |year|
@zstumgoren
zstumgoren / merge_pdfs.sh
Last active August 29, 2015 14:11
merge pdf files from a directory
#!/bin/bash
pdf_files=(*.pdf)
n=1000
count=0
for ((i=0; i < ${#pdf_files[@]}; i+=n)); do
count=$((count+1));
# UPDATE DIRECTORY NAME, AS NEEDED
pdfjam "${pdf_files[@]:i:n}" -o ../FINAL-COMBINED/inbox/"$i".pdf
;
@zstumgoren
zstumgoren / gist:fecc7672540d757c53c1
Created August 7, 2014 18:57
nginx sample setup
server {
listen 80;
server_name watusi.inside.ap.org;
root /mnt/share_STG/rack_apps/watusi/current/public;
passenger_ruby /home/interact/.rvm/wrappers/ruby-1.9.3-p448/ruby;
passenger_enabled on;
rails_env production;
access_log /var/log/nginx/watsui.access.log;
@zstumgoren
zstumgoren / gist:5817465
Last active December 18, 2015 17:19 — forked from sc0ttman/gist:1145418
Rails3 - CheatSheet - CommandLine
rails new ApplicationName – Create a new application
rails _3.0.9_ new ApplicationName – Create a new application with a specific version of rails
rails generate/g model ModelName – Creates a model with the specified model_name
rails generate/g controller ControllerName – Creates a controller with the specified controller_name
rails generate/g migration MigrationName – Creates a migration with the specified migration_name
rails generate/g scaffold ModelName ControllerName – A shortcut for creating your controller, model and view files etc.
rails destroy controller ControllerName – Destroys the created controller and its related file.
rails destroy model - Destroys the created model and its related file.
/**
* Copy Button modeled on Add button features from Django admin and Grappelli inlines.js
*/
var OPELEC = OPELEC || function() {};
OPELEC.inlines = {
copy: function(copy_anchor) {
// Get stacked inline container from copy button that was clicked
1 (function($) {
2 $(document).ready(function() {
3 //$.fn.opelec_inline = function() {
4 /*
5 return this.each(function(elemIndex) {
6 var inline = $(this);
7 var copy_anchor = inline.find("a.grp-copy-handler");
8 copyButtonHandler(copy_anchor);
9 console.log(elemIndex);
10 });
@zstumgoren
zstumgoren / georgia_leg_calendar.py
Created June 8, 2012 16:27
Scrape Georgia state leg calendar site
import re
import urllib2
from BeautifulSoup import BeautifulSoup
def main():
base_url = "http://webmail.legis.ga.gov/Calendar/"
program_url = base_url + "?Chamber=house"
html = urllib2.urlopen(program_url).read()
soup = BeautifulSoup(html)
@zstumgoren
zstumgoren / georgia_leg_calendar.py
Created June 8, 2012 16:26
Scrape Georgia state leg calendar site
from BeautifulSoup import BeautifulSoup
import re
import urllib2
def main():
base_url = "http://webmail.legis.ga.gov/Calendar/"
program_url = base_url + "?Chamber=house"
html = urllib2.urlopen(program_url).read()
soup = BeautifulSoup(html)
@zstumgoren
zstumgoren / FdaMedDeviceRecalls
Created January 31, 2012 14:24 — forked from anonymous/FdaMedDeviceRecalls
Kwillson@icij.org
"""
A few notes:
* Lines starting with "#" signs are standard Python code comments
* Multi-line comments can be wrapped in triple-quotes (""")
"""
from itertools import islice, product
import calendar
from BeautifulSoup import BeautifulSoup
import requests