Skip to content

Instantly share code, notes, and snippets.

View MadBomber's full-sized avatar
💭
I may be slow to respond.

Dewayne VanHoozer MadBomber

💭
I may be slow to respond.
View GitHub Profile
@MadBomber
MadBomber / application_record.rb
Created May 22, 2023 14:41
Auto-connection switching between read and write database
# app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
# When true, the database automatically switches connections
@@auto_switch_connection = true
# returns the name of the read replica if one is defined in database.yml, otherwise returns :primary
def self.reading_db
@MadBomber
MadBomber / increase_root_fedora.md
Created December 27, 2022 14:29 — forked from 181192/increase_root_fedora.md
How to increase the root partition size on Fedora

How to increase the root partition size on Fedora

Boot up with an Fedora Live USB stick.

  1. Run vgs to check if there's any space:
$ sudo vgs
  VG     #PV #LV #SN Attr   VSize    VFree
  fedora   1   3   0 wz--n- <237.28g    0 
@MadBomber
MadBomber / # crystal-lang - 2018-06-18_16-32-06.txt
Created June 18, 2018 21:40
crystal-lang on 4.16.15-300.fc28.x86_64 - Homebrew build logs
Homebrew build logs for crystal-lang on 4.16.15-300.fc28.x86_64
Build date: 2018-06-18 16:32:06
@MadBomber
MadBomber / madbomber_kernel_maybe.rb
Created July 19, 2013 17:28
fuzzy conditional
module MadBomber
module Kernel
# When if and unless seem too black and white, use maybe
#
# Usage:
#
# maybe(some_condition, 50) do
# puts "When some_condition is true, 50% of the time print this message"
# end
@MadBomber
MadBomber / normalize_pathnames.rb
Created October 28, 2012 03:07
Normalize file and directory names
#!/bin/env ruby
###########################################
###
## File: normalize_pathnames.rb
## Desc: renames directory and file names such that any
## embedded special characters are translated to an underscore.
#
$debug = ARGV.include?('-d') || ARGV.include?('--debug')
$changed = 0
@MadBomber
MadBomber / extract_fav_gems.rb
Created December 4, 2011 00:39
A way to manage RubyGems worthy of investigation using Twitter's Favorite tweets
#!/bin/env ruby
###############################################
## extract_fav_gems.rb
## An html file obtained from twitter.com is passed
## on the command line. The file is the favorite tweets
## of a specific user. Tweets from RubyGems are reviewed
## abd the gem name extracted. If the gem is not currently
## installed it will be nominated for installation. Gems
## are not installed automatically. The gem install command
## line containing the nominated gems is printed to stdout
@MadBomber
MadBomber / debug_web_service.rb
Created November 2, 2011 17:29
A Sinatra process for setting the value of global debug variables during the execution of a process.
########################################################################
## debug_web_service.rb
## A sinatra web application provides an embedded web service for setting
## global variables that include 'debug' in their name
##
## Usage:
## Inside of an event-machine run loop (if Thin is used) or in a new Thread do this ...
##
## DebugWebService::Gui.run!( :ip => '0.0.0.0', :port => 4567 )
##
@MadBomber
MadBomber / summarize_all_gems.rb
Last active September 27, 2015 19:08
A Tool to List GEM Summaries
#!/bin/env ruby
############################################################################
## summarize_all_gems.rb
class NilClass
def split(*args)
[" "]
end
def strip
""
@MadBomber
MadBomber / gist:417429
Created May 28, 2010 17:13
A tool to print the labeled value of variables edi
##################################################
## debug_me.rb
## A tool to print the labeled value of variables.
## Works with local, instance and class variables.
## Example usage:
=begin
debug_me # Prints only the header banner consisting of tag, method name, file name and line number
debug_me('INFO') # Also prints only the header but with a different tag
debug_me {} # prints the default header and __ALL__ variables
debug_me {:just_this_variable} # prints the default header and the value of only one specific variable