Skip to content

Instantly share code, notes, and snippets.

🐕

Igor Escobar igorescobar

🐕
Block or report user

Report or block igorescobar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@igorescobar
igorescobar / imageboss-url.js
Last active Oct 27, 2019
Generating ImageBoss URLs with JavaScript
View imageboss-url.js
function mountImageBossUrl(src, { operation, cover_mode, width, height, options }) {
var serviceUrl = 'https://img.imageboss.me';
var template = '/:operation/:options/';
if (operation === 'cover') {
template = '/:operation::cover_mode/:widthx:height/:options/';
} else if (operation === 'width') {
template = '/:operation/:width/:options/';
} else if (operation === 'height') {
template = '/:operation/:height/:options/';
View valida-date-mask.js
$(".data").mask("AB/CD/0000", {
translation:{
A: {pattern: /[0-3]/},
B: {pattern: /[0-9]/},
C: {pattern: /[0-1]/},
D: {pattern: /[0-9]/},
},
onKeyPress: function(a, b, c, d) {
if (!a) return;
var m = a.match(/(\d{2})/g);
@igorescobar
igorescobar / rails_db_migrate.sh
Created Feb 16, 2016
The correct way to run rails db migration on AWS Beanstalk (Docker Container Environment)
View rails_db_migrate.sh
#!/bin/bash
# .ebextensions/scripts/db_migrate.sh
. /opt/elasticbeanstalk/hooks/common.sh
EB_SUPPORT_FILES=$(/opt/elasticbeanstalk/bin/get-config container -k support_files_dir)
EB_CONFIG_DOCKER_ENV_ARGS=()
while read -r ENV_VAR; do
EB_CONFIG_DOCKER_ENV_ARGS+=(--env "$ENV_VAR")
@igorescobar
igorescobar / git-spush.bash
Last active Apr 10, 2019
Git alias to run your maven tests before push your changes to remote
View git-spush.bash
git config alias.spush='!sh -c "mvn clean test && git push \$1 \$2 \$3"'
@igorescobar
igorescobar / docker-tips.sh
Last active May 3, 2018
Docker useful commands
View docker-tips.sh
# Clean unused images
docker image prune
# Clean up dangling volumes
docker volume rm $(docker volume ls -qf dangling=true)
# Stop all containers
docker stop $(docker ps -a -q)
@igorescobar
igorescobar / 01_sync_postgres_sequences.sql
Last active Jan 10, 2018
Syncing Postgres Sequences for All Tables
View 01_sync_postgres_sequences.sql
-- https://wiki.postgresql.org/wiki/Fixing_Sequences
SELECT 'SELECT SETVAL(' ||
quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) ||
', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM ' ||
quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
FROM pg_class AS S,
pg_depend AS D,
pg_class AS T,
pg_attribute AS C,
pg_tables AS PGT
@igorescobar
igorescobar / delete_git_old_tags.rb
Created Dec 12, 2017
A utility for deleting old git tags
View delete_git_old_tags.rb
# CUT_OFF_DATE needs to be of YYYY-MM-DD format
CUT_OFF_DATE = "2016-06-30"
def get_old_tags(cut_off_date)
`git log --tags --simplify-by-decoration --pretty="format:%ai %d"`
.split("\n")
.each_with_object([]) do |line, old_tags|
if line.include?("tag: ")
date = line[0..9]
tags = line[28..-2].gsub(",", "").concat(" ").scan(/tag: (.*?) /).flatten
@igorescobar
igorescobar / clean-junk.sh
Last active Nov 21, 2017
Clean junk files from vendor/bundle directory
View clean-junk.sh
#!/usr/bin/env bash
find ./vendor/bundle \( -name '__tests__' -o \
-name "*.md" -o \
-name "*LICENSE*" -o \
-name "*.ts" -o \
-name "*.jst" -o \
-name "*.coffee" -o \
-name "*.rdoc" -o \
-name "example" -o \
-name "examples" -o \
@igorescobar
igorescobar / phonemask.js
Created Sep 14, 2012
Mascara Javascript para os novos telefones de São Paulo
View phonemask.js
// using: https://github.com/igorescobar/jQuery-Mask-Plugin
// version: v0.5.0+
var SPphoneMask = function(phone, e, currentField, options){
return phone.match(/^(\(?11\)? ?9(5[0-9]|6[0-9]|7[01234569]|8[0-9]|9[0-9])[0-9]{1})/g) ? '(00) 00000-0000' : '(00) 0000-0000';
};
$(".sp_celphones").mask(SPphoneMask, {onKeyPress: function(phone, e, currentField, options){
$(currentField).mask(SPphoneMask(phone), options);
}});
@igorescobar
igorescobar / ssh_config.sh
Created Mar 3, 2017
Connect to a PRIVATE machine through a PUBLIC machine.
View ssh_config.sh
# put this in your ~/.ssh/config
Host public.host
HostName $ip
User $username
IdentityFile $identity_file_path
Host private.host
ProxyCommand ssh -q -W $private_ip:$private_local_port public.host
User $username
IdentityFile $identity_file_path
You can’t perform that action at this time.