Skip to content

Instantly share code, notes, and snippets.

@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
@max10rogerio
max10rogerio / yup.locale.pt-br.js
Last active August 23, 2023 17:43
Translation of the main messages from the Yup library into the Pt-Br language.
/* eslint-disable */
// For more infos, see: https://github.com/jquense/yup/blob/master/src/locale.js
import { setLocale } from 'yup'
const translation = {
mixed: {
default: '${path} é inválido',
required: '${path} é um campo obrigatório',
oneOf: '${path} deve ser um dos seguintes valores: ${values}',
notOneOf: '${path} não pode ser um dos seguintes valores: ${values}',
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };
@sadjow
sadjow / makesure.example.coffee
Last active August 29, 2015 14:08
A simple example of makesure using CoffeeScript
validateUser = makesure ->
@permit "name email" # optional
@attrs("name email").isNot('empty').orSay "can't be empty"
userInput =
name: ""
description: "My description"
admin: true
@tomas-stefano
tomas-stefano / Capybara.md
Last active January 31, 2024 16:36
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
# app/models/concerns/slugable.rb
module Slugable
extend ActiveSupport::Concern
included do
validates_format_of :slug, :without => /^\d/
end
module ClassMethods
@neerajsingh0101
neerajsingh0101 / with_published_versions.rb
Last active December 15, 2015 02:28
How to write Active Record bug report when you are using published versions of gems. More details at https://gist.github.com/neerajdotname/5187216 .
gem 'activerecord', '3.2.12'
require 'active_record'
require "minitest/autorun"
require 'minitest/pride'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
@sadjow
sadjow / _addthis.haml
Created February 7, 2013 20:33
AddThis HAML Buttons
%a.addthis_button_facebook_like{"addthis:url" => product_url(p), "fb:like:layout" => "button_count"}
%a.addthis_button_tweet{'tw:text' => "#{p.name} #{app_title}: #{product_url(p)}"}
@sadjow
sadjow / rmagick.sh
Created January 25, 2013 17:50 — forked from zoras/rmagick.sh
sudo apt-get install libdjvulibre-dev libjpeg-dev libtiff-dev libwmf-dev libmagickcore-dev libmagickwand-dev libmagick++-dev rvm
sudo gem install rmagick
ok!
Fetching: rmagick-2.13.1.gem (100%) Building native extensions. This could take a while ... Successfully installed rmagick-2.13.1 1 gem installed
require 'RMagick' #=> true
@ryanb
ryanb / issues_with_modules.md
Created November 29, 2012 22:38
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article < ActiveRecord::Base