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
from nltk.chat.util import Chat, reflections | |
pairs = [ | |
[ | |
r"My name is (.*)", | |
['hello %1', '%1 mabuhay ka'], | |
], | |
[ | |
r'hi', | |
['hello', 'kamusta', 'mabuhay',], |
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
# export script | |
# export_script.js | |
print("subject,sender,recipient,created") | |
db.collectionname.find({'subject':/for you/}).foreach(function(email){ | |
print(email.subject+","+email.sender+","+email.recipient+","+email.created); | |
}); | |
# then run this line | |
$ mongo tablename export_script.js > export_file.csv |
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
from django.contrib.auth.models import User | |
from django.db.models import Count | |
qs = (User.objects.all(). | |
extra(select={ | |
'm': "EXTRACT(month FROM date_joined)", | |
'd': "EXTRACT(day FROM date_joined)", | |
'y': "EXTRACT(year FROM date_joined)", | |
}). | |
values('d', 'm', 'y'). |
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 requests | |
from BeautifulSoup import BeautifulSoup | |
resp = requests.get('http://www.ofwguru.com/sitemap.xml') | |
soup = BeautifulSoup(resp.content) | |
urls = soup.findAll('url') | |
for url in urls: | |
loc = url.find('loc').string |
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
$ mongoexport -d dbname -c collectionname -v -o file.json | |
$ mongoimport -d dbname -c collectionname -v --file file.json -h 127.0.0.1 -p 27017 |
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
Django Compressor + Amazon S3 | |
============================= | |
http://django-compressor.readthedocs.org/en/latest/ | |
https://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html | |
$ pip install django_compressor | |
$ pip install django-storages boto | |
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
<VirtualHost *:80> | |
ServerName example.com | |
Redirect permanent / http://www.example.com/ | |
</VirtualHost> | |
<VirtualHost *:80> | |
ServerName www.example.com | |
<Directory /home/ubuntu/public_html/example/example/> |
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
function isEmail(email){ | |
// http://www.w3.org/TR/html-markup/input.email.html | |
var emailReg = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/ | |
return emailReg.test(email); | |
} |
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 OdeskView(View): | |
class LinkAccount(View): | |
def get(self, request, *args, **kwargs): | |
client = odesk.Client(settings.ODESK_API_KEY, | |
settings.ODESK_API_SECRET) | |
url = client.auth.get_authorize_url() | |
# need to store request token and request token secret | |
# so that callback url will not raise exception |
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
<html> | |
<head> | |
<style type="text/css"> | |
#toc .h1 { | |
font-size: 20px; | |
font-weight: bold; | |
text-indent: .25in; | |
} |