This file contains hidden or 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
@app.route("/cart") | |
def shopping_cart(): | |
"""TODO: Display the contents of the shopping cart. The shopping cart is a | |
list held in the session that contains all the melons to be added. Check | |
accompanying screenshots for details.""" | |
melon_ids = session.get("my_melons") | |
melon_qty = {} | |
for melon_id in melon_ids: | |
if melon_qty.get(melon_id): |
This file contains hidden or 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
SQL> problem | |
Problem 2 | |
Select statements can have an additional clause called the 'where' clause. | |
This lets us extract specific rows out of our table. Our where clause can be | |
specific enough to match a single row, or general enough to match a set of | |
rows. The format of a select statement with a 'where' clause is: | |
SELECT <column list> FROM <table name> WHERE <equality expression>; | |
Examples: http://sqlzoo.net/wiki/SELECT_basics -- 1 |
This file contains hidden or 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
"Pathogen" | |
call pathogen#infect() | |
"Taglist stuff for mac" | |
let Tlist_Ctags_Cmd='/usr/local/bin/ctags' | |
"Basic crap for coding" | |
syntax on | |
set ai | |
set autochdir |
This file contains hidden or 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
Meringue:shenanigans chriszf$ python test.py | |
fish | |
this is a fish | |
s/"fish"/"squid"/g | |
squid | |
this is a squid |
This file contains hidden or 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
Meringue:shenanigans chriszf$ python | |
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) | |
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import lib.vim | |
>>> some_str = "DevBeat is pretty alright" | |
>>> s/"alright"/"awesome"/some_str | |
'DevBeat is pretty awesome' | |
>>> |
This file contains hidden or 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
mac3:shenanigans czf$ cat 031_switchcase2.py | |
import lib.switchcase | |
def one(): | |
print "One branch executed" | |
def two(): | |
print "Two branch executed" | |
def three(): |
This file contains hidden or 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 lib.switchcase | |
def one(): | |
print "One branch executed" | |
def two(): | |
print "Two branch executed" | |
def three(): | |
print "Three branch executed" |
This file contains hidden or 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
def cross(A, B): | |
"Cross product of elements in A and elements in B." | |
return [a+b for a in A for b in B] | |
digits = '123456789' | |
rows = 'ABCDEFGHI' | |
cols = digits | |
squares = cross(rows, cols) | |
unitlist = ([cross(rows, c) for c in cols] + | |
[cross(r, cols) for r in rows] + |
This file contains hidden or 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
class case(object): | |
EMPTY_CASE = (None for x in [1]) | |
def __init__(self, *args): | |
self.cases = args | |
self.used = False | |
def __iter__(self): | |
return self | |
def next(self): |
This file contains hidden or 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
def custom_len(input_list): | |
"""custom_len(input_list) imitates len(input_list)""" | |
count = 0 | |
for item in input_list: | |
count += 1 | |
return count | |
def custom_remove(input_list, value): | |
"""custom_remove(input_list, value) imitates input_list.remove(value)""" | |
for i in range(custom_len(input_list)): |
NewerOlder