Skip to content

Instantly share code, notes, and snippets.

View igorescobar's full-sized avatar
🐕

Igor Escobar igorescobar

🐕
View GitHub Profile
@igorescobar
igorescobar / clean-junk.sh
Last active November 21, 2017 14:49
Clean junk files from vendor/bundle directory
#!/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 September 14, 2012 20:35
Mascara Javascript para os novos telefones de São Paulo
// 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 March 3, 2017 14:22
Connect to a PRIVATE machine through a PUBLIC machine.
# 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
@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 |
|-------------|:------------------------------:|
// e.g: @include truncate(.875em, 1.4, 10)
@mixin truncate($font-size, $line-height, $lines-to-show) {
display: block; // Fallback for non-webkit
display: -webkit-box;
max-width: 400px;
height: $font-size*$line-height*$lines-to-show; // Fallback for non-webkit
font-size: $font-size;
line-height: $line-height;
-webkit-line-clamp: $lines-to-show;
@igorescobar
igorescobar / github-expand-comments.js
Last active August 23, 2016 13:42
Expand Github Pull Request Comment Bookmark
// add this as a bookbark on your browser
javascript:Array.from(document.getElementsByClassName('outdated-diff-comment-container')).forEach(l => l.classList.add('open'));
@igorescobar
igorescobar / fix-house-search.md
Last active June 17, 2016 15:34
Feature Request: Search for a new house using its approximation of a POI like a subway, mall or something like that.

Feature Request: Search for a new house using its approximation of a POI like a subway, mall or something like that.

Here is how you can achieve it:

  1. When your user are adding a new house for sale/rent they also provide its address.
  2. With this address you are able to convert it to a latitute,longitude (x,y).
  3. With this x,y you are able to use a service like Google Places API and store on your database the proximity of a lot of useful POIs from the house itself.
  4. Now that you have all those nearby POIs stored and its distances from the provided address, you are able to provide a freaking awesome search for your users.
  5. Now you can for example search for a house or appartment, for rent, in Lisbon, which is 1-2km near of a subway or a train station.
  6. How? With postgres you can use extensions like cube or earthdistance. Or with a no-sql solution using Geospatial index (2d).
@igorescobar
igorescobar / docker-compose.yml
Last active May 27, 2016 10:07
Two neo4j containers on the same local network without sharing data.
# based on @spacecowboy at https://github.com/neo4j/docker-neo4j/issues/34
version: '2'
services:
neo4j:
image: neo4j
ports:
- "7474:7474"
networks:
- basic-lan
@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) {
@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;
}