Skip to content

Instantly share code, notes, and snippets.

mes = 2;
isValidMonth = true;
if(mes < 1){
console.log('mes tem que ser maior que 1');
isValidMonth = false;
}
if(mes > 12){
# To run:
# gem install rspec
# rspec mb.rb
class Pocket
attr_reader :white, :red, :blue, :black, :green
InvalidValueForColor = Class.new(StandardError)
def initialize(white: 0, red: 0, blue: 0, black: 0, green: 0)
@fabioperrella
fabioperrella / memWatcher
Created March 27, 2020 13:45
Bash script to print the memory usage in syslog every 2s
#!/bin/bash
while :; do
mem_used="$(free -m | grep Mem | awk '{print$3}')"
mem_free="$(free -m | grep Mem | awk '{print$4}')"
mem_avail="$(free -m | grep Mem | awk '{print$4}')"
logger -t MemWatcher "Used: ${mem_used}. Free: ${mem_free}. Available: ${mem_avail}.";
sleep 2; done
@fabioperrella
fabioperrella / suplementos_alimentares.md
Created June 20, 2018 01:06
Suplementos alimentares para ficar mais ligado no dia a dia

Suplementos alimentares para ficar mais ligado no dia a dia

Dicas do Dr Psiquiatra Italo Marsili https://www.amelhorfamiliadomundo.com.br/

MCT (trigliceridio de cadeia média)

  • Para dar energia e tirar a preguiça
  • Melhora sintomas de depressão
  • Melhor em pó do que em oleo
  • sugestao de marca: Athletica
@fabioperrella
fabioperrella / AngularJS.cache
Last active January 13, 2017 12:37
sublime sync
{"/home/fabio/workspace/hodor/home/fabio/workspace/provisioning-core": {"attributes": {}, "definitions": []}}
@fabioperrella
fabioperrella / git_clean_merged_branches
Last active November 26, 2023 23:24
Bash script to clean git merged branches (local and remote). Thanks to Eron Junior to introduce me the command "git fetch -p"
#!/bin/sh
set -xe
git checkout master
git fetch
git pull
git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete || true
git branch --merged | grep -v master | xargs git branch -d || true
git fetch -p
@fabioperrella
fabioperrella / gist:21c1da9e90c6fc5bc3ec
Created September 8, 2014 20:44
logando no admn do SMTP sem CAS
## substiuir o conteudo do arquivo admin/base_controller.rb pelo abaixo
class Admin::BaseController < InheritedResources::Base
extend Memoist
layout 'admin'
protect_from_forgery
before_filter :signin, :authenticate_admin!, :log_action
@fabioperrella
fabioperrella / gist:26155083c11d45c905e7
Created July 14, 2014 18:25
logando no SMTP sem CAS
app/controllers/panel/base_controller.rb
# comentar linha abaixo
#before_filter :authenticate_user!, :require_account!, :check_if_enabled
before_filter :signin, :authenticate_user!, :require_account!, :check_if_enabled
#criar metodo abaixo
def signin
sign_in(User.first) if current_user.nil?
end
@fabioperrella
fabioperrella / gist:4513418
Created January 11, 2013 19:45
example csv for email marketing
@fabioperrella
fabioperrella / stacktrace
Created April 18, 2012 17:36
pry-nav next Segmentation fault
153: binding.pry
154:
=> 155: if result[:success]
156: #so apaga arquivo se foi sucesso, caso contrario deixa pra debugar
157: delete_import_file(part_number)
158: else
159: failed!
160: end
[1] pry(#<ContactImport>)> next