Skip to content

Instantly share code, notes, and snippets.

View kernelsmith's full-sized avatar
I'm not entirely sure.

Josh kernelsmith

I'm not entirely sure.
View GitHub Profile
kernelsmith / ruby_advanced_regex_stuff.rb
Created August 16, 2022 19:50
Advanced (for me anyway) Regex stuff in the Ruby language that I often forget
View ruby_advanced_regex_stuff.rb
# Capture groups
if /(hello) (world)/ =~ "hello world"
puts "#{$2} #{$1}" # => "world hello"
# Named groups
if /(?<domain>rubycademy)/ =~ ''
puts domain # => "rubycademy"
kernelsmith / the_pentaverate.txt
Created August 11, 2021 14:45
The Pentaverate - So, I Married an Axe Murderer
View the_pentaverate.txt
Well it's a well-known fact sonny jim that there's a secret society of the five
wealthiest people in the world known as...The Pentaverate, who run everything in
the world, including the newspapers, and meet tri-annually at a secret country
mansion in colorado known as...The Meadows. The Queen, the Vatican, the Gettys,
the Rothchilds and Colonel Sanders before he went teats up. Oh I hated the colonel
with his wee beedy eyes and that smug look on his face `ohh you're gonna buy my
chicken ohhh`
- Dad how can you hate the colonel?
Because he puts an addictive chemical in his chicken that makes you crave it
fortnightly smart-arse!
kernelsmith / strip_harder.rb
Created August 5, 2021 21:08
Ruby string encoding defaults to UTF-8, but String#strip doesn't alter its definition of whitespace to match the encoding, it's always defined as: '\x00\t\n\v\f\r '. This does not include unicode whitespace no matter the string's encoding, see Ruby Regexp Character Classes for more info. It would appear that [[:space:]] does in fact include unic…
View strip_harder.rb
# This was probably encountered and overcome a long time ago, but I ran into it in my own Ruby dealings and thought maybe it could be an issue elsewhere:
# Ruby string encoding defaults to UTF-8, but String#strip doesn't alter its
# definition of whitespace to match the encoding
# String#strip removes lead/trail whitespace defined as: '\x00\t\n\v\f\r '
# null, horiz tab, line feed, vert tab, form feed, carriage return, & space
# This does not include unicode whitespace no matter the string's encoding,
# see Regexp for more info
kernelsmith /
Created February 27, 2019 17:01
to get radamsa to wait on stdin before generating the next case

Find main.scm and replace



((λ () (get-block stdin 1)))
kernelsmith /
Created May 10, 2018 00:04
decreasingly dumb ways of doing windows host discovery

Old ways of scanning for windows hosts

This is from an old presentation, I just wanted to record it somewhere. I'm not saying this stuff:

a) still works b) is a good idea c) hasn't been surpassed greatly in the last 7 years d) is completely accurate

hping & TTLs

kernelsmith / key_peele_east_west_names.rb
Created April 13, 2018 20:28
All the names, teams, schools, and East-West episode numbers for Key & Peele's East vs West ruby
View key_peele_east_west_names.rb
names = [
["D'Marcus Williums", "1", "east", "University of Georgia"],
["T.J. Juckson", "1", "east", "Wayne State University"],
["T'varisuness King", "1", "east", "Merrimack College"],
["Tyroil Smoochie-Wallace", "1", "east", "University of Miami"],
["D'Squarius Green, Jr.", "east", "University of Notre Dame"],
["Ibrahim Moizoos", "1", "east", "University of Tennessee at Chatanooga"],
["Jackmerius Tacktheritrix", "1", "east", "Michigan State University"],
["D'Isiah T. Billings-Clyde", "1", "east", "Coastal Carolina University"],
["D'Jasper Probincrux III", "1", "east", "South Carolina State University"],
kernelsmith /
Last active April 5, 2017 21:52
follow a redirect at the command line
curl -s -I $url | grep \^Location: | cut -d ':' -f 2-
# I had a longer version that continued following redirects up to a limit, but
# can't find it atm
# if you'd like to do the above anonymously, you can use and
# change the HTTP method from GET to HEAD and paste in your URL (assuming HEAD
# is supported by the webserver). In the response you'll see the
# Location: HTTP header w/the redirected URL (assuming nominal situation).
kernelsmith /
Last active February 23, 2024 17:03
Basic GPGME ruby gem usage

Basic GPGME Ruby Gem Usage

I just found this API ridiculously confusing to use, and maybe I just suck, but I don't want to figure it out again, so I'm writing it down here

Establish a gpg home dir if desired

Optional, but if you have an established gpg home dir that you want to use or you don't want it chosen for you

GPGME::Engine.home_dir = "/some/dir" # e.g. env['GNUPG_HOME']
kernelsmith /
Last active January 14, 2016 00:27
vmware tools problems such as mounting shares and kernel patches

Restart vmware tools services

  • restart the services so you can see if any fail

sudo /etc/vmware-tools/ restart

  • if failure, you can optionally check which services are actually still running

sudo /etc/vmware-tools/ status

  • but you'll want to rerun the vmware config script which will recompile kernel mods
kernelsmith /
Last active January 14, 2016 19:25
easily set ubuntu system date/time and timezone
# change this value to suit you, see below for further guidance
# Note, if you were to get this value from an argument etc, keep
# in mind it would be vulnerable to command injection
# get timezone values from `ls /usr/share/zoneinfo` if you need them
# for example, you can see there's a /usr/share/zoneinfo/US/Central and
# /usr/share/zoneinfo/America/Chicago etc