Skip to content

Instantly share code, notes, and snippets.

@rabbitt
rabbitt / port-scanner.py
Created April 27, 2020 17:35
Rudimentary port scanner using scapy and half-open connections
#!/usr/bin/env python
import socket
from scapy.all import IP, TCP, ICMP, sr1, RandShort
# only emit warning about scapy not being permitted once
scapy_warning_emitted = False
def get_port_name(port):
try:
@rabbitt
rabbitt / threadsafe-logger-active_support-v3.2.22.1.patch
Last active April 15, 2016 18:39
ActiveSupport threadsafe logger patch for v3.2.22.1
diff -Nabur ./benchmarkable.rb /Users/rabbitt/work/repos/rails/activesupport/lib/active_support/benchmarkable.rb
--- ./benchmarkable.rb 2016-04-15 14:38:20.000000000 -0400
+++ /Users/rabbitt/work/repos/rails/activesupport/lib/active_support/benchmarkable.rb 2016-04-15 13:43:10.000000000 -0400
@@ -46,10 +46,11 @@
# Silence the logger during the execution of the block.
#
def silence
- old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger
+ if logger
+ logger.silence(::Logger::ERROR) { yield }
#!/usr/bin/env ruby
def try_require(name, version=nil)
gem name, version if version
require name
rescue LoadError
if version
STDERR.puts "Unable to load gem #{name} (#{version})"
STDERR.puts "to install, type: gem install #{name} -v '#{version}'"
else
@rabbitt
rabbitt / erb-test
Created November 5, 2015 15:56
Erb file command line tester
#!/usr/bin/env ruby
def try_require(name, version=nil)
gem name, version if version
require name
rescue LoadError
if version
puts "Unable to load gem #{name} (#{version})"
puts "to install, type: gem install #{name} -v '#{version}'"
else
@rabbitt
rabbitt / check_logfile
Last active April 26, 2018 12:07
nagios script to check log files
#!/usr/bin/env bash
PROGRAM="$(/bin/basename "$0")"
REVISION="1.0.0"
STATE_OK=0
STATE_CRITICAL=2
STATE_UNKNOWN=3
revision_details() {
@rabbitt
rabbitt / client-cache-search_path.patch
Last active September 25, 2015 04:36
initial (extremely hacky) patch for pgbouncer that caches the last search_path set on the client socket.
diff --git a/include/varcache.h b/include/varcache.h
index 4984b01..d363fb0 100644
--- a/include/varcache.h
+++ b/include/varcache.h
@@ -5,7 +5,8 @@ enum VarCacheIdx {
VTimeZone,
VStdStr,
VAppName,
- NumVars
+ VSearchPath,
@rabbitt
rabbitt / Portfile
Last active August 29, 2015 14:25
nginx portfile adding +subs variant (which compiles in http://wiki.nginx.org/HttpSubsModule)
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 135802 2015-05-03 21:53:49Z cal@macports.org $
PortSystem 1.0
name nginx
version 1.9.0
categories www mail
platforms darwin
license BSD
@rabbitt
rabbitt / keybase.md
Created May 28, 2015 15:25
keybase.md

Keybase proof

I hereby claim:

  • I am rabbitt on github.
  • I am rabbitt (https://keybase.io/rabbitt) on keybase.
  • I have a public key whose fingerprint is 57E9 5B37 E083 2817 C44D A4B5 9839 AF7E 8BAB DE41

To claim this, I am signing this object:

OS Version:
CentOS release 6.5 (Final)
GLIBC RPMS:
glibc-headers-2.12-1.149.el6_6.4.x86_64
glibc-2.12-1.149.el6_6.4.x86_64
glibc-devel-2.12-1.149.el6_6.4.x86_64
glibc-common-2.12-1.149.el6_6.4.x86_64
Ghost Checker:
@rabbitt
rabbitt / schema_clone.py
Last active October 8, 2020 12:56
PostgreSQL schema cloner (including data).
import psycopg2 as pg
from io import BytesIO
from collections import defaultdict
from contextlib import contextmanager
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED
READ_COMMIT = ISOLATION_LEVEL_READ_COMMITTED
AUTO_COMMIT = ISOLATION_LEVEL_AUTOCOMMIT