Skip to content

Instantly share code, notes, and snippets.

@kirkelifson
kirkelifson / keybase.md
Created January 12, 2015 17:33
Keybase verification

Keybase proof

I hereby claim:

  • I am kirkelifson on github.
  • I am kirkelifson (https://keybase.io/kirkelifson) on keybase.
  • I have a public key whose fingerprint is 7C6C 9C5D 6CCA 5950 D216 627C 8825 A623 5817 B4C8

To claim this, I am signing this object:

@kirkelifson
kirkelifson / all_nil.rb
Created November 6, 2015 08:11
rails: all_nil? -- returns true if list of object attributes are nil
def all_nil?(object, *options)
options.map { |item| object.send(item) }.compact.empty?
end
@kirkelifson
kirkelifson / generate_params.rb
Created January 28, 2016 19:56
Generates a list of params straight from the database schema
#!/usr/bin/env ruby
# Usage: generate_params.rb [/path/to/db/schema.rb] [table name]
# By: Kirk Elifson <kirk [at] parodybit [dot] net>
def print_usage
puts "", "\tUsage: ruby generate_params.rb /path/to/db/schema.rb table_name", ""
exit
end
print_usage if ARGV.length != 2
@kirkelifson
kirkelifson / meta.rb
Created February 20, 2016 05:59
Map relation containing id and model to instances
# Example:
# approvable_id = 7
# approval_type = "Finding"
# Finding.find(7) is yielded
Approval.pluck(:approvable_id, :approvable_type).sort.uniq.map { |id, type| Object.const_get(type).find(id) }.count
@kirkelifson
kirkelifson / select_columns.rb
Created July 10, 2016 14:40
Selects all column names containing phone and not containing type
phones = Model.attribute_names.select { |c| c.include? 'phone' }.reject { |c| c.include? 'type' }.map(&:to_sym)
@kirkelifson
kirkelifson / signalflare-update.rb
Last active December 1, 2016 02:44
Quick update to signalflare using API v4 wrapper
require 'rubyflare'
ip = { content: `curl -s https://ifconfig.co`.chomp }
zone_name = "parodybit.net"
hostnames = ['host1.parodybit.net', 'host2.parodybit.net', 'host3.parodybit.net']
email = 'EMAIL-HERE'
api_key = 'API-KEY-HERE'
cloudflare = Rubyflare.connect_with(email, api_key)
zone_id = cloudflare.get('zones').results.select{ |z| z[:name] == zone_name }.first[:id]
@kirkelifson
kirkelifson / gist:331c833bc3f562319cdd8f74cac235ce
Created March 13, 2017 23:53
bad words according to crown royal
<input type="hidden" id="bad_words_list" class="input-text" value="absofuckinlutely,ahole,badass,anus,arse,a55,as5,a5s,arsehole,ash0les,asholes,ass,asss,a$$$,a$$,assbag,assbandit,biiiach,biiach,assbanger,assbite,assclown,asscock,asscracker,asses,peckerhead,pussy,fucckk,gay,fuucckk,fucckkk,fucck,nigguh,hairydick,dickhead,niggah,assface,assfuck,assfucker,assgoblin,sh!t,assh0le,assh0lez,fuc,fuk,asshat,ass-hat,nigga,niga,asshead,dick beaters,b1tch,motherfucker,fagit,asshole,assholes,assholz,asshopper,ass-jabber,assjacker,fkkin,fkkn,asslick,asslicker,assmonkey,assmunch,assmuncher,assnigger,nigger,asspirate,ass-pirate,assshit,assshole,asssucker,asswad,asswipe,azzhole,bampot,bassterds,bastard,bastards,bastardz,basterds,basterdz,beaner,biatch,biotch,bitch,bitchass,bitches,bitchs,bitchtits,bitchy,blowjob,blowjob,blowjobs,boffing,recktum,rectum,renob,retard,rimjob,ruski,cunt, cunts,cock,sadist,sandnigger,sandnigger,scank,schlong,screwing,scrote,scrotum,seamen,semen,sex,sexual,sexualtoy,sexuallypopularwoman,sh1ter,sh1ts
@kirkelifson
kirkelifson / distraction.html
Created May 3, 2017 15:38
Knightsec Distraction Channel
<meta charset="UTF-8"><title>Knightsec™ Distraction Channel</title>
<style>
a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}table{border-collapse:collapse;border-spacing:0}
#watermark
{
position:fixed;
bottom:8%;
right:8%;
opacity:0.5;
@kirkelifson
kirkelifson / drive_space.rb
Created June 2, 2017 21:55
Reports remaining drive space for each specified drive (Windows)
require 'filesize'
require 'win32ole'
drive_list = ["D:", "H:"]
file_system = WIN32OLE.new("Scripting.FileSystemObject")
drives = file_system.Drives
drives.each do |drive|
next unless drive_list.include? drive.Path
file = File.open("#{drive.Path}//drive_status.txt", "w")
@kirkelifson
kirkelifson / rspec-all-day.rb
Last active March 31, 2019 03:45
rspec all day - simple test runner for finding fragile tests
#!/usr/bin/env ruby
require 'json'
require 'awesome_print'
require 'colorize'
class SpecRunner
FILE_NAME = "spec_run_#{Time.now.strftime("%H%M%S_%m%d%y_%Z")}.log"
TEST_LOG_FILE = 'log/test.log'.freeze
LOG_FILE_SIZE_LIMIT = 500