Skip to content

Instantly share code, notes, and snippets.

@jpaugh
jpaugh / XPath in the browser.js
Created September 30, 2020 16:41
How to test XPath in the browser
View XPath in the browser.js
function iterate(i) {
var result = [];
do {
var next = i.iterateNext();
result[result.length] = next;
} while (next != null)
return result;
}
iterate(document.evaluate("//a[@href and data-mediatype]", document, null, XPathResult.ANY_TYPE))
@jpaugh
jpaugh / scrollIntoView.js
Last active July 30, 2019 20:23
An implementation of scrollIntoView which actually does the thing.
View scrollIntoView.js
/**
* function scrollIntoViewSensibly
* Author: Jonathan Paugh; MIT License
* Source: https://gist.github.com/jpaugh/265bbaadd7d3d243d2d52e558863847d
*
* Scroll the parent element until the child is visible. This is like the 'nearest' option to [Element.scrollIntoView],
* except that it actually works --- even in IE, and even when the child is partially visible already. It's not a drop-in
* replacement, though: to make a polyfil for [Element.scrollIntoView], you'd want to find the nearest scrollable parent
* yourself, and then accept that all options passed to the polyfil would be ignored.
*
@jpaugh
jpaugh / AsEnumerableVsCasting.cs
Last active April 17, 2019 14:00
Test whether AsEnumerable differs from casting regarding a hidden extension method.
View AsEnumerableVsCasting.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace AsEnumerableVsCasting
{
class AsEnumerableVsCasting
{
static void Main(string[] args)
{
@jpaugh
jpaugh / en-bcv-parser.js
Last active August 21, 2018 14:15
Human -> OSIS Bible reference parser, copied from the following, but without the function wrapper: https://raw.githubusercontent.com/openbibleinfo/Bible-Passage-Reference-Parser/master/js/en_bcv_parser.js
View en-bcv-parser.js
var bcv_parser, bcv_passage, bcv_utils, root,
hasProp = {}.hasOwnProperty;
root = self;
bcv_parser = (function() {
bcv_parser.prototype.s = "";
bcv_parser.prototype.entities = [];
@jpaugh
jpaugh / keybase.proof
Created November 15, 2017 18:45
keybase proof
View keybase.proof
### Keybase proof
I hereby claim:
* I am jpaugh on github.
* I am jpaugh (https://keybase.io/jpaugh) on keybase.
* I have a public key ASBMWiTSoNsFFtCJvDAGy8pd9WKJQjjQLuZBxbFl6ejDCwo
To claim this, I am signing this object:
@jpaugh
jpaugh / .bashrc
Created September 6, 2017 13:53
An auto-reloading .bashrc file
View .bashrc
if _BASHRC_WAS_RUN 2>/dev/null; then
:;
else # Stuff that only needs to run the first time we source .bashrc.
# Useful to allow re-sourcing new changes, without breaking/changing things in this section
alias _BASHRC_WAS_RUN=true
# ... continued ...
fi
# Last mod time of a file or files
get_file_timestamp () {
View Psalm 147
First
-----
15
He sends out his commandment to the earth.
His word runs (very) swiftly.
16
He gives snow like wool,
and scatters frost like ashes.
17
He hurls down his hail like pebbles.
@jpaugh
jpaugh / Reference.hs
Last active December 16, 2015 04:59
Creative way to represent Biblical references in Haskell.
View Reference.hs
-- |A list of `Range's. This is the comprehensive ref type, and
-- can form an arbitrarily complex reference to the scripture.
data Reference = Reference [Range] -- [ x ] means list of x's
deriving (Show, Eq)
-- |A Range of verses, or a single ref. "Range" is a bit of a misnomer,
-- since we can have a single reference "Range".
data Range
= Range
@jpaugh
jpaugh / The gist
Created June 25, 2012 13:06
The gist
View The gist
Do you catch my drift?
@jpaugh
jpaugh / OOPed-my-brain.java
Last active October 1, 2015 04:08
The night after...
View OOPed-my-brain.java
/**
* This is what happens when I try eating breakfast after having spent
* the previous night hacking away on some graphical programming.
* ActionScript 3 was the language of choice---or, urm, Haxe---but the
* code is here prescribed in Java. (ActionScript 3---or actually
* Haxe---supports all of the language constructs I use here; I just
* don't remember the syntax exactly; and, after several years using
* OOP, my brain can OOPs! without any particular language.)
*/