Skip to content

Instantly share code, notes, and snippets.

View randyleighton's full-sized avatar
☺️
Build It! Release It!

Randy Leighton randyleighton

☺️
Build It! Release It!
  • G5
  • Bend
View GitHub Profile
@levibrown
levibrown / kube_commands.rb
Last active July 15, 2019 22:35
a cli for common g5 kube commands
#!/usr/bin/env ruby
# Setup:
# 1) `gem install highline`
# 2) save this file to a local folder
# 3) rename the file to remove extension `mv kube_commands.rb kube_commands`
# 4) change permissions `chmod 755 kube_commands`
# 5) link to your /usr/local/bin `ln -s $PWD/kube_commands /usr/local/bin/`
# 6) in a new shell you should now be able to run `kube_commands`
# 7) add new commands and add to this gist
@amitsaxena
amitsaxena / gist:689d29f23d01bd563839
Last active August 29, 2015 14:07
Ruby text only spinner/loader/processing/progress indicators && some FUN
# Loader for infinite time
["|", "/", "-", "\\"].each{|v| STDOUT.write "\r#{v}"; sleep 0.5} while 1
# In case you want to run it for a few seconds (~ 20s in the example below)
10.times{ ["|", "/", "-", "\\"].each{|v| STDOUT.write "\r#{v}"; sleep 0.5} }
# Progress Bar
100.times{STDOUT.write "|"; sleep 0.1}
# Another kind of loading indicator
@flomotlik
flomotlik / deploy_branch.rb
Created July 14, 2014 14:24
Create new Heroku App for branch
#!/usr/bin/env ruby
require "open3"
git_branch = ENV['CI_BRANCH'] || `git rev-parse --abbrev-ref HEAD`
@app_name = "csqa-#{git_branch[0..24].gsub(/\W/, '-')}"
def exec command
Open3.popen2e(command){ |stdin, stdout_err, wait_thr|
while line = stdout_err.gets
@gmontard
gmontard / domain.rb
Last active October 20, 2023 21:44
Rails dynamic domain and subdomain routes constraint
# -*- encoding : utf-8 -*-
class Domain < ActiveRecord::Base
after_save :reload_routes
def reload_routes
if self.domain_changed?
REDIS.set("rails_routes_ts", "expired")
end
end
@dideler
dideler / routes.md
Last active April 8, 2024 04:15
Rails Routes

A summary of the Rails Guides on Routes, plus other tips.

The Rails router recognizes URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views.

Examples

# Redirects /orders/report to orders#report.
get 'orders/report', to: 'orders#report'
@rstacruz
rstacruz / index.md
Last active August 2, 2025 18:42
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one