Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View danielpuglisi's full-sized avatar
💭
🤘

Daniel Puglisi danielpuglisi

💭
🤘
View GitHub Profile
@danielpuglisi
danielpuglisi / sumome.js.coffee
Last active September 2, 2015 13:38 — forked from jaimeiniesta/setup_sumo_me.js.coffee
How to load SumoMe script in a turbolinks-friendly way
$ ->
$(document).on("page:change", ->
sumo = document.createElement("script")
sumo.type = "text/javascript"
sumo.async = true
sumo.src = "//load.sumome.com/"
sumo.setAttribute('data-sumo-site-id', 'your sumo me ID')
(document.getElementsByTagName("head")[0] or document.getElementsByTagName("body")[0]).appendChild(sumo)
)
# Convert a locations response to an Array of Location Objects
#
# response - The Hash object from an API response
#
# Returns an array of Location objects, returns nil if the Hash is empty
def self.objectify(response)
response.empty? ? nil : response.map {|station| Rtransport::Location.new(station)}
end
# Hook to save the html page of every failed features into the temp
# # file directory taht it can be checked after cucumber has finished running.
require 'fileutils'
FAILED_FEATURES_PAGES_PATH = File.join Rails.root, 'tmp', 'failed_features'
FAILED_FEATURES_IMAGES_PATH = File.join Rails.root, 'tmp', 'failed_features_images'
FileUtils.rm_rf FAILED_FEATURES_PAGES_PATH
FileUtils.rm_rf FAILED_FEATURES_IMAGES_PATH
@danielpuglisi
danielpuglisi / build_pandoc_for_heroku.sh
Last active May 24, 2016 16:33 — forked from minrk/build_pandoc_for_heroku.sh
doing some magic for making pandoc work on heroku
# bring up the vagrant VM
sudo apt-get install vagrant
git clone https://bitbucket.org/puffnfresh/vagrant-haskell-heroku.git
cd vagrant-haskell-heroku
vagrant up
vagrant ssh
# run this in vagrant shell
cabal update
cabal install cabal-install
@danielpuglisi
danielpuglisi / static_map_helper.rb
Last active January 27, 2017 14:54 — forked from mcasimir/static_map_helper.rb
Google Maps Static map helper for Ruby on Rails
module StaticMapHelper
def static_map_for(location, options = {})
params = {
center: [location.latitude, location.longitude].join(","),
zoom: 15,
size: "300x300",
scale: 2,
markers: [location.latitude, location.longitude].join(","),
sensor: true,
@danielpuglisi
danielpuglisi / test_helper.rb
Last active July 29, 2019 09:40 — forked from abarrak/test_helper.rb
Perform Enqueued Mail Job in Rails 6 Tests
# Extend in your test_helper.rb or any other `/support` setup you have.
class ActiveSupport::TestCase
# === NOTICE:
# Ensure you have included `ActionMailer::TestHelper` in the test class ..
#
# This method performs any enqueued job during tests manually,
# Helpful when testing the queueing of your jobs and then the result of their execution.
#
# === Author: (abarrak, danielpuglisi)
class AddFieldsToDelayedJobs < ActiveRecord::Migration
def change
add_column :delayed_jobs, :signature, :string
add_index :delayed_jobs, :signature
end
end