Skip to content

Instantly share code, notes, and snippets.

Working from home

Daniel Puglisi danielpuglisi

Working from home
View GitHub Profile
View add_signature_fields_to_delayed_jobs.rb
class AddFieldsToDelayedJobs < ActiveRecord::Migration
def change
add_column :delayed_jobs, :signature, :string
add_index :delayed_jobs, :signature
danielpuglisi / test_helper.rb
Last active Jul 29, 2019 — forked from abarrak/test_helper.rb
Perform Enqueued Mail Job in Rails 6 Tests
View test_helper.rb
# 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)
danielpuglisi / static_map_helper.rb
Last active Jan 27, 2017 — forked from mcasimir/static_map_helper.rb
Google Maps Static map helper for Ruby on Rails
View static_map_helper.rb
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 /
Last active Sep 2, 2015 — forked from jaimeiniesta/
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 = "//"
sumo.setAttribute('data-sumo-site-id', 'your sumo me ID')
(document.getElementsByTagName("head")[0] or document.getElementsByTagName("body")[0]).appendChild(sumo)
# Fix postgres after OSX crashed
pg_resetxlog /usr/local/var/postgres
rm /usr/local/var/postgres/
pg_resetxlog /usr/local/var/postgres
pg_resetxlog -f /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
danielpuglisi / users_controller.rb
Last active Aug 9, 2021
Rails examples: Single Table Inheritance (STI), strong parameters, single controller.
View users_controller.rb
# Variant 1
def user_params(type)
# Variant 2
def user_params(type)
case type
when "user"
danielpuglisi /
Last active May 24, 2016 — forked from minrk/
doing some magic for making pandoc work on heroku
# bring up the vagrant VM
sudo apt-get install vagrant
git clone
cd vagrant-haskell-heroku
vagrant up
vagrant ssh
# run this in vagrant shell
cabal update
cabal install cabal-install
danielpuglisi / .gitignore
Last active Dec 21, 2015
Rails ENV variables: heroku development setup
View .gitignore
# other stuff
# other stuff
danielpuglisi / helpers.rb
Created Jul 23, 2013
Seiten application controller helper methods, inspired by devise
View helpers.rb
module Seiten
module Controllers
# Those helpers are convenience methods added to ApplicationController.
module Helpers
extend ActiveSupport::Concern
def current_page
@current_page ||= Seiten::Page.find_by_slug(request.fullpath)
danielpuglisi / spec_helper.rb
Created May 8, 2013
Configure rspec or test/unit to autoreload factories with spring after they have changed.
View spec_helper.rb
RSpec.configure do |config|
config.before(:all) do