Skip to content

Instantly share code, notes, and snippets.

@sriedel
sriedel / dns_compare.rb
Last active December 18, 2020 08:33
DNS compare
#!/usr/bin/env ruby
NEW_NS_SERVER="ns-561.awsdns-06.net"
OLD_NS_SERVER="ns.udag.net"
def clean_up_answer(ns_answer)
answer_section = nil
ns_answer.match(%r{^;; ANSWER SECTION:\s*(.*?\n)\n}m) do |match|
answer_section = match[1]
end
module Memoize
def memoize(method_name)
ivar_name = :"@#{method_name}"
aliased_method_name = :"__unmemoized_#{method_name}"
alias_method aliased_method_name, method_name
define_method method_name do
return instance_variable_get(ivar_name) if instance_variable_defined?(ivar_name)
instance_variable_set(ivar_name, send(aliased_method_name))
2019-09-19 13:00:51 - [sway/main.c:152] Linux plinth 5.1.16 #1 SMP PREEMPT Fri Jul 5 21:04:54 CEST 2019 x86_64 GNU/Linux
2019-09-19 13:00:51 - [sway/main.c:168] Contents of /etc/lsb-release:
2019-09-19 13:00:51 - [sway/main.c:152] LSB_VERSION=1.4
2019-09-19 13:00:51 - [sway/main.c:152] DISTRIB_ID=Arch
2019-09-19 13:00:51 - [sway/main.c:152] DISTRIB_RELEASE=rolling
2019-09-19 13:00:51 - [sway/main.c:152] DISTRIB_DESCRIPTION="Arch Linux"
2019-09-19 13:00:51 - [sway/main.c:168] Contents of /etc/os-release:
2019-09-19 13:00:51 - [sway/main.c:152] NAME="Arch Linux"
2019-09-19 13:00:51 - [sway/main.c:152] PRETTY_NAME="Arch Linux"
2019-09-19 13:00:51 - [sway/main.c:152] ID=arch
@sriedel
sriedel / setup_vault_access
Last active January 9, 2019 11:37
Automate vault access
#!/usr/bin/bash
VAULT_USER=sr
SSH_SOCKET=$HOME/.ssh/control/vault
REMOTE_HOST=app1.staging.givve.io
VAULT_HOST=vault.givve.io
export VAULT_ADDR="https://$VAULT_HOST:8200"
export VAULT_CACERT="/home/sr/src/givve/givve/config/certs/vault_cacert.pem"
@sriedel
sriedel / db_size.rb
Created March 19, 2017 12:22
Summarize table size and index usage for a postgres database
#!/usr/bin/env ruby
require_relative '../config/environment'
class TableStats
include ActionView::Helpers::NumberHelper
OUTPUT_HEADER = sprintf "%-32s %10s %10s %10s %10s\n", "Table name", "Tuples", "Size", "#Seq. Scans", "#Index Scans"
def initialize( attrs = {} )
@attributes = attrs
@sriedel
sriedel / rc.lua
Created February 11, 2014 14:53
awesome 3.5 config
-- Standard awesome library
local awful = require("awful")
awful.autofocus = require("awful.autofocus")
awful.rules = require("awful.rules")
-- Theme handling library
local beautiful = require("beautiful")
local gears = require("gears")
-- Notification library
local naughty = require("naughty")
local vicious = require("vicious")
# Nginx+Unicorn best-practices congifuration guide. Now with SPDY!
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@sriedel
sriedel / gist:4032070
Created November 7, 2012 14:56
git lg
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
@sriedel
sriedel / ctags.excludes
Created November 5, 2012 08:32
ctags update scripts for git hooks
tmp
log
doc
coverage
app/assets/javascripts/*min.js
@sriedel
sriedel / gist:3016439
Created June 29, 2012 07:18
copy opt-out-urls from xml feed
file = File.readlines( "20120628T111327_1" )
hash = {}
pairs = file.grep( /extid|opt_out_url/ ).
map { |e| e.gsub( /<.*?>/, '' ) }.
map(&:strip)
pairs.shift
pairs.each_slice( 2 ) { |e| hash[e[0].to_i] = e[1] }
hash.delete(0)