Skip to content

Instantly share code, notes, and snippets.

View JohnStuartRutledge's full-sized avatar

John Rutledge JohnStuartRutledge

View GitHub Profile
@JohnStuartRutledge
JohnStuartRutledge / python_idioms.md
Last active February 23, 2023 09:56
A gist for tracking examples of idiomatic Python. The goal is to accrue a list of concrete examples to help develop an intuition of what constitutes "Pythonic" code.
@JohnStuartRutledge
JohnStuartRutledge / php_to_python.md
Last active December 18, 2015 00:18
Side by side examples of how you would write the same code in Python and PHP.

PHP to Python

You can see some more examples of PHP to Python at hyperpolyglot


PHP

$x = "nice";
@JohnStuartRutledge
JohnStuartRutledge / scopes.txt
Last active December 19, 2015 18:28 — forked from iambibhas/scopes.txt
Sublime Text 2: Snippet scopes
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CSS: source.css

Django Idioms

General Tips

  • put methods that apply to a single instance of a Model on the model class itself
  • put methods meant to query against a Models entire table that models corresponding managers.py file.
  • if a models.py file gets too long to manage then create a models directory and place an __init__ file in it.
  • try to avoid using signals, but if you must then put them in a signals.py file
import requests
from bs4 import BeautifulSoup
headers = {
'host': '...etc',
'user-agent': 'Mozilla... etc',
}
url = 'https://global.sitesafety.trendmicro.com/result.php'
cookies = {'some_cookie_name': 'example cookie value'}
@JohnStuartRutledge
JohnStuartRutledge / FC_email_variables.md
Created September 19, 2017 21:05
Email Variables for Fluent City

Fluent City Emails

Below is a list of variables that can be used in the SendGrid Email templates.

COURSE

field name example value
course__id 1
course__code C-ND1-DDX-TUWESA-02/28/2017-2139
course__template_name Spanish 1
course__cancelled False
@JohnStuartRutledge
JohnStuartRutledge / mlb.csv
Last active July 20, 2018 17:08
mlb genome
pos word freq is_keyword
VERB play 50808 1
VERB feel 29178 0
VERB win 26113 0
VERB look 24600 0
VERB pitch 24093 0
VERB hit 23734 0
VERB mean 19342 0
VERB start 18708 0
VERB throw 18025 0
@JohnStuartRutledge
JohnStuartRutledge / owl.csv
Last active July 20, 2018 18:22
Overwatch Genome
pos word freq is_keyword
VERB play 86514 0
VERB kill 22264 1
VERB mean 21558 0
VERB look 20111 0
VERB feel 19698 0
VERB work 17655 0
VERB come 16599 0
VERB lose 15635 1
VERB win 15284 1
@JohnStuartRutledge
JohnStuartRutledge / nfl.csv
Created October 7, 2018 17:54
NFL Genome
pos word freq is_keyword
VERB play 46089 0
VERB win 15076 0
VERB feel 13274 0
VERB run 12253 1
VERB happen 7409 0
VERB watch 6378 0
VERB change 4862 0
VERB understand 4458 0
VERB throw 4434 1
@JohnStuartRutledge
JohnStuartRutledge / nba.csv
Created October 7, 2018 18:06
NBA Genome
pos word freq is_keyword
VERB shoot 25459 1
VERB happen 24725 0
VERB lose 19558 0
VERB watch 19244 0
VERB run 15381 0
VERB score 15267 0
VERB beat 14579 1
VERB hit 14095 0
VERB stay 13645 0