Skip to content

Instantly share code, notes, and snippets.

@wtaysom
wtaysom / where_is.rb
Created September 23, 2011 08:57
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@barnes7td
barnes7td / sublime_setup.md
Last active March 28, 2024 17:59
Sublime Terminal Setup

Setup Terminal for Sublime Shorcut "subl":

Open terminal and type:

1. Create a directory at ~/bin:

mkdir ~/bin

2. Copy sublime executable to your ~/bin directory:

@mattbrictson
mattbrictson / application.html.erb
Last active August 16, 2023 15:33
Simpler nested layouts in Rails using the parent_layout helper
<%= render("shared/navbar") %>
<div class="container">
<%= render("shared/alerts") %>
<%= render("shared/page_header") %>
<%= yield %>
<%= render("shared/footer") %>
@kevinhughes27
kevinhughes27 / the_arborist.rb
Last active January 7, 2022 22:53
find un-deleted branches from closed PRs
#!/usr/bin/env ruby
require 'octokit'
require 'highline/import'
require 'colorize'
require 'byebug'
require 'csv'
require 'active_support/time'
username = ask("Enter your Github username: ") { |q| q.echo = true }
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 25, 2024 09:09
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@vasanthk
vasanthk / System Design.md
Last active July 27, 2024 18:36
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@gmcculloug
gmcculloug / custom_button_export.rb
Last active May 4, 2020 16:42
Custom Button Export
class ExportArInstances
EXCLUDE_ATTRS = %w(id created_on updated_on created_at updated_at).freeze
def self.export_object(obj, hash)
class_name = obj.class.name.underscore
puts "Exporting #{obj.class.name} [#{obj.try('name')}] with ID: #{obj.id}"
(hash[class_name] ||= []) << item = {'attributes' => export_attributes(obj)}
try(class_name).tap do |has_many_assoc, has_one_assoc|