Skip to content

Instantly share code, notes, and snippets.

View sogamoso's full-sized avatar
👋
Hey there!

Sebastian Sogamoso sogamoso

👋
Hey there!
View GitHub Profile
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active June 14, 2024 02:40
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

@odlp
odlp / update.sh
Last active May 3, 2020 10:06
Rbenv update Rubygems
#!/usr/bin/env sh
# Multiple vulnerabilities have been disclosed in RubyGems:
# https://www.ruby-lang.org/en/news/2018/02/17/multiple-vulnerabilities-in-rubygems/
#
# And again in March 2019:
# https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html
#
# If you're an Rbenv user, here's any easy one-liner to upgrade to a
# safe version of Rubygems (2.7.8 / 3.0.3 or later) for each installed Ruby version:
# Cleans up branches like:
# if Shopify.rails_next?
# # Rails 5 login
# else
# # Rails 4 login
# end
module RuboCop
module Cop
module ShopifyRails
class RailsNextUnless < Cop
@blowmage
blowmage / docs.rake
Created November 15, 2014 01:56
A rake task to update the documentation in the gh-pages branch.
namespace :docs do
desc "Updates the documentation on the gh-pages branch"
task :update do
branch = `git symbolic-ref --short HEAD`.chomp
if "master" != branch
puts "You are on the #{branch} branch. You must be on the master branch to run this rake task."
exit
end
require_relative "../lib/my_gem/version.rb"
@brasic
brasic / clear_redis_script.rb
Last active October 13, 2020 19:52
Clear a large number of redis keys by pattern using SCAN and pipelining
#!/usr/bin/env ruby
require 'redis'
# Clear a large number of keys matching a pattern using SCAN and
# pipelining to avoid killing the server.
class ClearKeys
def initialize(pattern, host='localhost', postprocess_pattern=nil)
@redis = Redis.new(host: host)
@pattern = pattern
module Kernel
alias :old_puts :puts
def puts(val)
old_puts val
old_puts caller.inspect
end
end
@allolex
allolex / README.md
Last active August 29, 2015 14:00
Regular expression examples
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@orendon
orendon / git_tag_timestamp.sh
Last active September 12, 2023 13:05
Git tag timestamp
#git tag `date "+staging-%Y%m%d%H%M%S"`
git tag `date "+production-%Y%m%d%H%M%S"`
git push --tags