Skip to content

Instantly share code, notes, and snippets.

View tiagobabo's full-sized avatar

Tiago Babo tiagobabo

View GitHub Profile
@swanson
swanson / .irbrc
Last active March 3, 2024 17:14
.irbrc color coding Rails console by environment
# Add color coding based on Rails environment for safety
if defined? Rails
banner = if Rails.env.production?
"\e[41;97;1m #{Rails.env} \e[0m "
else
"\e[42;97;1m #{Rails.env} \e[0m "
end
# Build a custom prompt
@jferris
jferris / configmap.yaml
Last active July 4, 2024 09:52
Rails Kubernetes Manifests
apiVersion: v1
kind: ConfigMap
metadata:
name: example
namespace: default
data:
APPLICATION_HOST: example.com
LANG: en_US.UTF-8
PIDFILE: /tmp/server.pid
PORT: "3000"
@jsimpson
jsimpson / arel_cheatsheet_on_steroids.md
Created February 7, 2020 21:51 — forked from ProGM/arel_cheatsheet_on_steroids.md
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@l3kn
l3kn / lazyFizzBuzz.rb
Created April 18, 2015 14:00
Lazy FizzBuzz
fizz = ["","","Fizz"].lazy.cycle
buzz = ["","","","","Buzz"].lazy.cycle
numbers = (1..Float::INFINITY).lazy
fizzbuzz = numbers.zip(fizz,buzz).map do |n,f,b|
(f.empty? && b.empty?) ? n.to_s : f + b
end
puts fizzbuzz.take(20).to_a
@devnulled
devnulled / OptionCheatsheet.scala
Created June 27, 2012 15:45
Scala Option Cheatsheet
// flatMap
// This code is equivalent to:
// option.flatMap(foo(_))
option match {
case None => None
case Some(x) => foo(x)
}
// flatten
// This code is equivalent to:
@unnitallman
unnitallman / gist:944011
Created April 27, 2011 10:11
sqlite with activerecord outside rails
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = false
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:dbfile => ":memory:"
)