Skip to content

Instantly share code, notes, and snippets.

View tyrelsouza's full-sized avatar

Tyrel Souza tyrelsouza

View GitHub Profile
@tyrelsouza
tyrelsouza / kickle_complete.lua
Created August 8, 2015 20:53
Kickle Cubicle detect when level complete FCEUX LUA script
emu.speedmode("normal") -- Set the speed of the emulator
-- It's 00B1 on the rom I have, might differ/
local MEM_ADDR = tonumber("00B1", 16)
local completed_level = false;
while true do
-- Execute instructions for FCEUX
local mem_val = memory.readbyte(MEM_ADDR)
if (mem_val == 1) then
#!/usr/bin/env python
''' Get a list of out-of-date packages from a pip requirements.txt file. '''
import itertools
import json
import requests
import sys
import yaml
@tyrelsouza
tyrelsouza / clipboard-gitbranch.sh
Last active August 29, 2015 14:21
Copy git branch to your clipboard (needs xsel or pbcopy installed)
function cpbr {
if branch=$(git symbolic-ref --short -q HEAD)
then
if command -v pbcopy 2>/dev/null; then
printf "$branch" | pbcopy
echo "$branch copied to your clipboard using pbcopy"
elif command -v xsel 2>/dev/null; then
printf "$branch" | xsel --clipboard
echo "$branch copied to your clipboard using xsel"
else
@tyrelsouza
tyrelsouza / import_keys.sh
Created May 12, 2015 20:05
Get GPG keys from Keybase
#!/bin/bash
keybase list-tracking | while read -r line ; do
if [ -n "$line" ]; then
curl -s https://keybase.io/$line/key.asc | gpg --with-fingerprint | sed -n 's/.*=//p' | awk 'NF>1{print $(NF-3)$(NF-2)$(NF-1)$(NF) }' | while read -r key; do
echo "Trying $line's key: $key"
gpg --recv-key $key
echo
done
fi
done
@tyrelsouza
tyrelsouza / import_keys.py
Last active August 29, 2015 14:21
Import Keybase Keys you are Tracking into GnuPG
import gnupg
import urllib
from subprocess import Popen, PIPE
import os
from pprint import pprint
def get_names():
p = Popen(['keybase', 'list-tracking'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
Verifying I am +tyrel on my passcard. https://onename.com/tyrel

Developer Cheat Sheets

This are my cheat sheets that I have compiled over the years. Tired of searching Google for the same things, I started adding the information here. As time went on, this list has grown. I use this almost everyday and this Gist is the first bookmark on my list for quick and easy access.

I recommend that you compile your own list of cheat sheets as typing out the commands has been super helpful in allowing me to retain the information longer.

@tyrelsouza
tyrelsouza / Download_All_Git_Repos.rb
Last active May 3, 2016 17:18
Get all repositories
#!/usr/bin/env ruby
require 'highline/import'
require 'io/console'
require 'octokit'
# Return true or false if the directory exists
def directory_exists?(directory)
File.directory?(directory)
end
@tyrelsouza
tyrelsouza / get_weather.py
Created December 3, 2013 23:24
Get Weather from worldweatheronline api.
import urllib2
import json
import re
def getWeather(self, area_dirty="Keene, NH"):
"""
Returns the current weather in a given location
"""
API_KEY = "API KEY HERE"
#try:
@tyrelsouza
tyrelsouza / gist:3455038
Created August 24, 2012 19:59
calculate distance on unit sphere with lat long
def distance_on_unit_sphere(lat1, long1, lat2, long2):
#http://www.johndcook.com/python_longitude_latitude.html
degrees_to_radians = math.pi/180.0
phi1 = (90.0 - lat1)*degrees_to_radians
phi2 = (90.0 - lat2)*degrees_to_radians
theta1 = long1*degrees_to_radians
theta2 = long2*degrees_to_radians
cos = (math.sin(phi1)*math.sin(phi2)*math.cos(theta1 - theta2) +
math.cos(phi1)*math.cos(phi2))
try: