Skip to content

Instantly share code, notes, and snippets.

View lbriones's full-sized avatar

Luis Briones lbriones

  • Santiago, Chile
View GitHub Profile
plan = Plan.find(plan_id)
@preapproval_plan = HTTParty.put("https://api.mercadopago.com/preapproval_plan/#{plan.preapproval_plan_id}",
headers: { "Content-Type" => "application/json", 'Authorization' => "Bearer #{ENV['MP_ACCESS_TOKEN']}" },
body: {
back_url: "#{ENV['APP_URL']}/mercadopago",
reason: plan.name,
auto_recurring: {
#actualizar información adicional
transaction_amount: plan.amount
}
@lbriones
lbriones / ruby_ocr.rb
Created March 21, 2022 23:47 — forked from dshorthouse/ruby_ocr.rb
OCR Image-based PDF in ruby
require 'parallel'
require 'rtesseract'
require 'mini_magick'
source = "/MyDirectory/my.pdf"
doc = {}
pdf = MiniMagick::Image.open(source)
Parallel.map(pdf.pages.each_with_index, in_threads: 8) do |page, idx|
tmpfile = Tempfile.new(['', '.tif'])
MiniMagick::Tool::Convert.new do |convert|
@lbriones
lbriones / README.md
Created March 12, 2018 20:16 — forked from chrisjhoughton/README.md
Notify tray workflows "webhook style" from Salesforce using Apex triggers.

Salesforce Apex trigger notifications for tray.io

Salesforce's Apex triggers allow you to trigger tray workflows in real-time, based on events that occur in Salesforce. Events include things like:

  • New lead creations
  • Opportunity updates, such as the status moving from "open" to "closed"

Salesforce doesn't support webhooks out of the box, so we'll need to add some Apex code to your Salesforce account to notify tray at the right time.

@lbriones
lbriones / Capistrano Commands
Created December 4, 2017 01:11 — forked from NicoMarchant/Capistrano Commands
Deploy Rails 4 to AWS EC2(Ubuntu 14.04.4 LTS). Nginx, Puma, Capistrano3, PostgreSQL, RVM.
Capistrano::Rails::Db
cap production deploy:db:abort_if_pending_migrations # Run rake db:abort_if_pending_migrations
cap production deploy:db:create # Run rake db:create
cap production deploy:db:drop # Run rake db:drop
cap production deploy:db:migrate # Run rake db:migrate Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
cap production deploy:db:migrate:down # Run rake db:migrate:down Run the "down" for a given migration VERSION
cap production deploy:db:migrate:redo # Run rake db:migrate:redo Rollback the database one migration and re migrate up (options: STEP=x, VERSION=x)
cap production deploy:db:migrate:reset # Run rake db:migrate:reset Reset your database using your migrations
cap production deploy:db:migrate:status # Run rake db:migrate:status Display status of migrations
cap production deploy:db:migrate:up # Run rake db:mi
@lbriones
lbriones / Capistrano Commands
Created December 4, 2017 01:11 — forked from NicoMarchant/Capistrano Commands
Deploy Rails 4 to AWS EC2(Ubuntu 14.04.4 LTS). Nginx, Puma, Capistrano3, PostgreSQL, RVM.
Capistrano::Rails::Db
cap production deploy:db:abort_if_pending_migrations # Run rake db:abort_if_pending_migrations
cap production deploy:db:create # Run rake db:create
cap production deploy:db:drop # Run rake db:drop
cap production deploy:db:migrate # Run rake db:migrate Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
cap production deploy:db:migrate:down # Run rake db:migrate:down Run the "down" for a given migration VERSION
cap production deploy:db:migrate:redo # Run rake db:migrate:redo Rollback the database one migration and re migrate up (options: STEP=x, VERSION=x)
cap production deploy:db:migrate:reset # Run rake db:migrate:reset Reset your database using your migrations
cap production deploy:db:migrate:status # Run rake db:migrate:status Display status of migrations
cap production deploy:db:migrate:up # Run rake db:mi
@lbriones
lbriones / README.md
Created October 1, 2017 07:59 — forked from Oxicode/README.md
Install wkhtmltopdf on Ubuntu 14.04 64-bit

Install wkhtmltopdf on Ubuntu

This was tested on:

  • Ubuntu 14.04 x64
  • Ubuntu 16.04 x64

Step 1

Install the xvfb server by running

@lbriones
lbriones / obtener_costo_envio_paquete.php
Created January 13, 2017 18:11 — forked from baamenabar/obtener_costo_envio_paquete.php
Obtener costos de envío por Chilexpress, usando el formulario de cálculo que tienen ellos. A falta de un API, hay que hacerse uno. Todo mérito a @nikoskip
<?php
/**
* Una simple función para obtener los costos de envío de un paquete mediante Chilexpress.
* Como única dependencia se necesita de la liberia PHP Simple HTML DOM Parser: http://simplehtmldom.sourceforge.net/
*
* Para poder comunicarse con Chilexpress, se debe tener la lista de todas las comunas que ellos utilizan y el código
* que le asignan a cada una. En este archivo, al final, podrás encontrar el listado, el cual podrás parsear fácilmente
*/
@lbriones
lbriones / new.html.erb
Created October 29, 2015 02:02 — forked from YerkoPalma/new.html.erb
Actualización de dropdown de comunas en base a regiones en rails (sin ajax)
<%= form_for(:user, :url => {:action => 'create', :controller=>"users"}, :class => "col s12") do |f| %>
<% cities_array = @regiones.map { |city| [city[:nombre], city[:codigo]] } %>
<%= f.select( :region, options_for_select(cities_array), {}, {}) %>
<%= f.label :region %>
<%= f.select(:comuna, [], {}, {}) %>
<%= f.label :comuna %>
<button type="submit" name="action">Siguiente</button>
@lbriones
lbriones / Contract Killer 3.md
Created August 7, 2015 22:09
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post