Skip to content

Instantly share code, notes, and snippets.

View panchew's full-sized avatar

Francisco Guzmán panchew

View GitHub Profile
@panchew
panchew / _form.html.erb
Created June 23, 2023 17:27
For HelloText
<%= form_with(model: section, url: url, local: true, class: 'form', id: 'product_section_form') do |f| %>
<% if section.errors.any? %>
<div id="error_explanation">
<h3><%= pluralize(section.errors.count, "error") %> prohibited this product section from being saved:</h3>
<ul>
<% section.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
$.each box, (key, value) ->
# Insert a container with a 'Click to sign' button that replaces the signature (mobile devices)
mobileSignatureContainer = '<div id="mobile-signature-container">'
mobileSignatureContainer += '<img id="signature_img_' + $(value).data('component-id') + '" class="signature-img" data-component-id="'
mobileSignatureContainer += $(value).data('component-id') + '"><br/>'
mobileSignatureContainer += '<a href="#" id="sign_button_' + $(value).data('component-id') + '" class="btn btn-info btn-xs mobile-sign-button" '
mobileSignatureContainer += 'data-component-id="' + $(value).data('component-id') + '">Click to sign</a>'
mobileSignatureContainer += '</div>'
$(value).parent().before(mobileSignatureContainer)
@panchew
panchew / heroku_rails_phantomjs.md
Created August 7, 2016 04:24 — forked from edelpero/heroku_rails_phantomjs.md
Heroku, Ruby on Rails and PhantomJS

#Heroku, Ruby on Rails and PhantomJS

In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).

Let’s get started. This is a high-level overview of the required steps:

  • Modify your app to use multiple Heroku buildpacks.
  • Extend your app to use both the Ruby as well as the PhantomJS buildpacks.
  • Confirm that everything worked.
@panchew
panchew / survey_output.yml
Created September 13, 2011 14:07
survey output
---
result_ok: true
data:
id: "630114"
team: "0"
_type: Survey
_subtype: Standard Survey
status: Launched
created_on: 2011-09-06 20:48:04
modified_on: 2011-09-07 13:17:23
@panchew
panchew / rspec_output
Created May 21, 2011 00:15
I am SOOOO fired
ETL environment loaded
........
.FF.....FF..FF....FFFFFFFFFFFFF.............FF.F...........................F.......................................................F...............................................F........................F........................F...............FF...F.........FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.....
7:13 PM
Finished in 167.74 seconds
566 examples, 322 failures
@panchew
panchew / gist:661883
Created November 3, 2010 23:15
WatermarkConsoleOutput
>> example_image_path = "#{RAILS_ROOT}/public/images/wallpaper_original.jpg"
=> "/Users/flamaspeed/creative-allies/public/images/wallpaper_original.jpg"
>> example_image_output_path = "#{RAILS_ROOT}/public/images/wallpaper_watermarked.jpg"
=> "/Users/flamaspeed/creative-allies/public/images/wallpaper_watermarked.jpg"
>> apply_watermark(example_image_path, example_image_output_path)
user system total real
0.020000 0.040000 0.060000 ( 1.123081)
user system total real
0.020000 0.010000 0.030000 ( 0.048455)
user system total real
@panchew
panchew / gist:661917
Created November 3, 2010 23:57
WatermarkConsoleOutputAfterTweak
>> example_image_path = "#{RAILS_ROOT}/public/images/wallpaper_original.jpg"
=> "/Users/flamaspeed/creative-allies/public/images/wallpaper_original.jpg"
>> example_image_output_path = "#{RAILS_ROOT}/public/images/wallpaper_watermarked.jpg"
=> "/Users/flamaspeed/creative-allies/public/images/wallpaper_watermarked.jpg"
>> apply_watermark(example_image_path, example_image_output_path)
user system total real
0.090000 0.030000 0.120000 ( 10.781697)
user system total real
0.030000 0.030000 0.060000 ( 1.791267)
=> #<Magick::Image: (destroyed)>

Imagine a lotto contest with 48 numbers; you can buy tickets with a 6 number combination. To win the lotto contest, your combination must match the 6 numbers of the winning combination.

You have to write a ruby program (of course observing BDD) that will randomly generate 8 combinations with 6 numbers each. The numbers from 1 to 48 can not be repeated among combinations.

After the tickets generator is finished, you will have to add the ability to enter a winning combination and the program will must respond with the number of winning numbers matches in each ticket.

Extra point if you extend the array class to achieve the goal instead of using ruby's built in methods...

Good luck!

A library that uses the Postmark-Server-Token:
- It should handle POST requests with data of the bounce
- It should parse the params to create an ActiveRecord instance and store the data in a DB
- It should return a status code to the webhook
- It should have logic to (maybe?) have external input to decide to attempt re-send (activate)
module PostMark
class API
include HTTParty
base_uri 'https://api.postmarkapp.com'
attr_accessor :token
# X-Postmark-Server-Token
def initialize(token)