Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@havenwood
havenwood / enumerator-memoized.rb
Created May 7, 2020 15:57
A memoized enumerator
# frozen_string_literal: true
class Enumerator
class Memoized < Enumerator
INTERRUPT = defined?(IRB::Abort) ? IRB::Abort : Interrupt
private_constant :INTERRUPT
module Refinement
refine Enumerable do
def memoized
@havenwood
havenwood / cache.rb
Created March 20, 2020 20:13
Another example for xco on #ruby IRC
require_relative 'tuple_space'
class Cache
def initialize
@memory = TupleSpace.new(reaper_period_in_secs: 10, expires_in_secs: 60)
end
def get(request)
@memory[request]
end
@smammy
smammy / macOS-IPv6-Tunnel-DNS-HOWTO.md
Created December 13, 2018 19:14
How to convince macOS to do IPv6 DNS lookups when your only IPv6 address is via a VPN or tunnel of some sort

This was a huge hassle to figure out, so I wrote up a little guide in hopes that others would find it helpful:

How to convince macOS to do IPv6 DNS lookups when your only IPv6 address is via a VPN or tunnel of some sort

The Problem

macOS's domain name resolver will only return IPv6 addresses (from AAAA records) when it thinks that you have a valid routable IPv6 address. For physical interfaces like Ethernet or Wi-Fi it's enough to set or be assigned an IPv6 address, but for tunnels (such as those using utun interfaces) there are some extra annoying steps that need to be taken to convince the system that yes, you indeed have an IPv6 address, and yes, you'd like to get IPv6 addresses back for DNS lookups.

I use wg-quick to establish a WireGuard tunnel between my laptop and a Linode virtual server. WireGuard uses a utun user-space tunnel device to make the connection. Here's how that device gets configured:

@mrmartineau
mrmartineau / stimulus.md
Last active April 19, 2024 09:41
Stimulus cheatsheet
FROM debian:jessie
MAINTAINER Zachary Carter "carterza@gmail.com"
RUN REPO=http://cdn-fastly.deb.debian.org && \
echo "deb $REPO/debian jessie main\ndeb $REPO/debian jessie-updates main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update --yes && apt-get install --yes \
automake \
@umardx
umardx / Openvswitch LTS in CentOS 7.md
Last active December 6, 2022 13:50
Installation Openvswitch LTS in CentOS 7

Based on this post: https://n40lab.wordpress.com/2016/03/02/openvswitch-lts-in-centos-7 The most recent release from the LTS series: http://openvswitch.org/releases/openvswitch-2.5.4.tar.gz

Instructions:

As the root user let’s install some packages:

yum -y install wget openssl-devel gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool python-twisted-core python-zope-interface PyQt4 desktop-file-utils libcap-ng-devel groff checkpolicy selinux-policy-devel
@jkullick
jkullick / block-tor-exit-nodes-iptables.md
Last active March 29, 2024 08:05
Block Tor Exit Nodes with IPTables
  1. Install ipset:
apt-get install ipset
  1. Create new ipset:
ipset create tor iphash
require "rubocop"
module RuboCop
module Cop
module Lint
# This cop checks bad use of the Minitest `assert` method
#
# `assert` method's second argument is the error message when the
# first argument evals to false.
#
@ianmetcalf
ianmetcalf / mithril-debounce.js
Last active February 4, 2016 19:54
Delay redraw for debounced events,based on https://www.npmjs.com/package/debounce
import m from 'mithril';
import now from 'date-now';
export default function debounce(func, wait = 100, immediate = false) {
let context, args, timestamp, timeout, result;
function debounced() {
context = this;
args = arguments;
timestamp = now();