Skip to content

Instantly share code, notes, and snippets.

@brodock
brodock / money_attribute.rb
Last active October 15, 2015 12:33
Money Attributes
module Financeiro
# Inclui suporte para escrever em um campo com valor monetário
# utilizando BigDecimal, ou valor em string seguindo sintaxe
# do jQuery MoneyMask
#
# Para habilitar em um model é preciso primeiro fazer um include no model:
# include MoneyAttribute
#
# Defina cada um dos campos que você quer que tenham o comportamento:
@maxivak
maxivak / custom_submit_simple_form.md
Last active February 27, 2023 16:33
Rails simple_form custom submit button. simple_form, bootstrap 3

Custom submit button in simple_form and bootstrap 3

Objective

It is easy to add wrappers for input components in simple_form, but it takes some time to modify rendering of buttons ("f.button").

We want to have this in our form:

= f.button :submit_cancel, 'Save'

@mogsdad
mogsdad / Apps Script pdfToText utility.md
Last active August 8, 2024 15:21
For http://stackoverflow.com/questions/26613809, a question about getting pdf attachments in gmail as text. I got a little carried away - this does much more than asked.

Google Apps Script pdfToText Utility#

This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).

Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.

    // Start with a Blob object
    var blob = gmailAttchment.getAs(MimeType.PDF);
    
@gampleman
gampleman / tracking_interceptor.md
Last active June 19, 2020 21:34
Adding tracking to emails in Rails

This gist illustrates how you would add Google Analytics tracking into your Rails mailers. Add the tracking_interceptor.rb into your path and enable it for your mailers with:

register_interceptor TrackingInterceptor
@aprescott
aprescott / re_run_friendly_formatter.rb
Last active July 27, 2016 14:18
A re-run friendly formatter for RSpec, to show failed example files as a single rspec command to run.
# place the contents of this file in, e.g., spec/re_run_friendly_formatter.rb
#
# and in .rspec:
#
# --format ReRunFriendlyFormatter
require "rspec/core/formatters/progress_formatter"
class ReRunFriendlyFormatter < RSpec::Core::Formatters::ProgressFormatter
RSpec::Core::Formatters.register self, :dump_summary
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')