Skip to content

Instantly share code, notes, and snippets.

Nick Jones nrjones8

Block or report user

Report or block nrjones8

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View inline_if_else.py
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 / README.md
Last active Jul 17, 2018
BART Weekday Ridership, by Starting Station (May, 2018)
View README.md

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.

@nrjones8
nrjones8 / zero_offset_utc.php
Created Aug 24, 2016
PHP's interpretation of RFC 3339 serialization of a UTC timestamp
View zero_offset_utc.php
<?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 / pycon_notes.md
Created Apr 13, 2015
Notes from a few talks at Pycon
View pycon_notes.md

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 / abstract_statics.php
Created Mar 24, 2015
PHP's abstract static functions
View abstract_statics.php
<?php
abstract class AbstractClass {
abstract protected static function Something();
}
class GoodExtender extends AbstractClass {
protected static function Something() {
echo "something!\n";
}
@nrjones8
nrjones8 / php_56_assignment.php
Created Feb 25, 2015
invalid syntax before PHP 5.6
View php_56_assignment.php
<?php
class Foo {
private $some_var = 'concatenated ' . 'str';
}
$foo = new Foo();
@nrjones8
nrjones8 / api_client_prototype.py
Created Jan 20, 2015
A few examples of how a client would interact with ApiClient
View api_client_prototype.py
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):
View ncaa_scraper.py
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 / scp_uploader.py
Last active Aug 29, 2015
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.
View scp_uploader.py
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
You can’t perform that action at this time.