Skip to content

Instantly share code, notes, and snippets.

🐕

Igor Escobar igorescobar

🐕
View GitHub Profile
@igorescobar
igorescobar / getJpegQuality.js
Created May 15, 2020 — forked from FranckFreiburger/getJpegQuality.js
pure JavaScript jpeg quality value recover
View getJpegQuality.js
// javascript jpeg decoder: https://github.com/eugeneware/jpeg-js/blob/79c4c7ea876d2e7b46981a563fcc4ae8f9e19849/lib/decoder.js
// Determine the JPEG compression quality from the quantization tables: https://github.com/ImageMagick/ImageMagick/blob/59f28acff016f6ae5e8b7e6300bcdf97e94affc9/coders/jpeg.c#L879
// JPEG File Layout and Format: http://vip.sugovica.hu/Sardi/kepnezo/JPEG%20File%20Layout%20and%20Format.htm
// jpeg constants: https://github.com/LuaDist/libjpeg/blob/6c0fcb8ddee365e7abc4d332662b06900612e923/jpeglib.h#L45
function getQuantizationTables(data) {
var quantizationTables = []
var dctZigZag = new Int32Array([
@igorescobar
igorescobar / imageboss-url.js
Last active May 16, 2020
Generating ImageBoss URLs with JavaScript
View imageboss-url.js
function mountImageBossUrl(src, { source, operation, cover_mode, width, height, options }) {
var serviceUrl = 'https://img.imageboss.me';
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
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 / 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
View Preferences.sublime-settings
{
"ensure_newline_at_eof_on_save": true,
"font_size": 14,
"highlight_line": true,
"ignored_packages": [ "Vintage" ],
"rulers": [100],
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_automatic_white_space": true,
"trim_trailing_white_space_on_save": true
View multi-line-css-truncate-ellipsis.scss
// 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 Aug 23, 2016
Expand Github Pull Request Comment Bookmark
View github-expand-comments.js
// 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 Jun 17, 2016
Feature Request: Search for a new house using its approximation of a POI like a subway, mall or something like that.
View fix-house-search.md

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).
You can’t perform that action at this time.