Welcome to Python 101 at PyOhio 2013!
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
#Given to the public domain | |
#No warranties | |
import urllib2 | |
import simplejson | |
def shorturl(urltoshorten): | |
"""Compress the URL using goo.gl take a look at https://developers.google.com/url-shortener/v1/getting_started | |
>>> shorturl('http://igor.tamarapatino.org') | |
'http://goo.gl/FxHOn' |
This demonstrates how different regular expression engines handle catastrophic expressions. Python's "re" module doesn't seem to have any type of backtracking timeout.
» awk --version
GNU Awk 4.0.1
» time echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | awk '{ gsub("^(([a-z])+.)+A-Z+$", "test"); print}'
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 | |
''' | |
This file contains fake data which may be useful in | |
demonstrating basic principles in Python. | |
''' | |
import random | |
colors = [ | |
'red', |
My model for assessing trust with people.
- Random strangers
- Acquaintances
- Most friends that are more than acquaintances
- Close friends
- Only me
- No additional bots in the channel. Only ChanServ and jenni are allowed.
- No automated scripts. (eg: No automatic /me's or messages when you go "away")
- No personal insults.
- No cheating.
- Do not highlight nicks unless you are conversing with said person or persons.
- Do not spam the channel with non-relevant commands to the current game.
- Do not beg/insist the ops ban somebody.
git.io is an awesome URL shortener provided by Github. It works when shortening URLs from *.github.com/* to a small https://git.io/ link.
>>> import requests
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 | |
import copy | |
f = open('weechat.conf', 'r') | |
formats = ['/join ', '/query '] | |
networks = { |
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
#Given to the public domain | |
#No warranties | |
import urllib2 | |
import simplejson | |
def shorturl(urltoshorten): | |
"""Compress the URL using goo.gl take a look at https://developers.google.com/url-shortener/v1/getting_started | |
>>> shorturl('http://igor.tamarapatino.org') | |
'http://goo.gl/FxHOn' |