Skip to content

Instantly share code, notes, and snippets.

gem 'mechanize', '2.7.2'
require 'mechanize'
require 'pony'
def sendmail(to, subject, body)
Pony.mail({
:to => to,
:via => :smtp,
:subject => subject,
:body => body,
{
"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":
@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.
@leonardofaria
leonardofaria / gist:bae42992c4c0c522bcbb
Created January 26, 2016 04:15
livestreamer mp3 grabber
#!/bin/bash
# paths
LIVESTREAMER="livestreamer"
FFMPEG="ffmpeg"
#####
@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 / 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.
<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 / 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
@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()');
};

Themes / UI related

  • native-ui: macOS-like
  • cobalt2: the same colour scheme (Cobalt) that I use everywhere
  • file-icons
  • fonts: give me the same font (Meslo) that I use everywhere

Packages

  • atom-beautify
  • atom-ternjs: autocomplete JS
  • auto-update-packages