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 bottle import Bottle | |
| from sqlalchemy import create_engine | |
| from sqlalchemy import MetaData | |
| from sqlalchemy import Table | |
| # Main Web App | |
| app = Bottle() | |
| # Configuration for sqlalchemy | |
| # source https://scraperwiki.com/scrapers/malaysian_mp_profile/ |
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
| Desktop/$ ./ping2.py | |
| http://ucsb.edu True | |
| http://ucbs.edu False | |
| http://uscb.edu True | |
| http://usbc.edu False | |
| http://ubcs.edu False | |
| http://ubsc.edu False | |
| http://cusb.edu False | |
| http://cubs.edu False | |
| http://csub.edu True |
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 json | |
| data = {"nodes":[{"nodename":"foo"},{"nodename":"bar"}]} | |
| print json.dumps(data) | |
| nodes = data["nodes"] | |
| nodes.sort(key=lambda node: node['nodename']) | |
| data["nodes"] = nodes | |
| print json.dumps(data) |
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
| 38,39c38,40 | |
| < // create the audio context (chrome only for now) | |
| < var context = new webkitAudioContext(); | |
| --- | |
| > // create the audio context -- covers Firefox and Chrome | |
| > var AudioContext = AudioContext || webkitAudioContext; | |
| > var context = new AudioContext(); | |
| 70c71,73 | |
| < javascriptNode = context.createJavaScriptNode(2048, 1, 1); | |
| --- |
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 readFile(file) { | |
| var reader = new FileReader(); | |
| var deferred = $.Deferred(); | |
| reader.onload = function(event) { | |
| deferred.resolve(event.target.result); | |
| }; | |
| reader.onerror = function() { | |
| deferred.reject(this); |
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 nltk | |
| from nltk.corpus import brown | |
| pronouns = 'i me my us we he she it her his its they them their'.split() | |
| news_text = brown.words(categories='news') | |
| fdist = nltk.FreqDist([w.lower() for w in news_text]) | |
| # worst bar chart in human history | |
| for p in pronouns: |
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 nltk | |
| from nltk.corpus import brown, reuters | |
| pronouns = 'I me my us we he she it her his its they them their'.split() | |
| #news_text = brown.words(categories='religion') | |
| brown_text = brown.words(categories='news') | |
| reuters_text = reuters.words() |
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 matplotlib.pyplot as plt | |
| import numpy as np | |
| from nltk.corpus import inaugural | |
| def count_vowels(word): | |
| return len([c for c in word.lower() if c in 'aeiou']) | |
| words = set(inaugural.words()) | |
| lengths = [len(w) for w in words] | |
| vowel_count = [count_vowels(w) for w in words] |
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
| >>> some_ethiopic = [u"\u1234", u"\u1235", u"\u1236"] | |
| >>> for s in some_ethiopic: | |
| ... print s, unicodedata.name(s) | |
| ... | |
| ሴ ETHIOPIC SYLLABLE SEE | |
| ስ ETHIOPIC SYLLABLE SE | |
| ሶ ETHIOPIC SYLLABLE SO | |
| >>> # ok, now we want to put these in a dictionary: | |
| ... names = {} | |
| >>> for s in some_ethiopic: names[s] = unicodedata.name(s) |
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
| def depunctuate(raw, badletters): | |
| """ | |
| return a copy of the string raw with all of | |
| badletters removed | |
| """ | |
| fixed = '' | |
| for letter in raw: | |
| if letter not in badletters: | |
| fixed += letter | |
| return fixed |