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 / 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 / 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 / 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 / pyserial.py
Created June 27, 2014 05:56
Testing out pySerial library to communicate serially with Arduino over USB.
import serial, time
ser = serial.Serial('/dev/cu.usbmodem411', 9600)
while True:
bin = bytes(chr(5), encoding = 'ascii')
print(bin)
ser.write(bin)
time.sleep(2)
@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
@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 / 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 / Expect_FTP.tcl
Last active August 29, 2015 14:03
Expect Script that automatically grabs Ephemeris data from server via Telnet
#!/usr/bin/expect
set env(TERM) no-resize-vt100
set timeout 15
set START_DATE "2014-Jun-26 03:00"
set END_DATE "2014-Jun-26 03:20"
set TIME_STEP "1m"
set M_BODY 301
spawn telnet horizons.jpl.nasa.gov 6775
expect "Horizons> " {send "load JMCCM-1\r"}
expect "Horizons> " {send "$M_BODY\r"}
@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);