Skip to content

Instantly share code, notes, and snippets.

View hugomaiavieira's full-sized avatar

Hugo Maia Vieira hugomaiavieira

View GitHub Profile
@hugomaiavieira
hugomaiavieira / clearCache.sh
Last active October 18, 2023 19:41
Script para limpar o cache do seu Linux
#!/bin/sh
#
# Salve este script no diretório /etc/cron.hourly e dê permissão
# de execução a ele. Desse modo a cada hora sera verificada se a
# porcentagem de memória utilizada pelo sistema atingiu o valor definido
# na variável 'percent'. Caso positivo, o script informará ao kernel
# que este deverá alterar o valor da opção 'drop_caches' para 3.
#
# Mais detalhes: 'man proc' -> /proc/sys/vm/drop_caches.
PATH="/bin:/usr/bin:/usr/local/bin"
@hugomaiavieira
hugomaiavieira / internet-test.sh
Last active September 28, 2015 05:27
Script para verificar se a internet voltou. Quando volta, toca um alarme.
# Verify it a website is back, or the internet access is back. When it is back,
# an alarm rings.
#
# Depends of ticktimer: https://github.com/algorich/ticktimer
#
# Author: Hugo Maia Vieira <hugomaiavieira@gmail.com>
#
while :
do
@hugomaiavieira
hugomaiavieira / all2pdf.sh
Created December 27, 2011 12:17
Script to convert all kind of files in a directory to pdf
#!/bin/bash
#
# a2pdf: Script to convert all kind of files in a directory to pdf
#
# Author: Hugo Maia Vieira <hugomaiavieira@gmail.com>
#
# Dependencies: tree, cedilla, ps2pdf
#
# TODO: Separar em funções "concatenar", "converter" e "concatenar e converter"
# para poderem ser chamadas separadamente.
@hugomaiavieira
hugomaiavieira / .gitconfig
Created December 27, 2011 13:03
My gitconfig
[color]
ui = auto
[alias]
br = branch
ci = commit
co = checkout
st = status
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
[diff]
external = /home/hugo/.config/git_meld_diff.py
# -*- encoding : utf-8 -*-
#
# Rodrigo Soares Manhães, professor homenageado pelos formandos da turma de 2007
# do curso de Ciência da Computação da UENF.
#
# 20/09/2012
#
##
class Aluno < ActiveRecord::Base
@hugomaiavieira
hugomaiavieira / ohmygems.sh
Created November 3, 2012 14:49
Oh My Gems! Gemsets made easy and error free (http://blog.zenspider.com/blog/2012/09/ohmygems.html)
# This is basically the same Ryan Davis's script
# (http://blog.zenspider.com/blog/2012/09/ohmygems.html) with a bug fix and some
# modifications.
#
# This should be added after rbenv config lines on your .profile or .bashrc file.
#
export ORIG_GEM_PATH=${GEM_PATH:-}
export ORIG_GEM_HOME=${GEM_HOME:-}
export ORIG_PATH=${PATH}
@hugomaiavieira
hugomaiavieira / gist:5359331
Created April 10, 2013 23:24
address.js.erb - javascript for find and fill address fields using brcep gem
// requires
<% routes = Rails.application.routes.url_helpers %>
$(function () {
$('#place_postal_code').on('change', function() {
var $label = $('label[for=place_postal_code]'),
value = $(this).val();
var onSuccess = function(r) {
@hugomaiavieira
hugomaiavieira / gist:5359356
Last active December 16, 2015 01:59
Controller action and route config for find and fill address fields using brcep gem
# controller action
def find_cep
begin
# Ex: ['Avenida', 'das Americas', 'Barra da Tijuca', 'Rio de Janeiro', 'RJ', 22640100]
address = BuscaEndereco.por_cep params[:cep]
street = "#{address.fetch(0)} #{address.fetch(1)}"
neighborhood = address.fetch(2)
city = address.fetch(3)
state = address.fetch(4)
data = {
@hugomaiavieira
hugomaiavieira / .bashrc
Last active December 16, 2015 16:59
my .bashrc file
export PATH="$HOME/.rbenv/bin:$PATH" # Add rbenv to PATH
eval "$(rbenv init -)" # init rbenv to enable shims and autocompletion
######
#
# Oh my gems!
#
export ORIG_GEM_PATH=${GEM_PATH:-}
export ORIG_GEM_HOME=${GEM_HOME:-}
export ORIG_PATH=${PATH}
@hugomaiavieira
hugomaiavieira / localStorageUsedSpace.js
Last active December 21, 2015 21:08
Script para verificar o espaço utilizado no localStorage
// based on: http://stackoverflow.com/a/17887889/529418
// On Android I get the max 2.5M characters in localStorage (Strings in JavaScript are UTF-16).
var localStorageUsedSpace = function(){
var allStrings = '';
for(var key in window.localStorage){
if(window.localStorage.hasOwnProperty(key)){
allStrings += window.localStorage[key];
}
}