This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
A simple script showing how to read data from a specified | |
file, do some basic processing, and then print out processed | |
lines to the shell. The input file is hard-coded in the text. | |
USAGE from command line | |
python simple_file_processing.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv | |
source_file = open('/path/to/Testfile.txt','rb') | |
# Use the DictReader class to read in your data. This class allows you to access | |
# field names by name. It assumes the first line in the file contains the field names | |
for line in csv.DictReader(source_file, delimiter='\t'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base_query = Casualty.safe_objects.all() | |
def build_chart(base_query, field_name, order_by): | |
''' | |
This is a function to make building our charts a little DRYer. Beats the pants off of lambdas. | |
''' | |
return base_query.values(field_name).annotate(Count(field_name)).order_by(order_by) | |
extra_context_dict = { | |
'theater_chart':build_chart(base_query, 'theater__name', '-theater__name__count'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
OlderNewer