Skip to content

Instantly share code, notes, and snippets.

View eiginn's full-sized avatar

Ryan Carter eiginn

View GitHub Profile
### Keybase proof
I hereby claim:
* I am eiginn on github.
* I am vaelen (https://keybase.io/vaelen) on keybase.
* I have a public key ASBjfgXRP1BqaOkL9ncUzgIEG4rC042DYANLR1O98BroGgo
To claim this, I am signing this object:
@eiginn
eiginn / remerge.py
Created April 11, 2017 22:59 — forked from mahmoud/remerge.py
Recursively merging dictionaries with boltons.iterutils.remap. Useful for @hynek's configs. https://twitter.com/hynek/status/696720593002041345
"""
This is an extension of the technique first detailed here:
http://sedimental.org/remap.html#add_common_keys
In short, it calls remap on each container, back to front, using the accumulating
previous values as the default for the current iteration.
"""
CREATE OR REPLACE VIEW bloat AS
SELECT
schemaname, tablename, reltuples::bigint, relpages::bigint, otta,
ROUND(CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages/otta::numeric END,1) AS tbloat,
relpages::bigint - otta AS wastedpages,
bs*(sml.relpages-otta)::bigint AS wastedbytes,
pg_size_pretty((bs*(relpages-otta))::bigint) AS wastedsize,
iname, ituples::bigint, ipages::bigint, iotta,
ROUND(CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages/iotta::numeric END,1) AS ibloat,
CASE WHEN ipages < iotta THEN 0 ELSE ipages::bigint - iotta END AS wastedipages,
@eiginn
eiginn / dhcpd.conf
Created April 21, 2016 03:38 — forked from robinsmidsrod/dhcpd.conf
Trying to chainload iPXE with full feature set from a lesser featured one, whilst still being able to boot non-supported cards with UNDI
ddns-update-style none;
deny bootp; #default
authoritative;
include "/etc/dhcp/ipxe-option-space.conf";
# GREEN
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.100 10.1.1.199;
option subnet-mask 255.255.255.0;
#!/usr/bin/env python
# GistID: 3285baf647fd1403ce18
import sys
from netaddr import IPNetwork, cidr_merge, AddrFormatError
CF_ANYCAST_NETS = []
lines = []
if len(sys.argv) > 1:
with open(sys.argv[1]) as f:
for line in f.readlines():
#!/usr/bin/python
# GistID: 1a3b938ba1f28ab18e6b
#
# List all Namespaces (works for Ubuntu 12.04 and higher)
#
# (C) Ralf Trezeciak 2013-2014
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@eiginn
eiginn / netstat.py
Last active December 16, 2015 20:33
#!/usr/bin/env python
# GistID: 9017260c676865aa6551
import re
import sys
TCP_EXTRACTOR = re.compile(r"""^\s*
(\d+):\s # sl - 0
([\dA-F]{8}(?:[\dA-F]{24})?):([\dA-F]{4})\s # local address and port - 1 y 2
([\dA-F]{8}(?:[\dA-F]{24})?):([\dA-F]{4})\s # remote address and port - 3 y 4

Keybase proof

I hereby claim:

  • I am eiginn on github.
  • I am vaelen (https://keybase.io/vaelen) on keybase.
  • I have a public key whose fingerprint is 8A3E D651 77CE 5F2C BFAC 1DED 1515 297F D2AB AD8D

To claim this, I am signing this object:

import ConfigParser, mmap
config_file = "/usr/share/applications/google-chrome.desktop"
add_string_to_each_section = ["StartupWMClass", "Google-chrome-stable"]
option = add_string_to_each_section[0]
value = add_string_to_each_section[1]
class Fixer:
def check(self, cf, option, value):
# Kyoto Cabinet
_kchashmgr() {
local cur prev
local commands="create inform set remove get list import copy dump load defrag setbulk removebulk getbulk check version" # not include: clear
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
arg1=${COMP_WORDS[1]}
if [ $COMP_CWORD -eq 1 ]; then