Skip to content

Instantly share code, notes, and snippets.

@xzys
xzys / index.html
Last active August 29, 2015 14:05
procedurally and randomly generated trees
<!DOCTYPE html>
<meta charset="utf-8">
<title>Trees</title>
<style>
body {
/*font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;*/
font: 11px sans-serif;
position: relative;
height: 500px;
@xzys
xzys / blackboard_downloader.py
Created February 4, 2014 15:41
Check blackboard for new lectures and documents and download regularly
from splinter import Browser
import re
import time
def download_file(url):
local_filename = url.split('/')[-1]
# NOTE the stream=True parameter
r = requests.get(url, stream=True)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
@xzys
xzys / megabus_route_planner.py
Created February 4, 2014 15:38
Allows you to look up connecting routes for Megabus
from splinter import Browser
from splinter.exceptions import *
from selenium.common.exceptions import *
from selenium.webdriver.common.keys import Keys
from collections import deque
import re
import time
import pickle
class Stop():
@xzys
xzys / dining_scraper.py
Created February 4, 2014 15:34
Looks up what food is being served today in the dining halls at Cornell University
from splinter import Browser
import time
#this part is unfinished
def get_hours(br):
br.visit('http://living.sas.cornell.edu/dine/whentoeat/')
for ea in br.find_by_css(".dineToggleControl"):
ea.click()
@xzys
xzys / wallpaper_organizer.py
Created October 17, 2013 15:22
Organizes a wallpapers folder by searching deeply and deleting duplicates and renaming files that are named the same but are different.
import os
import string
import random
def organize_wallpapers(directory=r'C:\Users\SACHIN\Pictures\Wallpapers'):
""" Delete duplicate files that are the same size, igoring *.db files.
Renames duplicately named files that are not the same size with
random id, maintaining same extension
"""
@xzys
xzys / RandomTalker.java
Created October 17, 2013 15:19
finds the most common words in a file.
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.ArrayList;
@xzys
xzys / Unsrambler.java
Created October 17, 2013 15:18
given a dictionary of words and a list of scrambled words, unscrambles the words.
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Scanner;
public class Unscrambler {
//given wordlist and dictionary, unscramble wordlist
@xzys
xzys / pdfsplitter.py
Created October 17, 2013 15:17
given some inputs, take a .pdf file and split into parts, mostly for spllitting textbooks into chapters.
from pyPdf import PdfFileWriter, PdfFileReader
def splitPDF(input_fn, output_fn, start, end):
""" extracts from input anoter pdf from start to end pages
just use the textbooks bookmarks 'edit' to figure out
where chapters end and start. It's easy from there
"""