Skip to content

Instantly share code, notes, and snippets.

@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
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 / 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 / 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 / AngularJS.cache
Last active January 13, 2017 12:37
sublime sync
{"/home/fabio/workspace/hodor/home/fabio/workspace/provisioning-core": {"attributes": {}, "definitions": []}}
@fabioperrella
fabioperrella / gist:4513418
Created January 11, 2013 19:45
example csv for email marketing
email
lalala@coc.com
@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
@fabioperrella
fabioperrella / mongo_shell
Created April 3, 2012 12:02
mongodb criando indice para custom field
> db.contacts.find({"custom_fields.gender":"fem"}).explain()
{
"cursor" : "BasicCursor",
"nscanned" : 1002,
"nscannedObjects" : 1002,
"n" : 244,
"indexBounds" : {
}
}
@fabioperrella
fabioperrella / mongos
Created March 19, 2012 12:12
MongoDB init script for Mongos in Debian
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.