Skip to content

Instantly share code, notes, and snippets.

View pstjean's full-sized avatar

Peter St.Jean pstjean

View GitHub Profile
@pstjean
pstjean / pingover.sh
Created February 18, 2021 20:17
Print pings with times over a certain number of milliseconds
#!/bin/bash
# Usage: ./pingover.sh google.com 5
# Based on default format of BSD ping shipped with macOS
ping $1 | awk -F '[= ]' "(\$10 >= $2)"
@pstjean
pstjean / cookieobject.js
Created October 8, 2020 14:54
Create an object containing all cookies in a document
Object.fromEntries(
document.cookie
.split(";")
.map(cookie => cookie.match(/([^=\s]+)=(.*)/).slice(1, 3)),
)
@pstjean
pstjean / checknvm.sh
Created January 2, 2019 21:16
Compare current version of node to nvmrc
git rev-parse --is-inside-work-tree > /dev/null 2>&1 && git ls-files $(git rev-parse --show-toplevel) | grep -q nvmrc
nvmrc_exist=$?
if [ $nvmrc_exist -eq 0 ]
then
node_ver=$(node --version | sed 's/^v//')
nvm_ver=$(cat $(git rev-parse --show-toplevel)/.nvmrc)
if [ $node_ver = $nvm_ver ]
then
printf "$node_ver"
exit 0
@pstjean
pstjean / rxjs-from-scratch.js
Last active December 19, 2018 21:34
RxJS from scratch
// From André Staltz's talk at ng-europe 2016
// https://www.youtube.com/watch?v=uQ1zhJHclvs
function map(transformFn) {
const inputObservable = this; // Object created by createObservable
const outputObservable = createObservable(function subscribe(outputObserver) {
inputObservable.subscribe({ // Give me data from the inputObservable
next: function (x) {
const y = transformFn(x);
outputObserver.next(y);
@pstjean
pstjean / keybase.md
Created August 19, 2016 18:44
Keybase Verification

Keybase proof

I hereby claim:

  • I am pstjean on github.
  • I am pstjean (https://keybase.io/pstjean) on keybase.
  • I have a public key whose fingerprint is 0D53 110C 83D2 C131 3226 1494 7979 B907 A88B 863E

To claim this, I am signing this object:

@pstjean
pstjean / .songfmtrc
Last active February 28, 2016 19:44
Format song lyrics with Vim
# Trim punctuation and whitespace from EOL
let @a='%s/[.|,|;|:][ \t]*$//g'
# Uppercase first letter of each line
let @b='%s/^\([a-z]\)/\U\1/g'
@pstjean
pstjean / uncontrol.js
Last active August 29, 2015 13:59
Remove gfycat controls
document.addEventListener('DOMContentLoaded', function(){
var gfyVid = document.getElementsByClassName('gfyVid')[0];
gfyVid.setAttribute('width','600px');
gfyVid.setAttribute('height','337px');
gfyContainer = gfyVid.parentNode;
var controls = gfyContainer.childNodes;
for(var control in controls) {
if(controls[control] instanceof HTMLElement) {
if(!controls[control].classList.contains("gfyVid")) {
gfyContainer.removeChild(controls[control]);
@pstjean
pstjean / gist:8299501
Last active January 2, 2016 11:49
Solarized for JSONView
/*
Solarized-ish theme for JSONView
https://github.com/gildas-lormeau/JSONView-for-Chrome
*/
body {
white-space: pre;
font-family: monospace;
background-color: #002b36;
color: #839496;
import simplejson
import sqlalchemy
from sqlalchemy import String
from sqlalchemy.ext.mutable import Mutable
class JSONEncodedObj(sqlalchemy.types.TypeDecorator):
"""Represents an immutable structure as a json-encoded string."""
impl = String
@pstjean
pstjean / .gitignore_global
Created November 20, 2013 15:20
Global gitignore file for OS X
# IntelliJ Files
.idea/
*.iml
*.iws
# Vim Files
*~
*.swp
*.swo