Skip to content

Instantly share code, notes, and snippets.

rogerleite /
Last active Sep 28, 2021
Install Monaco font in Linux
# Install Monaco font in Linux
# Version from nullvideo
sudo mkdir -p /usr/share/fonts/truetype/ttf-monaco && \
sudo wget -O - > \
/usr/share/fonts/truetype/ttf-monaco/Monaco_Linux.ttf && \
sudo fc-cache
rogerleite / PlainEnglish.livemd
Created Apr 30, 2021
Interpret and evaluate arithmetic expressions written in plain English (Livebook Elixir)
View PlainEnglish.livemd
# Arithmetic expressions in plain English
## Interpret and evaluate arithmetic expressions written in plain English
Example: "one plus two times four"
* numbers are [zero-ten]
* numbers can be negative, for example: "negative five"
* "plus" and "times" are the only supported operations natural order of operations apply, multiply before add.
* "negative" is optional string before the number and is not an operation "one minus two" is expressed as "one plus negative two"
rogerleite /
Last active Mar 9, 2020
Some scripts to install things


Some install scripts. Target to work with Ubuntu 12 or greater.

Table of Scripts

rogerleite / defensive-ruby.rb
Created Jun 12, 2019
Example of defensive ruby
View defensive-ruby.rb
# example 1: adopting default values and trying to not break things
def adapter(action)
action = action.to_sym unless action.is_a?(Symbol)
batch = {
active_products: "ProductsActive",
inactive_products: "ProductsInactive",
download_products: "ProductsDownload"
batch.fetch(action, "UnknownAction")
rogerleite / converters.rb
Last active Sep 17, 2018
Ruby and CSV examples
View converters.rb
require "csv"
require "date"
puts CSV::HeaderConverters.keys.inspect # => [:downcase, :symbol]
# Add new header converter
CSV::HeaderConverters[:remap] = lambda do |raw_value|
raw_value = raw_value.to_sym
case raw_value
when :country
rogerleite / backup_redmine_with_mutt
Created Feb 16, 2009
Exemplo de script que faz backup do Redmine
View backup_redmine_with_mutt
DATE_BACKUP=`date +%Y%m%d`
rogerleite / oracle_export.rb
Created Oct 24, 2009
Access Oracle with jruby using JDBC. Export data to json format.
View oracle_export.rb
Requisitos Minimos para rodar este script:
#jruby 1.1 ou superior (nao testei com superior :D)
apt-get install jruby
#baixar o oracle jdbc (para o 10g, ou procure a versão que deseje) de:
#copiar o ojdbc14.jar para (usar sudo):
rogerleite /
Created Jun 26, 2013
Using Shell Script to test your server
## Unit-Testable Shell Scripts (
typeset -i tests_run=0
function try { this="$1"; }
trap 'printf "$0: exit code $? on line $LINENO\nFAIL: $this\n"; exit 1' ERR
function assert {
let tests_run+=1
rogerleite / Gemfile
Last active Dec 16, 2015
CSV data generator for lazy people like me.
View Gemfile
source ""
gem "faker", "~> 1.1.2"
gem "uuid", "~> 2.3.7"