Skip to content

Instantly share code, notes, and snippets.

View bird.conf
log syslog all;
router id **MY_IP**;
protocol bgp vultr {
local as 395409;
source address **MY_IP**;
import none;
export all;
graceful restart on;
@kyledrake
kyledrake / http.cr
Created Jun 20, 2016
Crystal HTTP Benchmark
View http.cr
# A very basic HTTP server
require "http/server"
server = HTTP::Server.new(8080) do |context|
context.response.content_type = "text/plain"
context.response.print "Hello world"
end
puts "Listening on http://0.0.0.0:8080"
server.listen
View internet_radio_stream_aliases.sh
# 1. Install mplayer command line (via Brew, Macports, or APT)
# 2. Add the following aliases to ~/.profile
# 3. Type `source ~/.profile`
# 3. Type `news` or `current` to listen in your terminal
alias news="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/news.pls" # MPR News
alias current="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/the_current.pls" # The Current
alias classical="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/classical.pls" # Classical MPR
alias localcurrent="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/local.pls" # Local Current
alias heartland="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/radio_heartland.pls" # MPR Radio Heartland
@kyledrake
kyledrake / config.ru
Created Oct 14, 2015
Puma "reverse proxy" debugging wackiness
View config.ru
# puma -p 31337 -q
require 'net/http'
run Proc.new { |env|
uri = URI('http://127.0.0.1:80/')
response = nil
Net::HTTP.start(uri.host, uri.port) do |http|
View curl commands
$ curl -kvv --tlsv1.2 https://sni.nakamura.io:4567/
* Trying 127.0.0.1...
* Connected to sni.nakamura.io (127.0.0.1) port 4567 (#0)
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
@kyledrake
kyledrake / ipfs-refs-daemon.sh
Last active Aug 18, 2019
IPFS replication service with one line of unix shell code!
View ipfs-refs-daemon.sh
#!/bin/bash
# First, install ncat: http://nmap.org/ncat/
# Usually comes with the 'nmap' package on distributions.
ncat -k -v -l -p 5555 -c 'ipfs refs local | gzip'
# To retrieve on the client machine:
# nc 127.0.0.1 5555 | gunzip | ipfs pin add -r
@kyledrake
kyledrake / paypal.rb
Last active Aug 29, 2015
A not-crazy Paypal REST API interface.
View paypal.rb
# Everything else was worse...
# https://developer.paypal.com/docs/api/
require 'rest_client'
require 'addressable/uri'
require 'thread'
class Paypal
OAUTH2_IS_INCREDIBLY_SHITTY_COMEDY_TIME_PADDING = 10
SANDBOX_URI = Addressable::URI.parse 'https://api.sandbox.paypal.com/v1'
LIVE_URI = Addressable::URI.parse 'https://api.paypal.com/v1'
@kyledrake
kyledrake / boring.rb
Created Apr 5, 2015
Neocities boring web site detector
View boring.rb
require 'rmagick'
require 'pry'
$filtered_sites = []
def web_site_too_blank?(path)
img = Magick::Image.read(path).first
pix = img.scale(1, 1)
average_color = pix.pixel_color(0,0)
@kyledrake
kyledrake / gist:d7457a46a03d7408da31
Last active Feb 20, 2022
Creating a self-signed SSL certificate, and then verifying it on another Linux machine
View gist:d7457a46a03d7408da31
# Procedure is for Ubuntu 14.04 LTS.
# Using these guides:
# http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/
# https://turboflash.wordpress.com/2009/06/23/curl-adding-installing-trusting-new-self-signed-certificate/
# https://jamielinux.com/articles/2013/08/act-as-your-own-certificate-authority/
# Generate the root (GIVE IT A PASSWORD IF YOU'RE NOT AUTOMATING SIGNING!):
openssl genrsa -aes256 -out ca.key 2048
openssl req -new -x509 -days 7300 -key ca.key -sha256 -extensions v3_ca -out ca.crt
View gist:3af997f6f58d4d58f728
# Example xorg.conf.d snippet that assigns the touchpad driver
# to all touchpads. See xorg.conf.d(5) for more information on
# InputClass.
# DO NOT EDIT THIS FILE, your distribution will likely overwrite
# it when updating. Copy (and rename) this file into
# /etc/X11/xorg.conf.d first.
# Additional options may be added in the form of
# Option "OptionName" "value"
#
Section "InputClass"