Skip to content

Instantly share code, notes, and snippets.


Leonardo Faria leonardofaria

View GitHub Profile
View vanilla-lazy-load.html
.item {width:300px; display: inline-block; }
.item .itemtitle {font-weight:bold; font-size:2em;}
.hidden {display:none;}
<h1>Amalgam Comics Characters</h1>
leonardofaria /
Last active May 6, 2016
MySQL backup using Ruby script

MySQL backup using Ruby script

This is a simple script that I wrote to backup my local databases. It uses terminal-notifier to create OS notifications and time_difference to report how much time it takes to execute a backup.


  • Install the required gems: gem install time_difference terminal-notifier
  • Adjust the relevant variables: databases, path
  • The connection variables are set in the .my.cnf file. I don't want your MySQL password in the script.
leonardofaria / UserMailer.rb
Last active Feb 18, 2016 — forked from willywg/UserMailer.rb
Mass password reset and email notification for Devise 3.5.1 with Rails 4.x
View UserMailer.rb
# Send password reset notification
# path: app/mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => ""
def password_reset(user, token)
@resource = user
@token = token
mail(:to =>,
:subject => 'Password Reset Notification')
View gist:bae42992c4c0c522bcbb
# paths
leonardofaria / quiz3.js
Created Oct 20, 2015
WMDD 4820 - Quiz 3
View quiz3.js
// 1. How many times are the following loop bodies repeated?
// What is the printout of each loop? (3 points)
// a.
var i = 1;
while (i < 10)
if (i % 2 == 0)
document.write( i + "<br />");
// Answer: infinity loop. i will be never incremented.
View Preferences.sublime-settings
"auto_completecommiton_tab": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
"font_face": "Meslo LG S Regular for Powerline",
"font_size": 17.0,
"highlight_line": true,
"highlight_modified_tabs": true,
"open_files_in_new_window": false,
View monitor.rb
gem 'mechanize', '2.7.2'
require 'mechanize'
require 'pony'
def sendmail(to, subject, body)
:to => to,
:via => :smtp,
:subject => subject,
:body => body,
View ducknorris.zsh-theme
# ducknorris custom theme
# FreeAgent puts the powerline style in zsh !
if [ "$POWERLINE_DATE_FORMAT" = "" ]; then
if [ "$POWERLINE_RIGHT_B" = "" ]; then
elif [ "$POWERLINE_RIGHT_B" = "none" ]; then
View error_messages_helper.rb
module ErrorMessagesHelper
# Render error messages for the given objects. The :message and :header_message options are allowed.
def error_messages_for(*objects)
options = objects.extract_options!
options[:header_message] ||= t(:"errors.template.header", model: t(:"activerecord.models.#{}"), count: objects.compact.first.errors.messages.size)
options[:message] ||= t(:"errors.template.body")
messages = { |o| o.errors.full_messages }.flatten
unless messages.empty?
content_tag(:div, id: "error_explanation") do
list_items = { |msg| content_tag(:li, msg) }
View gist:4482539
// esse é o arquivo de configurações do sublime
// ele é organizado em um formato json
// mais informações:
// configurações visuais
"theme": "Soda Light.sublime-theme",