Skip to content

Instantly share code, notes, and snippets.

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

Marco Montes marcomontes

🏠
Working from home
View GitHub Profile
export RAILS_ENV="production" ; ~/.rvm/bin/rvm default do bundle exec rails c
@marcomontes
marcomontes / Gemfile
Created November 30, 2016 22:38 — forked from slothelle/Gemfile
Deploying Rails 4 apps with Resque and Redis to Heroku using Unicorn with a Procfile.
# and whatever other gems you need
gem 'resque', '~> 1.24.1'
gem 'unicorn', '~> 4.6.2'
@marcomontes
marcomontes / gist:75aebbde882c71f866ef05045edff732
Last active October 8, 2016 04:39
Fixed removing system installed wkhtmltopdf and using the binary of wkhtmltopdf (Ubuntu 12.04)taken from : http://stackoverflow.com/questions/9672070/wicked-pdf-on-production-server/9687535#9687535

Uninstall the wkhtmltopdf package:

apt-get remove wkhtmltopdf --purge

cd /usr/local/bin
sudo curl -C - -O http://download.gna.org/wkhtmltopdf/obsolete/linux/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
sudo tar -xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
rm wkhtmltopdf-0.9.9-static-amd64.tar.bz2
ln -s wkhtmltopdf-amd64 wkhtmltopdf
@marcomontes
marcomontes / capybara cheat sheet
Last active August 28, 2015 16:15 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@marcomontes
marcomontes / tinder-api-documentation.md
Last active August 29, 2015 14:27 — forked from rtt/tinder-api-documentation.md
Tinder API Documentation

Tinder API documentation

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

Note: this was written in April/May 2014 and the API may have changed since

API Details

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
@marcomontes
marcomontes / download_zip.rb
Created June 11, 2015 14:43
Get images from Class, pack into Zip file and upload to S3. Notify user by mail with url for zip file
class << self
def download_zip(user, photo_ids)
photos = SurveyPhoto.find photo_ids.gsub(' ', ',').split(",")
zipfile_name = File.join(Rails.root, "tmp", "archive.zip")
Zip::ZipOutputStream.open(zipfile_name) do |zipfile|
photos.each do |photo|
if photo.image.present?
zipfile.put_next_entry("#{Time.now.strftime('%M%S')}-#{photo[:image]}")
@marcomontes
marcomontes / currency_format.rb
Last active August 29, 2015 14:22
Currency Format - Convierte un número a formato de moneda, con símbolo y delimitadores
def currency_format(number, options={})
options = {:currency_symbol => "$", :delimiter => ".", :decimal_symbol => ",", :currency_before => true, :no_decimal => true}.merge(options)
# split integer and fractional parts
int, frac = ("%.2f" % number).split('.')
# insert the delimiters
int.gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
if options[:no_decimal]
frac_part = ""
@marcomontes
marcomontes / calculo_tiempo.rb
Created June 11, 2015 14:23
Sistema parqueadero - calculo de tiempo
def calculo_tiempo(tiempo = "hora")
if tiempo == "hora"
segundos = self.fecha_salida - self.fecha_entrada
horas = (segundos / 3600)
if self.fecha_salida.hour < self.fecha_entrada.hour
total_horas = 24 - self.fecha_entrada.hour + self.fecha_salida.hour
else
total_horas = horas
end
total_horas.round(2).ceil
@marcomontes
marcomontes / youtube_adapter.rb
Last active August 29, 2015 14:22
Funciones varias para extraer y validar info de youtube y crear thumbnails personalizados.
class YoutubeAdapter
def self.get_thumbnail(entry, size)
video_id = get_video_id entry.embed
case size
when 0 then "http://img.youtube.com/vi/#{video_id}/0.jpg"
when 1 then "http://img.youtube.com/vi/#{video_id}/1.jpg"
end
end