Skip to content

Instantly share code, notes, and snippets.

Avatar
🐕

Igor Escobar igorescobar

🐕
View GitHub Profile
@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 / jenkins-build-pipeline-to-markdown-table.js
Last active Jan 19, 2017
Small script to convert an Build Pipeline View to a Markdown table
View jenkins-build-pipeline-to-markdown-table.js
/*
Instructions:
1 - Open the Jenkins Pipeline View with your browser
2 - Open the console and execute the following code
3 - Copy the output and paste into your README.md
Your github README.md will never be the same ;o)
Example:
| CI | Build Pipeline: Project Name |
|-------------|:------------------------------:|
@igorescobar
igorescobar / mustache-global-helper.js
Created Aug 18, 2015
Registering global mustache helpers
View mustache-global-helper.js
function i18nLambda (text, render) {
text = dict[text] || text
return render(text)
}
var Context = mustache.Context
Context.prototype._lookup = Context.prototype.lookup
Context.prototype.lookup = function i18nLookup (name) {
return (name === 'i18n' ? i18nLambda : this._lookup(name)
}
@igorescobar
igorescobar / OpsWorks -> Elastic Beanstalk EnvVars.js
Created Aug 18, 2015
OpsWorks -> Elastic Beanstalk EnvVars
View OpsWorks -> Elastic Beanstalk EnvVars.js
var envVars = JSON.parse($('.code').text()).play2.env_vars
, output = []
;
Object.keys(envVars).forEach(function (key) {
output.push(key + '="' + envVars[key] + '"')
});
console.log(output.join(" "))
@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 / hal_builder_spec.js
Created May 20, 2014
Testing sequelizejs success callback with mocked data
View hal_builder_spec.js
/*globals describe, it, context*/
/*jslint node: true, indent: 2*/
'use strict';
var HalBuilder,
chai = require('chai'),
should = chai.should(),
assert = chai.assert,
expect = chai.expect,
@igorescobar
igorescobar / mask- number-input-validation.js
Last active Dec 27, 2015
This mask validates if the typed number is hight than 10.00 and lower than 100.00
View mask- number-input-validation.js
// http://jsfiddle.net/cKz5u/9/
var handleValidNumber = function (triggerValidation, el) {
var n = el.val(), arNumber = n.split(''),
isInValid = function(number) {
number = parseFloat(number, 2);
return number < 10.00 || number > 100.00;
};
if (n.length >= triggerValidation && isInValid(n)) {
while (isInValid(el.val()) && el.val().length > 0) {
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 / object.keys.js
Created Jul 6, 2013
Object.keys - Javascript
View object.keys.js
Object.keys = function (obj, k) {
k=[];
for (o in obj) {
obj.hasOwnProperty(obj[o]) && (k[k.length]=o);
}
return k;
}
@igorescobar
igorescobar / remote-mysql-dump-to-local-machina.sh
Created Apr 26, 2013
This command executes a full MySQL dump on a remote machine and transfers it back to your local machine.
View remote-mysql-dump-to-local-machina.sh
ssh user@host "mysqldump --lock-tables=0 -h HOST -u USER -pPASSWORD --all-databases | gzip -c" > ~/full_mysql_dump.sql.gz