Skip to content

Instantly share code, notes, and snippets.

View fakefarm's full-sized avatar
🐽
🦁🍎🐸🧄🐔🍐🐹🍑🐮 🐴🦆🥦🐙🐳F🦞🧅🐶 🦧👾A🦈🐋🍉K🌽 🐣🐎🦚🦩🦔🐿🦨🐉🥕 🐿🐾🐒🍊E🐈🐻🥥🐱 🐼🥑🐷🐓🍌🐖F🦃 🐑🚜🍋🐂A🐏🌾🤖🐀🦔 R🦜🦝🐈🦓🐠🦑🦂M🐜

Dave Woodall fakefarm

🐽
🦁🍎🐸🧄🐔🍐🐹🍑🐮 🐴🦆🥦🐙🐳F🦞🧅🐶 🦧👾A🦈🐋🍉K🌽 🐣🐎🦚🦩🦔🐿🦨🐉🥕 🐿🐾🐒🍊E🐈🐻🥥🐱 🐼🥑🐷🐓🍌🐖F🦃 🐑🚜🍋🐂A🐏🌾🤖🐀🦔 R🦜🦝🐈🦓🐠🦑🦂M🐜
View GitHub Profile
@kddnewton
kddnewton / json.rb
Last active October 6, 2023 09:25
JSON parser with pattern matching
require "json"
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] }
source = JSON.dump(struct)
tokens = []
index = 0
until source.empty?
tokens <<
@pawurb
pawurb / application.rb
Created February 23, 2020 12:20
Rails colored prompt without gems
# config/application.rb
module RailsApplicationName
class Application < Rails::Application
...
console do
ARGV.push "-r", root.join("lib/console.rb")
end
end
end
@jalkoby
jalkoby / my_awesome_rspec_hacks.rb
Created September 29, 2018 13:05
My awesome RSpec hacks
## Context + metadata
shared_context 'Logged as a user', role: true do
let(:user) { |example| create :user, example.metadata[:role] }
before { login_as user }
end
scenario "Login as a client", role: :client
scenario "Login as a customer", role: :customer
scenario "Login as an admin", role: :admin
@simonw
simonw / how-to-upgrade-heroku-postgresql.md
Last active January 10, 2024 00:16
How to upgrade a Heroku PostgreSQL database to a new plan

How to upgrade a Heroku PostgreSQL database to a new plan

I started a project on a Hobby Dev plan (free, limit 10,000 rows), and then later needed to upgrade it to Hobby Basic ($9/month, limit 10,000,000 rows).

After assigning the new database, I had two databases attached to the application. They looked something like this:

  • HEROKU_POSTGRESQL_OLIVE (postgresql-dimensional-3321) Old, free-tier (Hobby Dev) database
@zulhfreelancer
zulhfreelancer / heroku_pg_db_reset.md
Last active January 29, 2024 10:09
How to reset PG Database on Heroku (for Rails app)?

It's important to note that running this reset will drop any existing data you have in the application

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

@J2TEAM
J2TEAM / sublime-text-scopes.md
Last active January 17, 2024 22:44 — forked from iambibhas/scopes.txt
Sublime Text 2/3: Snippet scopes

Here is a list of scopes to use in Sublime Text 2/3 snippets -

ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
@pdobb
pdobb / .aprc
Last active May 25, 2023 05:19
Use AwesomePrint in Rails Console without adding to Gemfile
AwesomePrint.defaults = {
:indent => -2,
:color => {
:string => :greenish,
:date => :yellowish,
:time => :yellowish,
:nilclass => :cyanish
}
}
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
// Brightness math based on:
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
// Extract color components
@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active January 17, 2024 23:54
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps