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 mongoengine import * | |
from mongoengine import DENY, CASCADE, NULLIFY, DO_NOTHING | |
from mongoengine import DeleteForbidden # or something equivalent | |
from mongoengine.queryset import QuerySet | |
class Post(Document): | |
title = StringField() | |
@classmethod |
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
>>>True,False=False,True | |
>>>False | |
True | |
>>>1==2 | |
False | |
>>>(1==2)==True | |
True | |
>>> # This shows how setting True/False is nothing more than a simple (yet scary!) | |
>>> # variable assignment in the local scope: |
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
require 'formula' | |
class GitFlow <Formula | |
url 'git://github.com/nvie/gitflow.git' | |
version '0.2' | |
homepage 'http://github.com/nvie/gitflow' | |
md5 'da3d5ff107f8fec1dad9aa3c0bc357a3' | |
depends_on 'git' | |
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
class Foo: | |
x = {} | |
def __init__(self, id): | |
self.x = { id: id } | |
f1 = Foo(5) | |
print f1.x # { 5:5 }, as expected | |
f2 = Foo(6) | |
print f2.x # { 6:6 }, as expected |
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
class Bar: | |
x = {} | |
print Bar.x # {} |
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
class Foo: | |
x = 3 | |
def __init__(self, id): | |
self.x = id | |
f1 = Foo(5) | |
print f1.x # 5, as expected | |
f2 = Foo(6) | |
print f2.x # 6, as expected |
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
print f1.x # {5:5,6:6}, too! |
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
class Foo: | |
x = {} | |
def __init__(self, id): | |
self.x[id] = id | |
f1 = Foo(5) | |
print f1.x # {5:5}, as expected | |
f2 = Foo(6) | |
print f2.x # {5:5,6:6} ?! |
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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
NewerOlder