Skip to content

Instantly share code, notes, and snippets.

View boriscy's full-sized avatar
🏠
Working from home

Boris Barroso boriscy

🏠
Working from home
  • Lead With Purpose
  • Samaipata, Bolivia
View GitHub Profile
@boriscy
boriscy / items-count.json
Last active September 24, 2015 22:34
JSON responses bonsaiERP API for items
{
"count": 88
}
@boriscy
boriscy / nginx.conf
Created May 25, 2015 19:27
Conf nginx
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
@boriscy
boriscy / test.rb
Last active August 29, 2015 14:16
Compare mongoHQ in heroku
require 'benchmark'
# 10 records
apis = ["42-507-32941", "42-507-32942", "42-507-32943", "42-507-32944", "42-507-32945", "42-507-32950", "42-507-32956", "42-501-35879", "42-507-32908", "42-507-32909"]
Benchmark.measure { WellIndex::Core.where(:api => apis).all }
# <Benchmark::Tms:0x0000000b156a48
# @real=0.481202381, # This
# @stime=0.0,
@boriscy
boriscy / convert_range.rb
Last active August 29, 2015 14:16
Convert ranges from old format to new
# convert from
# (0 - 21 - 71 - 121) : (0 - 0,491 - 0,563 - 0,66)
# to
# (0-20:0); (21-70:0.491); (71-120:0.563); (121:0.66)
require 'csv'
module ConvertRange
def self.convert(str)
ranges, values = str.split(":")
ranges.gsub!(/[^\d-]/, '')
class MigrateHstoreToJson < ActiveRecord::Migration
def up
rename_column :posts, :data, :data_hstore
add_column :posts, :data, :jsonb, default: {}, null: false, index: { using: 'gin' }
execute 'UPDATE "posts" SET "data" = json_object(hstore_to_matrix("data_hstore"))::jsonb'
remove_column :posts, :data_hstore
end
def down
rename_column :posts, :data, :data_jsonb
@boriscy
boriscy / authentication.rb
Created January 22, 2015 18:16
Models for polla
module Authentication
extend ActiveSupport::Concern
mattr_accessor :pepper, :stretches
attr_accessor :password, :password_confirmation
included do
validates_uniqueness_of :email, :if => "email.present?", :message => I18n.t("activerecord.errors.messages.existing_email"),
:allow_blank => true
blue = '#16A9E3'
green = '#7FC06B'
width = 300
height = 150
space = 40
x = d3.scale.ordinal()
.rangeRoundBands([0, width], 10)
@boriscy
boriscy / incomes_controller.rb
Last active October 14, 2017 08:05
Print to PDF using phantomjs
# Example controller
class IncomesController < ApplicationController
# Include the print
include Controllers::Print
# GET /incomes/1
def show
@income = present Income.find(params[:id])
respond_to do |format|
'use strict';
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var paths = {

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results