Skip to content

Instantly share code, notes, and snippets.

@Startouf
Startouf / specification_pattern.rb
Created March 20, 2019 15:16
Specification pattern implementation for ActiveJob
class SpecificationJob < ApplicationJob
include JobSpecifications
around_perform do |_, block|
init_specifications # init a bunch of instance variables to remember status of specifications
block.call # calls the #perform method of jobs
run_registered_specifications # Actually run the specs
if specifications_all_passed?
execute_if_specifications_all_passed
else
@Startouf
Startouf / google_analytics_turbolinks5.js
Created August 20, 2016 22:09
Google Analytics for Turbolinks 5 (& Rails 5)
// Google Analytics code to work with Turbolniks 5
this.GoogleAnalytics = (function() {
function GoogleAnalytics() {}
GoogleAnalytics.load = function() {
var firstScript, ga;
window._gaq = [];
window._gaq.push(["_setAccount", GoogleAnalytics.analyticsId()]);
window._gaq.push(['_setAllowAnchor', true]);
{
"type": "home",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Don't Slack Evil Performance*"
},
"accessory": {
@Startouf
Startouf / readme.md
Last active August 31, 2022 08:53
Update CRD for helm traefik migration from 2.4 to 2.5
@Startouf
Startouf / script.js
Last active October 22, 2022 08:53
Modern UTM & Referral Cookie Replicator
<script id="gtm-modern-cookie-replicator">
/**
* Modern UTM & Referral Cookie Replicator
*
* Inspired from the UTMZ cookie replicator,
* whose goal was to makes a generally faithful representation
* of the old __utmz cookie from Classic Analytics. ;
*
* the "Modern" cookie replicator
* - stores and decodes the cookie as/from JSON format