Skip to content

Instantly share code, notes, and snippets.

View nateberkopec's full-sized avatar

Nate Berkopec nateberkopec

View GitHub Profile
begin
require "awesome_print"
AwesomePrint.irb!
rescue LoadError => e
puts e
end
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
@nateberkopec
nateberkopec / Gemfile
Last active March 17, 2022 08:21
ActionCable isn't *really* a Rails 5 dependency.
# gem 'rails'
gem "activerecord"
gem "actionpack"
gem "actionview"
gem "actionmailer"
gem "activejob"
gem "activesupport"
gem "railties"
gem "sprockets-rails"
gem 'sqlite3'
@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');
#/usr/bin/env bash
rm -rf ./.pngs
rm -rf ./.gifs
mkdir .pngs
mkdir .gifs
ffmpeg -i $1 -r 10 ./.pngs/out%04d.png
sips -s format gif ./.pngs/*.png --out ./.gifs
gifsicle ./.gifs/*.gif --optimize=3 --delay=3 --loopcount --resize 720x405 --colors=255 > $1.gif
gifsicle --unoptimize $1.gif | gifsicle --dither --colors 48 --resize-fit-width 512 -O2 `seq -f "#%g" 0 2 213` -o $1.optimized.gif
rm -rf $1.gif
@nateberkopec
nateberkopec / patch.patch
Created July 22, 2015 20:38
Patch to make tests pass
diff --git a/activerecord/test/cases/tasks/postgresql_rake_test.rb b/activerecord/test/cases/tasks/postgresql_rake_test.rb
index 3187338..3dac83f 100644
--- a/activerecord/test/cases/tasks/postgresql_rake_test.rb
+++ b/activerecord/test/cases/tasks/postgresql_rake_test.rb
@@ -212,7 +212,7 @@ module ActiveRecord
def test_structure_dump_with_schema_search_path
@configuration['schema_search_path'] = 'foo,bar'
- Kernel.expects(:system).with("pg_dump -i -s -x -O -f #{@filename} --schema=foo --schema=bar my-app-db").returns(true)
+ Kernel.expects(:system).with("pg_dump", '-i', '-s', '-x', '-O', '-f', @filename, '--schema=foo --schema=bar', "my-app-db").returns(true)
@nateberkopec
nateberkopec / rolldie.rb
Last active August 29, 2015 14:17
rolldie.rb
#!/usr/bin/env ruby
def roll_die(die_string)
num_of_die, die_type = die_string.split("d").map(&:to_i)
(1..num_of_die).reduce(0) { |s, i| s + rand(die_type) + 1 }
end
puts roll_die(ARGV[0])
# We don't test javascript or styles in this part of the test suite (we do that
# in cucumber). This saves us from compiling these assets in our functional
# tests.
module Sprockets
module Rails
module Helper
def javascript_include_tag(*_args)
end
def stylesheet_link_tag(*_args)
@nateberkopec
nateberkopec / config.ru
Created January 10, 2015 20:16
True one-line Rails app
%w[rails rack/test action_controller].map{|r|require r};run Class.new(Rails::Application){config.secret_key_base=1;routes.append{root to:proc{[200,{},[]]}}}.initialize!
@nateberkopec
nateberkopec / Gemfile
Created January 10, 2015 20:11
One Line Rails App
source "https://rubygems.org"
gem "actionpack", "~> 4.2"
gem "railties", "~> 4.2"