Skip to content

Instantly share code, notes, and snippets.

@ab
ab / github-print-bookmarklet.js
Last active October 19, 2016 02:39
Github Print Bookmarklet (like others, but does not require jQuery). Paste the minified javascript: into a bookmark to use it.
/* Remove stuff from the page to make github pages pretty for printing */
console.log("Github pretty print 0.1");
function removeClassElems(name) {
console.log("looking for class:", name);
Array.from(document.getElementsByClassName(name)).forEach(function(e) {
console.log("Removing", e);
e.parentNode.removeChild(e);
});
@ab
ab / test-block.rb
Created July 5, 2017 05:05
Case study to demonstrate jruby block bug https://github.com/jruby/jruby/issues/4217
#!/usr/bin/env ruby
class Foo
attr_reader :failed
def initialize
@failed = false
end
def [](foo, &block)
@ab
ab / pixeltest.html
Created July 31, 2017 03:00
Dead pixel test page
<!doctype html>
<html>
<head>
<title>Pixel test page</title>
</head>
<body>
<div id="nav">
<a href="?black" style="color:black">black</a>
<a href="?white" style="color:white; background: gray">white</a>
<a href="?red" style="color:red">red</a>
#!/usr/bin/env python
from ddtrace import tracer
@tracer.wrap()
def traced():
return "Traced"
def not_traced():
return "Not traced"
@ab
ab / signals_test.py
Created January 13, 2021 22:29
Python script that prints pstree and loops forever, gracefully exiting on SIGINT/SIGTERM, useful for debugging process managers / deploy behavior
#!/usr/bin/env python3
import collections
import logging
import os
import psutil
import signal
import sys
import time
logger = logging.getLogger(__name__)
@ab
ab / foo.csv
Created February 24, 2021 22:21
Testing
cola b c
foo omg baz
@ab
ab / ngrok.yml
Created March 16, 2021 16:43
Ngrok config file
# ~/.ngrok2/ngrok.yml
authtoken: "<REDACTED>"
tunnels:
ecommerce_python:
proto: http
hostname: <YOUR-CUSTOM-SUBDOMAIN>.ngrok.io
addr: localhost:8101
host_header: rewrite
bind_tls: true
#!/bin/bash
set -x
cd $(git rev-parse --show-toplevel)
poetry install --no-root
#!/bin/bash
set -eo pipefail
cd "$(git rev-parse --show-toplevel)"
if [ -t 1 ]; then
opts=("--ansi")
else
opts=()
fi
#!/bin/bash
if [ $# -eq 0 ]; then
cat >&2 <<EOM
usage: poetry-shebang FILE
Install this script somewhere on your \$PATH -- such as /usr/local/bin/ -- to
be able to seamlessly run Python scripts under \`poetry run\` without having to
type that out.