Skip to content

Instantly share code, notes, and snippets.

View rhenning's full-sized avatar
👻

Richard Henning rhenning

👻
View GitHub Profile
@rhenning
rhenning / x509_cert_scan.rb
Last active August 29, 2015 13:59
Script to read information from remote X509 certificates
#!/usr/bin/env ruby
require 'openssl'
require 'socket'
require 'timeout'
DEFAULT_PORT=443
CONNECT_TIMEOUT=5
targets = ARGV.empty? ? ARGF : ARGV
filetype plugin on
filetype indent on
syntax enable
colorscheme desert
set background=dark
set expandtab
set smarttab
set shiftwidth=2
set tabstop=2
@rhenning
rhenning / entity_users.js
Last active August 29, 2015 14:07
Mongo aggregations and date to ObjectId
// run like: nohup mongo --quiet neat_prod > entity_users.js
days_ago = 120
date_after = new Date(new Date().setDate(new Date().getDate() - days_ago))
secs_after = Math.floor(date_after.getTime() / 1000)
oid_after = ObjectId(secs_after.toString(16) + "0000000000000000")
rs.slaveOk()
c = db.entities.find(
@rhenning
rhenning / gist:899c77ba618752fd43c6
Last active August 29, 2015 14:09
Mongo Date ObjectId helpers
var daysAgo = 10;
Date.prototype.toObjectId = function() {
var dateSecs = Math.floor(this.getTime() / 1000);
return ObjectId(dateSecs.toString(16) + "0000000000000000");
}
function daysAgoToDate(daysAgo) {
return new Date(new Date().setDate(new Date().getDate() - daysAgo));
}
#!/usr/bin/env bash
awk '/proftp.*successful/ { print $7 }' /var/log/secure{,.?} \
| cut -f1 -d\[ \
| tr -d '(' \
| sort \
| uniq \
| while read ip ; do
echo flushing $ip from banlist...
for chain in fail2ban-{,REPEAT-}SFTP ; do

Keybase proof

I hereby claim:

  • I am rhenning on github.
  • I am rhenning (https://keybase.io/rhenning) on keybase.
  • I have a public key whose fingerprint is 71FE AC16 2CFD 4F14 4779 4541 5326 CF40 1F9E 17BB

To claim this, I am signing this object:

@rhenning
rhenning / passpack2onepassword.rb
Created July 8, 2015 17:36
Passpack to 1Password CSV converter
require 'csv'
# PASSPACK_CSV_FIELDS = %i[
# title
# username
# password
# url
# tags
# notes
# email
@rhenning
rhenning / gist:b54f12514ca4bbabf65a
Created July 22, 2015 17:44
Mongo embedded array push test
require 'moped'
require 'benchmark'
s = Moped::Session.new(%w(127.0.0.1:27017))
s.use 'junkdb'
s.drop
s[:test].insert(foo: [])
Benchmark.bm do |b|
@rhenning
rhenning / rhenning.zsh-theme
Created October 5, 2012 19:31
My zsh theme
# Hack of robbyrussell's theme, with RVM & Git indicators, but no host indicator
# Example:
# ✻ currentdir rvm:rubyversion@gemset git:branchname ✗
# Get the current ruby version in use with RVM:
if [ -e ~/.rvm/bin/rvm-prompt ]; then
RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:%{$fg[cyan]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%}%{$reset_color%} "
else
if which rbenv &> /dev/null; then
RUBY_PROMPT_="%{$fg_bold[blue]%}rbenv:%{$fg[cyan]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg_bold[blue]%}%{$reset_color%} "
@rhenning
rhenning / id_rsa_neat.pub
Created November 3, 2012 19:37
Rich's neat ssh public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCb1Rl3cfJNrppD1JH+ItXN5Hq/IBv6SNTEk1k1Gd8/j4nm05wPtpMDxnwYgt+g8VgVvwRc9v4Ff9I7O+jTU8OOJEGR0wMqb9URhaSbJhQ+hpElg7iWGPudxDGUR9ivyMEII7IlJCFPK2BqxRxdGoZ2IMgSfmntrRo9fTreO7g6maKV1DRgZtO8eSdPc6fPybuVyPMSt3VwPJIkHFXO7dezRrvFheei8MYdscsJxlXBgdGYYbfk2KBR2eCJzmYxLXXnirIriKXtAy4YYNOM/YBxfIwkdcq1RAgo5IdcN32TEoMxbt2+ykYnJBzECJn6A4of1eh27YAklHQzNl0KnwRf rhenning@neat.com