Skip to content

Instantly share code, notes, and snippets.

View jbylund's full-sized avatar

Joseph Bylund jbylund

View GitHub Profile
#!/usr/bin/python
import argparse
from getpass import getuser
import json
import os
import readline # not to be confused with the builtin
import sys
import time
import sqlite3
from json import loads as json_loads
import requests
import time
class Windfinder(object):
def __init__(self):
self.cache = {}
self.threshold = 3 * 60
def get_uncached(self, location):
#!/usr/bin/python
import datetime
from math import sin, pi, cos, atan2, asin, tan, acos
import requests
# https://www.timeanddate.com/sun/@z-us-02118
def get_julian_day(dtobj, longitude):
Y, M, D = [float(x) for x in (dtobj.year, dtobj.month, dtobj.day)]
#!/usr/bin/python
# my pid and instance uniquely identify myself
import os
import random
import sys
import threading
import time
import boto3
from botocore.errorfactory import ClientError
@jbylund
jbylund / gnome_terminal_colors.py
Created January 24, 2017 21:23
Silly script to update the colors of gnome terminal to be uniformly spaced around the wheel.
#!/usr/bin/python
from gi.repository import Gio, GLib
class Color(object):
def __init__(self, red, green, blue):
self.red = red
self.green = green
self.blue = blue
#!/usr/bin/python
"""Get the set of instance id's (exclude spot instances)!"""
import boto3
import datetime
import json
import redis
import sys
import base64
VERSION = 0.2
#!/usr/bin/python
"""
Something that's kind of sort of like a multiprocessing pool, but is designed for heterogenously sized tasks
"""
import math
import multiprocessing
import random
import sys
import time
import Queue
export workdir=$(mktemp -d)
(
cd $workdir
wget http://ftpmirror.gnu.org/parallel/parallel-latest.tar.bz2
tar -xf parallel-latest.tar.bz2
cd $(find . -maxdepth 1 -mindepth 1 -type d)
./configure
make -j $(grep -c processor /proc/cpuinfo)
sudo --non-interactive make install
)
@jbylund
jbylund / hash_partition.py
Created December 12, 2015 01:50
Hash Partition some number of files... to be patched up some.
#!/usr/bin/python
import argparse
import hashlib
import json
import multiprocessing
import os
import re
import resource
import subprocess
import urllib
@jbylund
jbylund / date_range.py
Created December 8, 2015 14:19
Date range logic
class DateRange(object):
start_of_time = datetime.date.min
end_of_time = datetime.date.max
def __init__(self, start=start_of_time, end=end_of_time):
if type(start) != type(DateRange.start_of_time):
self.start = datetime.datetime.strptime(start, '%Y-%m-%d').date()
else:
self.start = start
if type(end) != type(DateRange.end_of_time):
self.end = datetime.datetime.strptime(end, '%Y-%m-%d').date()