Skip to content

Instantly share code, notes, and snippets.

View trueheart78's full-sized avatar
πŸ’–

Josh Mills trueheart78

πŸ’–
View GitHub Profile
@trueheart78
trueheart78 / junklet.rb
Last active July 9, 2024 15:37
Junklet RSpec Support File
# All credit to Dave Brady & his RSpec-Junklet Project that changed how I think about test data.
# * https://rubygems.org/profiles/dbrady
# Place in rspec/support/junklet.rb and have the rails_helper.rb load it
# Returns randomized data for when we don't care *what* the data is.
def junk(length = 32)
# hex returns length*2 digits, because it returns a 0..255 byte
# as a hex pair. But when we want junk, we want *bytes* of
# junk. Get (length+1)/2 chars, which will be correct for even
# sizes and 1 char too many for odds, so trim off with [0...length]
@trueheart78
trueheart78 / kitty-version-check.rb
Last active April 20, 2025 01:06
Kitty version checker πŸˆβ€β¬›
#!/usr/bin/env ruby
# full path to a custom icns file
CUSTOM_ICNS = false
CUSTOM_ICNS_FILE = ""
require "colorize"
require "optparse"
def options
@trueheart78
trueheart78 / wow-name.rb
Created April 18, 2023 16:20
WoW Character Name Checker (local)
#!/usr/bin/env ruby
require "colorize"
def wow_name(string)
fits = string.size <= 12
if fits
"=> \"#{string.downcase.capitalize}\" fits and would make a great name! βœ…".green
else
# cutoff = string[0...12]
@trueheart78
trueheart78 / remind-me-to.rb
Last active July 23, 2021 18:25
Simple reminder script to flood the terminal.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'colorize'
end
@trueheart78
trueheart78 / web-servers.md
Created May 28, 2021 20:17 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@trueheart78
trueheart78 / api-gateway-taylor-showtime-2018.markdown
Last active June 11, 2018 16:02
API Gateway - Taylor Showtime 2018
@trueheart78
trueheart78 / git-functions.sh
Last active January 26, 2021 15:44
Git Init Prompt
# remap git to point to g()
git () {
g "$@"
}
# git super command
# make sure with zsh that the git plugin is not used
# as it will override this command
g () {
if [[ $# -gt 0 ]]
#!/usr/bin/env ruby
require 'etc'
commands = {}
File.readlines(File.join(Etc.getpwuid.dir, '.zsh_history')).each do |l|
l = l.encode('utf-8', 'binary', :undef => :replace)
next if l == ''
next unless l.match(/: \d+:/)
l = l.sub(';','[SPLIT]').split('[SPLIT]')
key = l.last.split.first
@trueheart78
trueheart78 / download_recent_stable_kernel.rb
Last active February 4, 2018 06:27
Detect and download the most recent stable Ubuntu kernel version
require 'nokogiri'
require 'net/http'
require 'uri'
require 'byebug'
require 'open-uri'
class LinuxKernel
OFFICIAL_KERNEL_URL = 'https://www.kernel.org/'.freeze
UBUNTU_KERNEL_BASE_URL = 'http://kernel.ubuntu.com/~kernel-ppa/mainline/'.freeze
@trueheart78
trueheart78 / 01_session_security.rb
Created December 12, 2017 14:23
64 Digit Session ID for Rails
# config/initializers/01_session_security.rb
module SessionSecurity
def generate_sid
sid = SecureRandom.hex(32)
sid.encode!(Encoding::UTF_8)
sid
end
end