View interface-lift-scrape.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 | |
from BeautifulSoup import BeautifulSoup | |
from urllib2 import urlopen | |
from re import compile, match | |
from urllib import urlretrieve | |
from sys import argv, stdout | |
from os.path import isfile | |
from time import sleep |
View simple-desktops-scrape.php
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 php | |
<?php | |
for ($page = 1; true; $page += 1) { | |
# Get the page of desktops | |
$url = 'http://simpledesktops.com/browse/' . $page . '/'; | |
$html = @file_get_contents($url); | |
# Bail if we hit a 404 |
View clear-background.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 | |
from BeautifulSoup import BeautifulStoneSoup | |
from commands import getoutput | |
from os.path import expanduser, join | |
plist = '~/Library/Preferences/com.apple.desktop.plist' | |
xml = getoutput('plutil -convert xml1 -o - -- {0}'.format(plist)) | |
soup = BeautifulStoneSoup(xml) |
View famigodocument.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
from datetime import datetime | |
from mongoengine import * | |
from mongoengine.queryset import queryset_manager | |
from re import sub | |
class FamigoDocument(Document): | |
_active = BooleanField(default=True, required=True) | |
@queryset_manager | |
def active(cls, queryset): |
View deepcopy.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
from copy import deepcopy | |
from mongoengine import Document, ReferenceField, connect | |
class Foo(Document): | |
pass | |
class Bar(Document): | |
foo = ReferenceField(Foo) | |
connect('tmp-deepcopy') |
View backup.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 | |
from BeautifulSoup import BeautifulStoneSoup | |
from urllib2 import urlopen | |
from urllib import urlretrieve | |
from os.path import basename | |
import sys | |
def main(argv=None): | |
if argv is None: |
View output.txt
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
Traceback (most recent call last): | |
File "unique.py", line 15, in <module> | |
B(foo=True).save() | |
File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/document.py", line 85, in save | |
mongoengine.queryset.OperationError: Tried to save duplicate unique keys (E11000 duplicate key errorindex: tmp-unique.a.$foo_1 dup key: { : null }) |
View output.txt
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: A object>, <A: A object>, <B: B object>] | |
Traceback (most recent call last): | |
File "unique3.py", line 20, in <module> | |
print B.objects | |
File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/queryset.py", line 1131, in __repr__ | |
File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/queryset.py", line 776, in __getitem__ | |
File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/queryset.py", line 427, in _cursor | |
File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/queryset.py", line 402, in _collection | |
File "build/bdist.linux-i686/egg/pymongo/collection.py", line 717, in ensure_index | |
File "build/bdist.linux-i686/egg/pymongo/collection.py", line 639, in create_index |
View file-field-fail.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
from copy import deepcopy | |
from mongoengine import * | |
from pymongo import Connection | |
class A(Document): | |
binary_field = BinaryField() | |
boolean_field = BooleanField() | |
date_time_field = DateTimeField() | |
decimal_field = DecimalField() | |
dict_field = DictField() |
View mongoengine-listfield-filefield.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
"""Python v2.7.1, MongoDB v1.8.2, PyMongo v1.10, MongoEngine v0.4 | |
""" | |
from mongoengine import connect, Document, FileField, ListField | |
from mongoengine.base import ValidationError | |
from mongoengine.fields import GridFSProxy | |
from pymongo import Connection | |
from time import time | |
# Start with a clean slate. |
OlderNewer