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 socket | |
| import sys | |
| # For getch... | |
| import tty | |
| import termios | |
| HOST = '192.168.1.8' | |
| PORT = 8888 | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
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 | |
| import binascii | |
| from PIL import Image, ImageFile | |
| import subprocess | |
| r = requests.get("http://webcams.sdes.ucf.edu/webcam/Stream/10", stream=True) | |
| # Generate Image Object | |
| def gen_image(): | |
| p = ImageFile.Parser() | |
| start_write = False |
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 bs4 import BeautifulSoup | |
| term = "trigun" | |
| url = "http://www.nyaa.se/?page=search&cats=0_0&filter=0&term=%s" % term | |
| r = requests.get(url) | |
| soup = BeautifulSoup(r.text) | |
| titles = soup.select('.tlistname') | |
| print titles | |
| print [title.contents for title in titles] |
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
| n = [121, 100, 1337, 404, 33] | |
| def num_digits(n): | |
| digits = 0 | |
| while n > 0: | |
| n /= 10 | |
| digits+= 1 | |
| return digits | |
| def is_palindrome(n): | |
| digits = num_digits(n) |
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
| var canvas = document.getElementById("theCanvas"); | |
| var ctx = canvas.getContext("2d"); | |
| var middle = {x: canvas.width / 2, y: canvas.height / 2}; | |
| var PI2 = Math.PI * 2; | |
| var radius = 100; | |
| var slices = [25, 50, 25, 100]; | |
| var total = slices.reduce(function(a, b) { return a+b; }); |
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
| print sum([x for x in xrange(1000) if x%3==0 or x%5==0]) |
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
| var reader = new FileReader(); | |
| var canvas, ctx; | |
| var base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | |
| var changes = document.getElementById("changes").value; | |
| var initChange = document.getElementById("initChange").value; | |
| document.getElementById("changes").addEventListener('change', function(e) | |
| { | |
| changes = this.value; | |
| createCanvas(glitch(reader.result)); | |
| }, false); |
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
| # Grab some subreddits' titles | |
| import requests | |
| from time import sleep | |
| import json | |
| # Get top 25 subreddits | |
| r = requests.get(r'http://www.reddit.com/subreddits/popular/.json') | |
| subs = {} | |
| data = r.json() |
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 | |
| import math | |
| from collections import Counter | |
| sentence = "I love this game" | |
| json_data = open('reddits.json') | |
| data = json.load(json_data) | |
| stop_words = set(['a', 'about', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'amoungst', 'amount', 'an', 'and', 'another', 'any', 'anyhow', 'anyone', 'anything', 'anyway', 'anywhere', 'are', 'around', 'as', 'at', 'back', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below', 'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom', 'but', 'by', 'call', 'can', 'cannot', 'cant', 'co', 'computer', 'con', 'could', 'couldnt', 'cry', 'de', 'describe', 'detail', 'did', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight', 'either', 'eleven', 'else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', 'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fi |