Skip to content

Instantly share code, notes, and snippets.

View agush22's full-sized avatar

Agustín Leñero agush22

View GitHub Profile
@Nosfheratu
Nosfheratu / my_mailer.rb
Created January 18, 2019 04:22
send pdf attachment
class MyMailer < ApplicationMailer
def send_invoice user, invoice
@user = user
@invoice = invoice
invoice_attachment = WickedPdf.new.pdf_from_string(render_to_string(pdf: "invoice", template: 'payments/charges/invoice.pdf.erb'))
attachments["I#{sprintf('%06d', @invoice.id)}.pdf"] = invoice_attachment
mail(to: @user.email,
subject: "Your invoice", template_path: 'users_mailer')
end
end
@bhserna
bhserna / where_is_the_app.markdown
Last active December 10, 2015 14:38
This are different examples to do the same thing, "mark a notification as read", and the pros and cons that I see in each example

Where is the app?

This are different examples of doing the same thing, "mark a notification as read", and the pros and cons that I see in each example

1. - Logic in the model

  • The user clicks the notification link
  • The system POSTs to the action "notifications/:id/mark_as_read"
  • The controller calls the method Notification#mark_as_read
  • The model updates the attribute "read" saves the Notification record
@maca
maca / das_download.rb
Created February 11, 2012 09:08
Script to download all Destroy All Software screencasts, account needed
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password [download_directory]
require 'mechanize'
# gem 'mechanize-progressbar'
email = ARGV[0] or raise('Please provide the email address for your account')
password = ARGV[1] or raise('Please provide the password for your account')
path = ARGV[2] || './'
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@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')