Skip to content

Instantly share code, notes, and snippets.

@rogerleite
rogerleite / install_monaco_font.sh
Last active August 3, 2023 23:39
Install Monaco font in Linux
#!/bin/bash
# Install Monaco font in Linux
# Version from nullvideo https://gist.github.com/rogerleite/99819#gistcomment-2799386
sudo mkdir -p /usr/share/fonts/truetype/ttf-monaco && \
sudo wget https://gist.github.com/rogerleite/b50866eb7f7b5950da01ae8927c5bd61/raw/862b6c9437f534d5899e4e68d60f9bf22f356312/mfont.ttf -O - > \
/usr/share/fonts/truetype/ttf-monaco/Monaco_Linux.ttf && \
sudo fc-cache
@rogerleite
rogerleite / _install.md
Last active May 19, 2023 16:57
Some scripts to install things

Introduction

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

Table of Scripts

Non-federal Acute Care Hospital Health IT Adoption

Mix.install([
  {:explorer, "~> 0.5.0"},
  {:vega_lite, "~> 0.1.4"},
  {:kino_vega_lite, "~> 0.1.1"}
])
@rogerleite
rogerleite / nginx.conf
Created August 2, 2012 19:24
Configuração Nginx
user www-data;
worker_processes 4;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
@rogerleite
rogerleite / PlainEnglish.livemd
Created April 30, 2021 22:12
Interpret and evaluate arithmetic expressions written in plain English (Livebook Elixir)

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
rogerleite / defensive-ruby.rb
Created June 12, 2019 11:32
Example of defensive ruby
# 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")
end
@rogerleite
rogerleite / converters.rb
Last active September 17, 2018 22:39
Ruby and CSV examples
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
rogerleite / backup_redmine_with_mutt
Created February 16, 2009 17:34
Exemplo de script que faz backup do Redmine
#ARQUIVO: bkp_redmine.sh
#!/bin/sh
BACKUP_FOLDER=/home/minha_empresa/backup/redmine
DATE_BACKUP=`date +%Y%m%d`
DB_FILE_BKP="$BACKUP_FOLDER"/"$DATE_BACKUP"_redmine_db.gz
FILES_FOLDER_BKP="$BACKUP_FOLDER"/files
FILES_FILE_BKP="$BACKUP_FOLDER"/"$DATE_BACKUP"_redmine_files.gz
@rogerleite
rogerleite / oracle_export.rb
Created October 24, 2009 13:41
Access Oracle with jruby using JDBC. Export data to json format.
=begin
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:
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html
#copiar o ojdbc14.jar para (usar sudo):