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.
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)
A library that uses the Postmark-Server-Token:
- It should get delivery stats (to parse them by Type and detect whether or not iterate over bounces)
- It should get bounces (for those types whose count is greater than zero)
- It should get single bounce to parse details
- It should have logic to (maybe?) have external input to decide to attempt re-send (activate)
# I like using HTTParty but Typhoeus could work very well here.
Client::PortalController analysis.
What does it do?
It seems to take care of the requests related to proposals. It has an action that takes care of both showing and previewing a proposal (the type of viewing gets chosen in #info action. It also has #index but the way the controller is implemented doesn't seemt to be RESTful (not a resource in the routes file).
I can see there is logic enable via includes that could enable the 'presenter' design pattern, and in the #canvas action, I can see a bit of the 'template' design pattern, and also I can see there are calls to Amazon S3 service; also the proposals states and acceptance are handled by this controller as well as comments related to a single proposal. I noticed mailer logic for several actions: acceptance, set_status and show (although I can't see why ClientEmailer.deliver_proposal_accepted(proposal) is called in two different actions.
What I like about it.
@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: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)>