Skip to content

Instantly share code, notes, and snippets.

View jnrbsn's full-sized avatar

Jonathan Robson jnrbsn

View GitHub Profile
@jnrbsn
jnrbsn / better-gist-styles.css
Created September 14, 2010 01:24
Better styles for embedding GitHub Gists
/* Better styles for embedding GitHub Gists */
.gist{font-size:13px;line-height:18px;margin-bottom:20px;width:100%}
.gist pre{font-family:Menlo,Monaco,'Bitstream Vera Sans Mono','Courier New',monospace !important}
.gist-meta{font-family:Helvetica,Arial,sans-serif;font-size:13px !important}
.gist-meta a{color:#26a !important;text-decoration:none}
.gist-meta a:hover{color:#0e4071 !important}
@jnrbsn
jnrbsn / GPL.md
Last active April 29, 2023 14:59
A Markdown-formatted GPL for your GitHub projects.

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

@jnrbsn
jnrbsn / get_stock_price.py
Last active November 8, 2020 18:51
Get latest price of stocks, ETFs, mutual funds, etc.
import json
from concurrent.futures import ThreadPoolExecutor, as_completed
from urllib.parse import urlencode
from urllib.request import Request, urlopen
def get_latest_price_single(ticker):
url = f'https://query1.finance.yahoo.com/v8/finance/chart/{ticker}'
params = {
'region': 'US',
@jnrbsn
jnrbsn / Jonathan_Robson_Resume.md
Created December 12, 2012 15:10
A Markdown version of my resume.

Jonathan Robson

8918 W 64th Pl, Apt 203 / Merriam, KS 66202
816-200-7301 / jnrbsn@gmail.com

Objective

To obtain a position working with web technologies that leverages my skills,

# Fatality rate of coronavirus outside China [1]
corona_fatal_rate = (3168 - 2945) / (92880 - 80152)
# Cases in USA [1]
corona_cases_usa = 118
# Population of USA [2]
population_usa = 329346645
# "Infection rate" of coronavirus in USA
corona_infect_rate = corona_cases_usa / population_usa
# Fatality rate of flu in USA [3]
# (average of 5 most recent seasons for which there's data 2012-2017)
@jnrbsn
jnrbsn / privatemethod.py
Last active May 30, 2018 08:26
Python decorator for making an instance method private
import inspect
def privatemethod(func):
"""decorator for making an instance method private"""
def func_wrapper(*args, **kwargs):
"""decorator wrapper function"""
outer_frame = inspect.stack()[1][0]
if 'self' not in outer_frame.f_locals or outer_frame.f_locals['self'] is not args[0]:
raise Exception('%s.%s is a private method' % (args[0].__class__.__name__, func.__name__))
func(*args, **kwargs)
@jnrbsn
jnrbsn / gist:4268258
Created December 12, 2012 14:40
Loads a JavaScript file asynchronously with a callback, like jQuery's `$.getScript()` except without jQuery.
function j(u, c) {
var h = document.getElementsByTagName('head')[0], s = document.createElement('script');
s.async = true; s.src = u;
s.onload = s.onreadystatechange = function () {
if (!s.readyState || /loaded|complete/.test(s.readyState)) {
s.onload = s.onreadystatechange = null; if (h && s.parentNode) { h.removeChild(s) } s = undefined;
if (c) { c() }
}
};
h.insertBefore(s, h.firstChild);
@jnrbsn
jnrbsn / gist:8062545
Created December 20, 2013 22:18
Install Python 2.7, easy_install, and pip on Amazon Linux
sudo yum update
sudo yum install python27
curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo /usr/bin/python27
sudo easy_install pip
echo "alias python='python27'" >> ~/.bashrc
source ~/.bashrc
@jnrbsn
jnrbsn / sleep.java
Created May 28, 2013 14:13
Sleep in Java
try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); }
@jnrbsn
jnrbsn / Outy.php
Created December 19, 2012 03:56
Objected-oriented command line output library for PHP.
<?php
/**
* Objected-oriented command line output library for PHP.
*
* Dependencies:
* - Console_Color PEAR package
* - Bash
*
* PHP version 5
*