Skip to content

Instantly share code, notes, and snippets.

View oogali's full-sized avatar

Omachonu Ogali oogali

  • Ordinary Stack
  • Princeton, NJ
  • 11:26 (UTC -04:00)
View GitHub Profile
@oogali
oogali / incremental-xfer.py
Created July 29, 2013 19:46
Quick attempt at incremental transfer of individual files (that only grow in size)
#!/usr/bin/env python
import os, sys, json
import paramiko
class Transfer:
def __init__(self, srcfile, dsthost, dstdir):
self.src_file = srcfile
self.dst_host = dsthost
self.dst_dir = dstdir
@oogali
oogali / ssh-tab-completion.bash
Created July 11, 2013 13:58
Should have known better than to paste into HN...
# Tab completion for scp/sftp/ssh based on ~/.ssh/config
complete -o default -o nospace -W "$(/usr/bin/ruby -ne 'puts $_.split(/[\s,]+/)[1..-1].reject { |h| h.match /\*|\?/ } if $_.match /^\s*Host[s]*\s+/' < ~/.ssh/config)" scp sftp ssh 2>/dev/null
@oogali
oogali / uncertainty-parkway.txt
Created July 3, 2013 22:11
So, Schrodinger and Heisenberg are out driving in their car...
< aaronw> so schrodinger and heisenberg are out driving in their car
< aaronw> they get stopped and the cop says to heisenberg (the driver)
< aaronw> "hey, do you know how fast you were going?"
< aaronw> heisenberg says " no, don't tell me! "
< aaronw> the cop says "90mph". heisenberg says "thanks a lot, now I'm lost, asshole"
< aaronw> the cop, being suspicious, also goes and looks in the trunk
< aaronw> and says "hey, do you realize you have a dead cat in here?"
< aaronw> schrodinger says "well, *NOW* we do"
@oogali
oogali / 7-year-system-v1.txt
Last active December 18, 2015 05:59
Scheming on a system with enough chops (and expandable components) to last for the next 7 years.
Component Quantity Description Price
--------- -------- ----------- ------
(Motherboard) 1 SuperMicro X9DRH-7F $ 628
- 2 processors
- 16 DIMMs
- up to 512GB of registered DIMMs
- up to 128MB of unregistered DIMMs
- onboard LSI2208 HW RAID controller
- 8 x SAS 6Gb/s ports
- 2 x SATA 6Gb/s ports
@oogali
oogali / loopback-dns.py
Created June 8, 2013 11:08
Loopback DNS Server Test
#!/usr/bin/env python
import os
import sys
import json
import dns.message
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
class LoopbackDNS(DatagramProtocol):
@oogali
oogali / sched-example.py
Created June 3, 2013 15:28
Example of using sched in Python
#!/usr/bin/env python
import os
import sys
import time
import sched
def jumpoff(arg=None):
print "[%f] It's the jumpoff! (%s)" % (time.time(), str(arg))
return
@oogali
oogali / ugly-gethostbyaddr.rb
Created June 2, 2013 05:38
One-line DNS resolution of IPs
# ipv4 only
def gethostbyaddr(ip)
Socket.gethostbyaddr(ip.split('.').map(&:to_i).pack('CCCC')).first rescue ip
end
@oogali
oogali / startoftheday.pl
Created May 31, 2013 15:30
Get sunrise times?
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$city = shift || die "startoftheday <city> <state>";
$state = shift || die "startoftheday <city> <state>";
@time = localtime;
$year = $time[5] + 1900;
@oogali
oogali / snmpresolve.c
Created May 31, 2013 15:28
Convert ASCII OIDs to numeric -- I guess I did not know about snmptranslate at the time
/*
* Copyright (c) 2006 Omachonu Ogali <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@oogali
oogali / tnt-port-count.c
Created May 31, 2013 15:25
Get MAX-TNT port count/status
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#define ADMIN_UP 1
#define ADMIN_DOWN 2
#define ADMIN_REMOVED 3