Skip to content

Instantly share code, notes, and snippets.

View igorescobar's full-sized avatar

Igor Escobar igorescobar

View GitHub Profile
igorescobar / getJpegQuality.js
Created May 15, 2020 18:35 — forked from FranckFreiburger/getJpegQuality.js
pure JavaScript jpeg quality value recover
// javascript jpeg decoder:
// Determine the JPEG compression quality from the quantization tables:
// JPEG File Layout and Format:
// jpeg constants:
function getQuantizationTables(data) {
var quantizationTables = []
var dctZigZag = new Int32Array([
igorescobar / imageboss-url.js
Last active May 16, 2020 16:36
Generating ImageBoss URLs with JavaScript
function mountImageBossUrl(src, { source, operation, cover_mode, width, height, options }) {
var serviceUrl = '';
var template = '/:source/:operation/:options/';
if (operation === 'cover') {
template = '/:source/:operation::cover_mode/:widthx:height/:options/';
} else if (operation === 'width') {
template = '/:source/:operation/:width/:options/';
} else if (operation === 'height') {
template = '/:source/:operation/:height/:options/';
igorescobar / 01_sync_postgres_sequences.sql
Last active January 10, 2018 12:04
Syncing Postgres Sequences for All Tables
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 / delete_git_old_tags.rb
Created December 12, 2017 12:03
A utility for deleting old git tags
# 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"`
.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 /
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 /
Created March 3, 2017 14:22
Connect to a PRIVATE machine through a PUBLIC machine.
# put this in your ~/.ssh/config
HostName $ip
User $username
IdentityFile $identity_file_path
ProxyCommand ssh -q -W $private_ip:$private_local_port
User $username
IdentityFile $identity_file_path
// 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 / 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 /
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 / 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
version: '2'
image: neo4j
- "7474:7474"
- basic-lan