Skip to content

Instantly share code, notes, and snippets.

View henriquemenezes's full-sized avatar

Henrique Menezes henriquemenezes

  • Recife, Brazil
View GitHub Profile
@henriquemenezes
henriquemenezes / rbenv-install-system-wide.sh
Last active July 14, 2017 23:49
rbenv install system wide
# Install RBenv in /opt/ for all users
echo '# == Rbenv ==' > /etc/profile.d/rbenv.sh
echo 'export RBENV_ROOT=/opt/rbenv' >> /etc/profile.d/rbenv.sh
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
chmod +x /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh
curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
@henriquemenezes
henriquemenezes / angularjs-force-refresh-google-maps.js
Created November 27, 2015 18:50
AngularJS force update images from google maps (ngMap)
$scope.map = null;
$scope.$on('mapInitialized', function(event, map) {
$scope.map = map;
});
$scope.$on('cfpLoadingBar:completed', function () {
$timeout(function() {
google.maps.event.trigger($scope.map,'resize')
}, 1000);
@henriquemenezes
henriquemenezes / curl-upload-file.sh
Last active September 12, 2023 20:19
Using CURL to Upload Files
# curl - Raw upload
curl -X PUT -T image.png https://example.com/upload
# curl - Content-Type: multipart/form-data
curl -F name=logo -F file=@image.png https://example.org/upload
# curl - POST presigned URL (S3)
ROM ruby:2.2.3
RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y libpq-dev
RUN apt-get install -y ghostscript
RUN mkdir /app
WORKDIR /app
@henriquemenezes
henriquemenezes / .vimrc
Last active August 11, 2020 14:47
.vimrc
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim " set the runtime path to include Vundle
call vundle#begin() " and initialize
" Keep Plugin commands between vundle#begin/end.
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'

Javascript

function cpfMask(cleanValue) {
  return cleanValue.replace(/^(\d{3})(\d{3})(\d{3})(\d{2}).*/, '$1.$2.$3-$4');
}

function cnpjMask(cleanValue) {
  return cleanValue.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2}).*/, '$1.$2.$3/$4-$5');
}
[core]
editor = /usr/bin/vim
autocrlf = input
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg3 = log --graph --abbrev-commit --decorate --date=relative --all
lg = !"git lg1"
[init]
templatedir = ~/.git-templates
@henriquemenezes
henriquemenezes / pre-commit
Created March 8, 2016 20:33
Git's pre-commit hook to remove trailing whitespaces/tabs Raw
#!/bin/sh
#
# This will remove the trailing whitespaces from the files and add it again to be committed.
#
# Put this into ~/.git-templates/hooks/pre-commit, and chmod +x it.
# Detect platform
platform="win"
uname_result=`uname`
if [ "$uname_result" = "Linux" ]; then
@henriquemenezes
henriquemenezes / one-line-web-server.md
Created March 16, 2016 20:48
List of one-line web servers

One-line Web Servers

Python 2.x

python -m SimpleHTTPServer 8080

Python 3.x

@henriquemenezes
henriquemenezes / one-line-random-string-generators.md
Last active December 24, 2022 01:44
List of one-line random string generators

One-line Random String Generator

Python

CSPRNG (Cryptographically Secure Pseudo-Random Number Generator) functions:

  • os.urandom(n): return a string of n random bytes.
  • random.SystemRandom(): provides random functions that uses os.urandom().

Note: Don't use random module for PRNG for security purposes.