Skip to content

Instantly share code, notes, and snippets.

View igorescobar's full-sized avatar
🐕

Igor Escobar igorescobar

🐕
View GitHub Profile
@igorescobar
igorescobar / rails_db_migrate.sh
Created February 16, 2016 20:21
The correct way to run rails db migration on AWS Beanstalk (Docker Container Environment)
#!/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 January 19, 2017 02:25
Small script to convert an Build Pipeline View to a Markdown table
/*
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 August 18, 2015 22:40
Registering global mustache helpers
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 August 18, 2015 14:07
OpsWorks -> Elastic Beanstalk EnvVars
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 10:15
Docker useful commands
# 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 20:52
Testing sequelizejs success callback with mocked data
/*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 December 27, 2015 16:29
This mask validates if the typed number is hight than 10.00 and lower than 100.00
// 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) {
$(".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 July 6, 2013 14:10
Object.keys - Javascript
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 April 26, 2013 13:31
This command executes a full MySQL dump on a remote machine and transfers it back to your local machine.
ssh user@host "mysqldump --lock-tables=0 -h HOST -u USER -pPASSWORD --all-databases | gzip -c" > ~/full_mysql_dump.sql.gz