Skip to content

Instantly share code, notes, and snippets.

@montycheese
montycheese / delete_extra.py
Last active August 29, 2015 14:04
Delete files with multiple versions
import os, glob
path = "/Users/mowong/Documents/Thumbnails/Big_Thumbnail_Project" # update to current dir
list = ["1","3","4"] #append here the version number(s)
for x in list:
for files in glob.glob("/Users/mowong/Documents/Thumbnails/Big_Thumbnail_Project/*-0%s.jpg" % x):
os.remove(files)
@montycheese
montycheese / BlackJack.py
Last active August 29, 2015 14:06
Black Jack game
from random import randint
import datetime
score = 100
round = 1
#date and time included in high scores
now = datetime.datetime.now()
today = datetime.date.today()
numericalDate = "%d/%d/%d" % (today.day, today.month, today.year)
@montycheese
montycheese / CheckRedditKarma.py
Last active August 29, 2015 14:07
Reddit Comment and Karma checker
import requests, webbrowser
def get_reddit_user_info(username):
url = "https://www.reddit.com/user/%s.json" % username
r = requests.get(url)
json_data = r.json()
#op = json_data['data']['children'][0]['data']['link_author']
#individualpost = json_data['data']['children'][0]['data']
@montycheese
montycheese / SubredditTracker.py
Created October 21, 2014 02:53
Subreddit ranking tracker
import requests, webbrowser
def get_frontpage_info():
url = "http://www.reddit.com/.json"
r = requests.get(url)
json_data = r.json()
try:
@montycheese
montycheese / SortingAlgorithms.java
Created November 3, 2014 04:58
Sorting Algorithms
import java.util.Scanner;
public class SortingAlgorithms {
public static void main(String[] args) {
int[] anArray = {2, 3, 1, 5, 6, 33, 10, 15, 16, 4, 7, 1000};
int searchTerm;
System.out.println("Starting array");
for (int x = 0; x < anArray.length; x ++)
System.out.printf("%d ", anArray[x]);
@montycheese
montycheese / calculator.py
Last active August 29, 2015 14:10
Calculator with Tinkter GUI
from Tkinter import *
from math import *
from time import sleep
import webbrowser
class Calculator():
def __init__(self):
self.root = Tk()
self.root.wm_title("Montana's Calculator")
@montycheese
montycheese / acronym.py
Created January 14, 2015 15:50
Acronym expander
abbvr = {
"lol": "laugh out loud",
"dw": "don't worry",
"hf": "have fun",
"gg": "good game",
"brb": "be right back",
"g2g": "got to go",
"wtf": "what the fuck",
"wp": "well played",
"gl": "good luck",
@montycheese
montycheese / pharm_analysis.py
Last active August 29, 2015 14:17
Analysis of Pharmaceutical web scraping results
import os
#File extensions to scrape
EXT = '.txt'
#filter out files to parse within entire directory
files = [
file for file in os.listdir('.')
if os.path.isfile(file)
and file.endswith('.txt')
and file.startswith('no_')
@montycheese
montycheese / ReverseInt.php
Last active August 29, 2015 14:20
Reversing an integer in PHP with pure tail recursion
function reverseInt($n){
return reverseIntAcc(0, $n);
}
function reverseIntAcc($acc, $n){
if ($n == 0){
return $acc;
}
$acc *= 10;
return reverseIntAcc($acc + ($n % 10) , floor($n / 10));
@montycheese
montycheese / decisionTree.js
Created July 2, 2015 04:16
Customer service decision tree in javascript
<script>
$(document).ready( function () {
$('#customerTripsTable').DataTable();
$('#customerNotesTable').DataTable();
} );
//reset all children nodes in tree if the parent is clicked
document.getElementById("contacttype").onclick = destroyChildren;
//listener for contact type dropdown
document.getElementById("contacttype").onchange = function() {
var selected = document.getElementById("contacttype").value;