Skip to content

Instantly share code, notes, and snippets.

@leonardofaria
leonardofaria / about.js
Created August 31, 2016 05:30
Javascript module loader
var App = App || {};
App.About = (function(document) {
'use strict';
var init = function() {
console.log('about init called()');
};
@leonardofaria
leonardofaria / example.rb
Created August 4, 2016 16:43
Time Calculation using Ruby
require_relative './time_calculation.rb'
distance = Time.new - Time.parse('2016-1-1')
puts TimeCalculation.humanize(distance)+"\r"
Date_of_birth = '1888-2-15'
3.times do
distance = Time.new - Time.parse(Date_of_birth)
puts TimeCalculation.humanize(distance, false)+"\r"
sleep 1
<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 23:07
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.

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 February 18, 2016 20:58 — forked from willywg/UserMailer.rb
Mass password reset and email notification for Devise 3.5.1 with Rails 4.x
# 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')
@leonardofaria
leonardofaria / gist:bae42992c4c0c522bcbb
Created January 26, 2016 04:15
livestreamer mp3 grabber
#!/bin/bash
# paths
LIVESTREAMER="livestreamer"
FFMPEG="ffmpeg"
#####
# 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
{
// 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",
http://www.flotcharts.org/
http://www.highcharts.com/
http://www.jscharts.com/
http://oesmith.github.com/morris.js/
http://raphaeljs.com/
http://g.raphaeljs.com/
http://www.rgraph.net/examples/
http://code.shutterstock.com/rickshaw/
http://xaviershay.github.com/tufte-graph/
@leonardofaria
leonardofaria / quiz3.js
Created October 20, 2015 21:16
WMDD 4820 - Quiz 3
// 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.