Skip to content

Instantly share code, notes, and snippets.

@kenbellows
kenbellows / removeOverlay.js
Last active February 7, 2020 04:25
JavaScript code and bookmarklet to cancel annoying "Please disable ad blocker" overlays that cover the page and disable scrolling
// find the element in the body with max z-index
// adapted from this StackOverflow answer by Jimmy Chandra:
// https://stackoverflow.com/a/1118216/470925
let max, maxVal = 0
document.querySelectorAll('body *').forEach(el => {
// get position and zIndex style values for the element
const {position, zIndex} = document.defaultView.getComputedStyle(el)
// skip statically positioned elements
if (position !== 'static') {
// parse the string value of zIndex into an integer, defaulting to 1,
@kenbellows
kenbellows / git-shortcuts.sh
Last active March 7, 2022 14:56
Git shorcuts for bash
# simple aliases
alias gA="git add -A"
alias gc="git commit"
alias gcm="git commit -m"
alias gcam="git commit -am"
alias gcp="git cherry-pick"
alias gcob="git checkout -b"
alias gb="git branch --show-current"
alias gp="git push"
@kenbellows
kenbellows / bashrc.sh
Created June 19, 2019 15:30
My base bashrc file
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
alias ls="ls --color=auto"
alias l=ls
alias ll="ls -l"
alias la="ls -a"
@kenbellows
kenbellows / vimrc.vim
Created June 14, 2019 14:31
My simple vimrc
if $SSH_CONNECTION
colo torte
endif
syntax on
filetype plugin on
" stop trying to be vi; you're vim, goddammit, start acting like it!
set nocompatible
@kenbellows
kenbellows / .pythonrc.py
Last active August 14, 2019 14:26
Python Interpreter Setup
"""
Custom evironment setup for the python interpreter
Usage:
1. Save to ~/.pythonrc (name doesn't matter, *rc is just convention)
2. Point the PYTHONSTARTUP environment variable to your file; e.g. for bash, add
the following to your ~/.bashrc or ~/.profile:
export PYTHONSTARTUP=~/.pythonrc
"""
@kenbellows
kenbellows / boolean_lambdas.js
Last active September 28, 2017 13:10
A JavaScript implementation of Boolean logic in the Lambda calculus
/**
* Implementing Boolean Logic in the Lambda Calculus: A JavaScript Demo
*
* (Inspiration: https://youtu.be/eis11j_iGMs)
*
* It turns out that it's entirely possible in the lambda calculus to define
* the Boolean values TRUE and FALSE in functional terms as lambdas, which
* is pretty cool.
*
* Once you've done that, it's also possible to define the Boolean operators as
@kenbellows
kenbellows / log-binary-tree.js
Created April 17, 2017 21:04
Log a binary tree data structure to the console
/**
* Recursively print a binary tree data structure
* @param {function} printFn function used to print output; called with a single string argument
* @param {object} node current node object
* @param {string|function} leftKey name of current node's left child property, or a function that accepts the
* current node and returns the left child node
* @param {string|function} rightKey name of current node's right child property, or a function that accepts the
* current node and returns the right child node
* @param {string|function} displayKey property to display, or a function that returns a display string
* @param {string} [indent=''] current indentation string; mostly used to build up indentation across levels
@kenbellows
kenbellows / goWayback.js
Created March 15, 2017 20:55
Bookmarklet: See archive.com's most recent copy of the current page from the Wayback Machine
// minified code for pasting into a bookmarklet:
javascript:(function(){var a="https://web.archive.org/web/";if(window.loadTimeData)location.href=a+window.loadTimeData.data_.summary.failedUrl;else document.location=a+document.location})()
// full, unminified code with comments
/**
* Summary:
* Append the current location URL to a base Archive.org Wayback Machine URL and navigate there
*
* Example:
@kenbellows
kenbellows / console_nonsense.js
Created April 5, 2016 16:46
Drop some pretty crazy stuff in your browser console
var cycles = 5, range = 60,
shadows = [], y = 0;
for (var i=0; i<cycles*360; i+=5.4) {
var x = Math.floor(Math.sin(i/3 * (Math.PI/180)) * range),
color = 'hsl('+(i%360).toFixed(1)+', 100%, 50%)';
shadows.push([x+'px', (y++)+'px', color].join(' '));
}
var css = "font-size: 40px; text-shadow: "+shadows.join(',');
console.log('%cDidn\'t know you could do this, did you?'+(new Array(Math.ceil(cycles*1.5))).fill('\n').join(''), css)
@kenbellows
kenbellows / fiddle.css
Last active March 7, 2016 20:43
Simple HTML table with sorting, filtering, and pagination implemented with Angular.js
.pointer-cursor {
cursor: pointer;
}
#people-table {
table-layout: fixed;
}
#filter {
margin: 0;