Skip to content

Instantly share code, notes, and snippets.

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

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.

Installation

  • 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
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 => "no-reply@example.com"
def password_reset(user, token)
@resource = user
@token = token
mail(:to => user.email,
:subject => 'Password Reset Notification')
View gist:bae42992c4c0c522bcbb
#!/bin/bash
# paths
LIVESTREAMER="livestreamer"
FFMPEG="ffmpeg"
#####
@leonardofaria
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,
"rulers":
View monitor.rb
gem 'mechanize', '2.7.2'
require 'mechanize'
require 'pony'
def sendmail(to, subject, body)
Pony.mail({
: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
POWERLINE_DATE_FORMAT=%D{%Y-%m-%d}
fi
if [ "$POWERLINE_RIGHT_B" = "" ]; then
POWERLINE_RIGHT_B=%D{%H:%M:%S}
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.#{objects.compact.first.class.name.downcase}"), count: objects.compact.first.errors.messages.size)
options[:message] ||= t(:"errors.template.body")
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
unless messages.empty?
content_tag(:div, id: "error_explanation") do
list_items = messages.map { |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:
// http://leonardofaria.net/2012/12/31/configurando-o-sublime-text-2
// http://simplesideias.com.br/configurando-o-sublime-text-2
// configurações visuais
"theme": "Soda Light.sublime-theme",