Skip to content

Instantly share code, notes, and snippets.

@tyrelsouza
tyrelsouza / plugin.py
Created April 27, 2012 03:59 — forked from anonymous/plugin.py
Da bikebot code
import bcrypt
import redis
import re, os
import urllib2
import json
import time
import datetime
import supybot.conf as conf
import supybot.utils as utils
from supybot.commands import *
@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:
@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 / 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

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.

Verifying I am +tyrel on my passcard. https://onename.com/tyrel
@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)
@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 / 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
#!/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