Skip to content

Instantly share code, notes, and snippets.

@nrjones8
nrjones8 / scp_uploader.py
Last active August 29, 2015 13:56
Simple Sublime Text 2 plugin to sync local files with remote ones via SCP. A simple workaround for lack of a free SFTP library that could be extended/made more robust.
import sublime, sublime_plugin
import sys
# Sublime has its own embedded Python interpreter -- we need to tell it explicitly
# to find installed 3rd party libraries (like paramiko)
PYTHON_PACKAGES_PATH = '/Library/Python/2.7/site-packages'
sys.path.append(PYTHON_PACKAGES_PATH)
from paramiko import SSHClient
from scp import SCPClient
import bs4 as bs
import requests as r
import re
import pandas as pd
ESPN_BASE_URL = 'http://scores.espn.go.com'
NCAA_BASE_URL = 'http://scores.espn.go.com/ncb/scoreboard'
SCORE_RE = r'[0-9]*\-[0-9]*$'
TIMESTAMP_RE = r'[0-9]*:[0-9]*$'
@nrjones8
nrjones8 / api_client_prototype.py
Created January 20, 2015 21:27
A few examples of how a client would interact with ApiClient
class MatchedResponseCode(object):
def __init__(self, expected_status_codes, status_code):
self.expected_status_codes = expected_status_codes
self.status_code = status_code
self.codes_handled = set()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, exc_tb):
@nrjones8
nrjones8 / php_56_assignment.php
Created February 25, 2015 19:50
invalid syntax before PHP 5.6
<?php
class Foo {
private $some_var = 'concatenated ' . 'str';
}
$foo = new Foo();
@nrjones8
nrjones8 / abstract_statics.php
Created March 24, 2015 02:15
PHP's abstract static functions
<?php
abstract class AbstractClass {
abstract protected static function Something();
}
class GoodExtender extends AbstractClass {
protected static function Something() {
echo "something!\n";
}
@nrjones8
nrjones8 / pycon_notes.md
Created April 13, 2015 18:46
Notes from a few talks at Pycon

Building Secure Systems -- lvh

  • High level
  • Bugs --> security bugs --> particularly bad
  • "Tools" don't work for security
  • Unit tests don't catch it
  • Using some software...read the docs?
  • Google/SO don't always have best answers
  • Good practice ~= bad practice
  • Process is different in security:
    • Install it
@nrjones8
nrjones8 / zero_offset_utc.php
Created August 24, 2016 17:03
PHP's interpretation of RFC 3339 serialization of a UTC timestamp
<?php
$timezone = new \DateTimeZone('UTC');
$needed_time = new \DateTime('2019-11-06 18:20:56', $timezone);
echo $needed_time->getTimezone()->getName() . "\n";
echo $needed_time->format(DATE_RFC3339) . "\n";
// Output (note the +00:00 instead of "Z")
// UTC
@nrjones8
nrjones8 / README.md
Last active July 17, 2018 05:51
BART Weekday Ridership, by Starting Station (May, 2018)

The above visualization breaks down all weekday rides on BART by their starting station. Clicking on an individual station will zoom in, showing the distribution of destination stations for that starting station.

BART provides monthly ridership data for all stations pairs - i.e. the average number of people who rode from station A to station B. They publish these datasets on their website in .xlsx format. Those files are combined into one flat CSV in a separate repo, which is where the data used in this visualization came from.

word = 'ravenclaw'
house = \
'Gryffindor' if 'gryffindor' in word else \
'Hufflepuff' if 'hufflepuff' in word else \
'Ravenclaw' if 'ravenclaw' in word else \
'Slytherin' if 'slytherin' in word else \
'some default value'
print house
@nrjones8
nrjones8 / parse_mn_covid_prison_image.py
Last active April 18, 2020 01:58
Parsing number of COVID-19 cases from MN Department of Corrections website, which provides data as an image of a table.
"""
Used image from 4/17/2020 at https://mn.gov/doc/assets/2020.04.17%20public%20COVID%20testing%20chart_tcm1089-425186.JPG
Context: https://twitter.com/seathebass92/status/1251184468066533376?s=20
Output looks like:
>> python parse_mn_image.py
Full string is:
Total 59 16 40 3 37 10 2 o
Parsed 16 positive cases from mn_prison_covid_table_from_website.jpeg