Skip to content

Instantly share code, notes, and snippets.

View nateberkopec's full-sized avatar

Nate Berkopec nateberkopec

View GitHub Profile
@nateberkopec
nateberkopec / .block
Created July 14, 2017 21:26 — forked from mbostock/.block
Force-Directed Graph
license: gpl-3.0
height: 600
@nateberkopec
nateberkopec / 0.result.md
Last active January 18, 2024 11:20 — forked from tomfuertes/0.result.md
De-'Async Inject'ing Universal Analytics

De-'Async Inject' Universal Analytics

This gist applies the theory from Ilya Grigorik's Script-injected "async scripts" considered harmful on the default Universal Analytics snippet. TLDR place this above the CSS in the <head> of your document

<!-- Google Analytics Part 1: Creates window.ga, sets account, and queues pageview-->
<script>
  !function(n,t){n.GoogleAnalyticsObject=t,n[t]=n[t]||function(){(n[t].q=n[t].q||[]).push(arguments)},n[t].l=1*new Date}(window,"ga");
  ga('create', 'UA-XXXX-Y', 'auto'); // REPLACE UA-XXXX-Y w/ YOUR ACCOUNT
 ga('send', 'pageview');
#
# Insert an automatic text MIME part into HTML e-mail.
# (c) Daniel Doubrovkine, Art.sy 2012
# MIT License
#
class ActionMailerWithTextPart < ActionMailer::Base
def collect_responses(headers)
responses = super(headers)
html_part = responses.detect { |response| response[:content_type] == "text/html" }
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>*|Giver|* bought you a coffee tasting box subscription!</title>
</head>
<body leftmargin="0" marginheight="0" marginwidth="0" offset="0" topmargin="0" style="background-color:#bba993;-webkit-text-size-adjust:none;padding:0;margin:0;width:100%">
<center>
<table border="0" cellpadding="0" cellspacing="0" height="100%" id="backgroundTable" width="100%" style="margin:0;padding:0;width:100%;height:100%;background-color:#669999"><tr>
<td align="center" valign="top" style="border-collapse:collapse">
@nateberkopec
nateberkopec / db.rake
Created November 20, 2012 00:57 — forked from xaviershay/db.rake
db:structure:load for Rails 3.1
namespace :db do
namespace :test do |schema|
schema[:clone_structure].abandon
desc "OVERWRITTEN - load the development_structure file using psql shell"
task :clone_structure => ["db:structure:dump", "db:test:purge"] do
config = ActiveRecord::Base.configurations['test']
cmd = "psql #{psql_options} < db/development_structure.sql"
system cmd
end
@nateberkopec
nateberkopec / about.md
Created August 10, 2011 13:58 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer