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 urllib2 | |
from lxml import html | |
from time import sleep | |
from datetime import datetime | |
from subprocess import Popen | |
PRODUCT_URL = "http://www.shopping.hp.com/store/product/product_detail/FB355UA%2523ABA?jumpid=se_r1002_fp_usen_hho" | |
def check(): | |
""" |
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 urllib2 | |
from time import sleep | |
from datetime import datetime | |
from subprocess import Popen | |
PRODUCT_URL = "http://content.newegg.com/LandingPage/ItemInfo4ProductDetail.aspx?Item=N82E16834158004" | |
def check(): | |
""" | |
Check product url and look for 'Out of Stock' in the specified xpath. |
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 django.contrib.auth.backends import ModelBackend | |
from django.contrib.auth.models import User | |
class EmailorUsernameBackend(ModelBackend): | |
""" | |
Authenticate given a users email or user name. | |
Does a double look up on email and user name but would rather | |
call super for ModelBackend to keep up with any changes. | |
put the following in your settings.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
import gevent | |
from gevent import monkey; monkey.patch_all() | |
from gevent import pool | |
import random | |
from time import sleep, time | |
import urllib2 | |
POOL_SIZE = 5 |
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
@property | |
def document(self): | |
user_id = self.id | |
user_document = UserDocument.objects.get(user_fk=user_id) | |
return user_document | |
User.add_to_class("document", document) |
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
cd ~ | |
sudo apt-get install unzip | |
sudo apt-get install python-software-properties -y | |
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" | |
sudo apt-get update | |
sudo apt-get install sun-java6-jre sun-java6-plugin -y | |
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz | |
rm elasticsearch.tar.gz |
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 haystack.inputs import Raw | |
>>> from haystack.query import SearchQuerySet, SQ | |
>>> sqs = SearchQuerySet().filter(content='python') | |
>>> sqs2 = SearchQuerySet().filter(SQ(content='python') | (SQ(content='python') & SQ(content=Raw('pycon^10')))) | |
>>> | |
>>> sqs.count() | |
16 | |
>>> sqs2.count() | |
16 | |
>>> |
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 django.db import models | |
# http://www.djangosnippets.org/snippets/562/#c673 | |
class QuerySetManager(models.Manager): | |
# http://docs.djangoproject.com/en/dev/topics/db/managers/#using-managers-for-related-object-access | |
# Not working cause of: | |
# http://code.djangoproject.com/ticket/9643 |
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/env python2 | |
from random import choice | |
pop = ['a', 'b', 'c',] | |
simulations = 0 | |
""" | |
while simulations < 3: | |
simulations += 1 |
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
Deployment notes for Ubuntu Instance | |
Nginx, uwsgi, postgres, django, virtualenv stack | |
* ssh root | |
root access (need pem) | |
ssh -i whatever.pem ubuntu@ec2-*-*-*-*.compute-1.amazonaws.com | |
* secure box | |
- cut off all ports but 22 and 80 using AWS Management Console | |
- edit /etc/ssh/sshd_config ensure PasswordAuthentication no |
OlderNewer