Skip to content

Instantly share code, notes, and snippets.

View rpgraham84's full-sized avatar

Robert Graham rpgraham84

View GitHub Profile
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function walkDOM(rootNode) {
let start = 0;
let end = 0;
let spanLength = 0;
let text = "";
let nodeText = "";
let mappings = [];
function recurse(node, pathStack) {
//console.log("\t".repeat(pathStack.length), node, start, end, pathStack);
if ((node.nodeType === 3) && (typeof node.textContent !== "undefined")) {

Keybase proof

I hereby claim:

  • I am rpgraham84 on github.
  • I am robertpgraham (https://keybase.io/robertpgraham) on keybase.
  • I have a public key whose fingerprint is AB77 D012 8661 E1AE 02A7 5EE7 D78C 3C3A 4941 5609

To claim this, I am signing this object:

#!/usr/bin/env bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
#1 @ 55,885: 22x10
#2 @ 102,14: 23x14
#3 @ 539,327: 21x22
#4 @ 429,353: 14x25
#5 @ 232,934: 29x11
#6 @ 796,785: 17x18
#7 @ 508,96: 11x18
#8 @ 83,289: 28x23
#9 @ 291,46: 21x17
#10 @ 505,954: 23x15
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import division, print_function
from operator import add, sub
from itertools import cycle
from functools import reduce
"""
Fun little script for approximating pi. Inspired my Matt Parker's
@rpgraham84
rpgraham84 / best_trade.py
Last active August 28, 2018 19:13
Find best trade example
from random import randint
def best_trade(closes):
size = len(closes)
if size < 2:
return 'Input must contain at least 2 prices.'
best = (-1, 0, 0)
right = closes[-1]
@rpgraham84
rpgraham84 / roman_numerals.py
Created August 11, 2018 18:15
Convert integers to roman and vice-versa
import re
numerals = {"M": 1000, "CM": 900, "D": 500, "CD": 400, "C": 100,
"XC": 90, "L": 50, "XL": 40, "X": 10, "IX": 9, "V": 5,
"IV": 4, "I": 1}
r = re.compile('|'.join(sorted(numerals.keys(), key=len, reverse=True)))
def to_roman(n, s=''):
#!/usr/bin/env python3.6
import os
import sys
import time
import string
import random
import requests
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
@rpgraham84
rpgraham84 / hnsort.es6
Last active March 21, 2018 00:27
Hacker News sort by best
'use strict';
// This let statement selects elements from the HTML document using a CSS selector.
// Specifically, we're making an Array of all table rows (each news listing is
// a table row in an html table). The css selector here says, find the 'tr' elements
// that are nested at any depth below a tbody which is nested at any depth below any
// element bearing the class 'itemlist' -- the dot in front of itemlist indicates
// we're talking about a CSS class, not an element.
// Look up css selectors and the document.querySelectorAll
// function for more about that.