Skip to content

Instantly share code, notes, and snippets.

GitRay

Block or report user

Report or block GitRay

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@GitRay
GitRay / parker_square.py
Created Jan 15, 2018
Parker Square! :) # Randomly try to get lucky and find a magic square with all square numbers. # Idea came from here: https://www.youtube.com/watch?v=G1m7goLCJDY
View parker_square.py
## Parker Square! :)
# Randomly try to get lucky and find a magic square with all square numbers.
# Idea came from here: https://www.youtube.com/watch?v=G1m7goLCJDY
import sys, random, pprint
rand = random.SystemRandom()
square_size = 3
square_step_x = list(range(square_size))
@GitRay
GitRay / inauguration_script.py
Created Jan 5, 2018
Find proximity of inauguration day to MLK
View inauguration_script.py
import calendar
# Martin Luther King, Jr. Day was established in 1986, so the first presidential inauguration to be affected was
# George Bush I on Jan 20, 1989. King's birthday was the 15th, but we celebrate it on the 3rd Monday of each January.
# So, to me, the interesting days would be when MLK is on the 19th, 20th, or 21st.
# Let's go until the year 2089, just to get a full 100-year period since MLK started.
start_year = 1989
end_year = 2089
@GitRay
GitRay / restart_shutdown_watcher.py
Last active Mar 27, 2017
Reset/Shutdown switch for Raspberry Pi
View restart_shutdown_watcher.py
#!/usr/bin/env python2.7
# This script is meant to be used to monitor a button on the
# Raspberry Pi. I connected the button between pins 13 and 14,
# chosen because BCM 27 is not used for anything else and it is
# right next to a ground, so I can use a single connector.
#
# If the button is pressed breifly (less than 5 seconds), the Pi
# will reboot. If the button is held down longer, it will shut down (halt).
# After a halt, you will need to cycle power to restart.
#
@GitRay
GitRay / serialize.py
Last active May 24, 2019 — forked from mrocklin/serialize.py
Serialization benchmark
View serialize.py
# This has been edited to work with python3. Some of the tested combinations will not work in python2.
import pandas as pd
df = pd.DataFrame({'text': [str(i % 1000) for i in range(1000000)],
'numbers': range(1000000)})
import pickle
# Python 3 has no cPickle
#import cPickle
import json
from functools import partial
@GitRay
GitRay / convert_to_divx.py
Last active Dec 14, 2015
Python script to convert any video file into a number of other kind of files: DIVX-compatible file no more than 640x480 in size, MP4 that works with the original iPhone/iPod no more than 480x320 in size, and MP4 that works with the Kindle Fire HD no more than 1280x800 in size. You can hardcode subtitles if you want. Limitations: ffmpeg v1 is req…
View convert_to_divx.py
#!/usr/local/bin/python
# convert any video file recognized by ffmpeg to divx
import subprocess, json, argparse, tempfile, os
import pprint
# Check arguments
parser = argparse.ArgumentParser(description="Convert any video file recognized by ffmpeg into a legacy DIVX")
parser.add_argument('--iphone',help='Convert to iPhone-compatible mp4 instead of Divx',action='store_true')
parser.add_argument('--kindlefirehd', help='Convert to Kindle Fire compatible mp4 instead of Divx', action='store_true')
parser.add_argument('--subtitles', help='Name of subtitles file to burn into video.')
You can’t perform that action at this time.