Skip to content

Instantly share code, notes, and snippets.

View j-mcc1993's full-sized avatar

James McCullough j-mcc1993

  • Bay Area & San Diego, CA
View GitHub Profile
@j-mcc1993
j-mcc1993 / Fractal.java
Created June 27, 2014 05:39
Java Fractal Image Generator
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
public class Fractal {
public static void main(String[] args) {
int width = 2048/2;
int height = 1536/2;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
@j-mcc1993
j-mcc1993 / postbyhour.py
Last active July 16, 2020 17:19
Reddit Top Post-Time Histogram
#!/usr/local/bin/python3.5
import datetime
import praw
import numpy
import matplotlib.pyplot as plt
# Constant values
hours_in_day = 24
pacific_time_offset = 7
@j-mcc1993
j-mcc1993 / imgur_test.py
Last active July 16, 2020 17:12
Reddit Scraper 2.0 with Imgur API
#!/usr/local/bin/python3.5
import datetime
import os
import praw
import pprint
import urllib2
from imgurpython import ImgurClient
from sys import argv
@j-mcc1993
j-mcc1993 / GaryMemeBot.py
Last active June 26, 2020 04:23
A reddit bot that crawls r/ucsd looking for posts about Gary Gillespie.
#!/usr/local/bin/python3.5
import praw
import random
# Delicious Memes
memes = [
"""Gary "The Transfer Crusher" Gillespie\n\nGary "Caught A Scrub on
Github" Gillespie\n\nGary "The Great Wall Of CS" Gillespie\n\nGary
"Bitches Don't Know About My Wine App" Gillespie\n\nGary "Be Scared If
################################################################################
################################################################################
## ------------------------------------------------------------------------ ##
## | The PKA podcast downloader! Downloads all the PKA podcasts directly to | ##
## | external drive. | ##
## ------------------------------------------------------------------------ ##
## ------------------------------------------------------------------------ ##
## | | ##
## | ####### ## ## ### ###### | ##
## | ## ## ## ## ## ## ######## | ##
@j-mcc1993
j-mcc1993 / Arduino_SNES_Controller.ino
Last active January 1, 2016 23:28
Arduino Sketch that handles serial communication between SNES controller and Arduino board.
int latch = 7; //signals controller to latch button states
int pulse = 5; //toggle to shift out button states
int data = 9; //data in line
int data_byte; //byte that stores button states
int count[] = {0,0,0,0,0,0,0,0,0,0,0,0}; //each value stores 1 or 0 indicating
//whether a key is currently pressed
char keys[] = {'a','b','s','d','u','j','l','r','w','e','t','y'}; //keyboard keys to be pressed
int tempbit; //iterates over the data_byte to grab each button's state
void setup() {
pinMode(latch, OUTPUT);
@j-mcc1993
j-mcc1993 / Quick_Reddit_Scraper.py
Last active January 1, 2016 21:39
A script that traverses a supplied number of links on the "hot" page of the supplied subreddit and downloads all posted images (with some corner cases).
import urllib.request, os, praw, datetime
from bs4 import BeautifulSoup
from sys import argv
script, sub, lim = argv
r = praw.Reddit(user_agent = 'RedditScraper1.0 by /u/I_Am_Treebeard')
subreddit = r.get_subreddit(sub)
directory = '/Users/admin/desktop/%s (%s)' % (sub, datetime.date.today())
if not os.path.exists(directory): os.makedirs(directory)
collectpath = directory + '/All_Pictures'
@j-mcc1993
j-mcc1993 / Arduino_NES_Controller.ino
Last active January 1, 2016 21:19
Arduino Sketch that handles serial communication between NES controller and Arduino
int latch = 7; //signals controller to latch button states
int pulse = 5; //toggle to shift out button states
int data = 9; //data in line
int data_byte; //byte that stores button states
int count[] = {0,0,0,0,0,0,0,0}; //each value stores 1 or 0 indicating whether a key is currently pressed
char keys[] = {'a','b','s','d','u','j','l','r'}; //keyboard keys to be pressed
int tempbit; //iterates over the data_byte to grab each button's state
void setup() {
pinMode(latch, OUTPUT);
@j-mcc1993
j-mcc1993 / LED_BYTE_CALCULATOR.ino
Created June 27, 2014 05:52
Arduino sketch that turns 8 LEDs into a byte adder using two buttons.
const int pot = A15;
const int pushButton = 22;
const int pushButton2 = 27;
int bitList[8] = {
};
int pinSet[] = {
13,11,9,7,5,3,14,16};
byte sensorValue = 0;
int op1;
int op2;
@j-mcc1993
j-mcc1993 / Telnet_Ephemeris.sh
Created June 27, 2014 05:55
Short Shell Script that runs expect script to grab Ephemeris data and stores output into files with unique names.
#!/bin/sh
EPHEMFILE=Ephem_Data_$(date "+%Y-%m-%d|%H-%M-%S").txt
OUTFILE=Output_$(date "+%Y-%m-%d|%H-%M-%S").txt
./expect_ftp.sh >/dev/null
READ=$(ls|grep .*\.15)
cat $READ > $OUTFILE
cat $OUTFILE | sed -n '/$$SOE/,/$$EOE/p' | sed -e 's/\$.*//' -e '/^$/ d' > $EPHEMFILE
cat "$EPHEMFILE"
rm $READ