Skip to content

Instantly share code, notes, and snippets.

@Radcliffe
Radcliffe / pandas-plot-example.ipynb
Created June 1, 2018 06:25
Plotting a dataframe using Pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Radcliffe
Radcliffe / pop.sh
Last active May 16, 2018 14:54
Bash script to move downloaded files into current directory.
#!/bin/bash
# This script moves files from the Download directory to the current directory.
# Usage examples:
# pop - move the most recently downloaded file.
# pop 3 - move the three most recently downloaded files.
downloads=$HOME/Downloads
n=1
if [ "$1" != "" ]; then
n=$1
@Radcliffe
Radcliffe / a268305.py
Last active February 3, 2018 03:26
A268035: a(n) is the smallest integer m such that each of the numbers m, 2*m, 3*m, ..., n*m is the sum of two successive primes.
"""
Author: David Radcliffe (2018-02-02)
I am interested in numbers that are sums of two successive primes:
5, 8, 12, 18, 24, 30, 36, 42, 52, 60, 68, 78, 84, 90, 100, ...
Note that 2+3=5, 3+5=8, 5+7=12, 7+11=18, and so on.
This is sequence A001043 in the On-Line Encyclopedia of Integer Sequences.
@Radcliffe
Radcliffe / fizzbuzz.bas
Created January 10, 2018 02:30
FizzBuzz in BASIC
10 PRINT "1"
20 PRINT "2"
30 PRINT "Fizz"
40 PRINT "4"
50 PRINT "Buzz"
60 PRINT "Fizz"
70 PRINT "7"
80 PRINT "8"
90 PRINT "Fizz"
100 PRINT "Buzz"
@Radcliffe
Radcliffe / scrape-7-eleven.py
Created December 1, 2017 02:05
Python web scraper to get a list of 7-Eleven locations in the US
# Download a list of all 7-Eleven stores in the United States.
# WARNING: The source data is inaccurate!
# Presented at PyMNtos, 2017-11-30
import requests
import csv
import time
import bs4
@Radcliffe
Radcliffe / merge_lists.py
Created August 6, 2017 02:26
Merge lists maintaining order
# Merge multiple lists of distinct elements into a single list, maintaining the order within each list.
# The result is a list of distinct elements, consisting of the union of the elements in the constituent lists.
# If A precedes B in one of the input lists, then A must precede B in the result.
# If this is not possible, then None is returned.
from collections import defaultdict
# Class to represent a graph - adapted from http://www.geeksforgeeks.org/topological-sorting-indegree-based-solution/
class Graph:
@Radcliffe
Radcliffe / keybase.md
Created July 16, 2017 21:13
keybase.io proof of identity

Keybase proof

I hereby claim:

To claim this, I am signing this object:

# Filename: pick_state.py
# To run this file, type
# python pick_state.py
# in a terminal window.
# This script requires the file us_states.txt which is available at
# https://gist.github.com/Radcliffe/7a3e0fe2efc0a9aeb523abfac67865db
import csv
@Radcliffe
Radcliffe / us_states.txt
Last active May 26, 2017 04:47
List of US States
StateCode|StateName|StateDate
AK|Alaska|1959-01-03
AL|Alabama|1819-12-14
AR|Arkansas|1836-06-15
AZ|Arizona|1912-02-14
CA|California|1850-09-09
CO|Colorado|1876-08-01
CT|Connecticut|1788-01-09
DE|Delaware|1787-12-07
FL|Florida|1845-03-03
@Radcliffe
Radcliffe / inaugural-emotions.csv
Last active January 20, 2017 22:34
Emotion analysis of inaugural adresses 1789-2017 using IBM Watson's AlchemyLanguage API
year name fear sadness joy anger disgust
1789 Washington 0.431542 0.212422 0.297166 0.155104 0.456401
1793 Washington 0.170726 0.110822 0.080267 0.238734 0.51617
1797 Adams 0.482235 0.498792 0.538104 0.094651 0.475888
1801 Jefferson 0.592254 0.539775 0.523261 0.139209 0.172762
1805 Jefferson 0.658992 0.230946 0.508855 0.136953 0.441134
1809 Madison 0.407716 0.46959 0.503345 0.398835 0.168831
1813 Madison 0.410416 0.496523 0.167754 0.422014 0.508343
1817 Monroe 0.184481 0.188871 0.550531 0.132109 0.445847
1821 Monroe 0.135458 0.258702 0.540292 0.135676 0.441433