Skip to content

Instantly share code, notes, and snippets.

@tigris
tigris / _test.rb
Last active December 18, 2015 04:39
Bug in Mail::Address
#!/usr/bin/env ruby
# encoding: utf-8
require 'bundler/setup'
require 'mail'
def formatted_email(name, email)
address = Mail::Address.new(email)
address.display_name = name
address.format
@tigris
tigris / rails3.log
Created August 19, 2013 07:26
rails caching bug
Site -> has_many :pages
> Rails.cache.fetch('test') { a = Array.new ; Site.all.each{|s| a.push(s) if s.pages.count > 1 } ; a }
Site Load (0.7ms) SELECT "sites".* FROM "sites"
(0.7ms) SELECT COUNT(*) FROM "pages" WHERE "pages"."site_id" = 2
(0.7ms) SELECT COUNT(*) FROM "pages" WHERE "pages"."site_id" = 1
=> [#<Site id: 2, designer_id: 4, url: "http://tigris.id.au/", created_at: "2012-09-11 01:18:07", updated_at: "2012-09-11 01:18:07">, #<Site id: 1, designer_id: 1, url: "http://tigris.id.au/", created_at: "2012-09-02 16:39:54", updated_at: "2013-08-01 03:15:47">]
> Rails.cache.fetch('test') { a = Array.new ; Site.all.each{|s| a.push(s) if s.pages.count > 1 } ; a }
=> [#<Site id: 2, designer_id: 4, url: "http://tigris.id.au/", created_at: "2012-09-11 01:18:07", updated_at: "2012-09-11 01:18:07">, :@new_record, false]
@tigris
tigris / README.md
Created July 21, 2014 10:30
nokogiri 1.6.3 install error OSX

System details

OSX -> 10.9.3

Homebrew

$ brew -v
Homebrew 0.9.5

libxslt

@tigris
tigris / .ebextensions__02_nginx_fix.config
Created January 18, 2016 08:03
Fix for elasticbeanstalk puma and serving of static files from the public folder
---
container_commands:
10_copy:
command: sudo cp -f config/nginx.conf /etc/nginx/conf.d/webapp.conf
20_reload:
command: sudo service nginx reload
@tigris
tigris / brownlow.rb
Created September 26, 2016 09:18
Convert game stats to brownlow votes
def brownlow_total(s)
disposals = s[:kicks] + s[:handballs]
disposal_modifier = case
when disposals > 40; then 10
when disposals > 30; then 5
when disposals > 20; then 1
else 0
end
marks_modifier = case
@tigris
tigris / untappd.rb
Created November 11, 2016 03:47
Scrape untappd checkins
#!/usr/bin/env ruby
require 'json'
require 'open-uri'
class UntappdApi
attr_accessor :access_token
def url_for(user_id, max_id)
"https://api.untappd.com/v4/user/checkins/#{user_id}?access_token=#{access_token}&max_id=#{max_id}&limit=50"
@tigris
tigris / RACK_ENV-in-rails
Last active February 15, 2018 00:39
Puma ignores RACK_ENV inside a rails app?
#-❯ docker run --rm -it -e RACK_ENV=production rails bash -c 'rails new test-app && cd test-app && puma'
create
create README.md
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/config/manifest.js
create app/assets/javascripts/application.js
@tigris
tigris / clownformation.yaml
Created December 4, 2019 23:49
Cloudfront S3 website
---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
Certificate:
Type: String
Hostname:
Type: String
Resources:
Bucket:
Type: AWS::S3::Bucket
@tigris
tigris / games.txt
Created October 1, 2020 05:17
List of xbox games on gamepass
a plague tale: innocence
absolver
ace combat™ 7: skies unknown
afterparty
age of wonders: planetfall
alan wake
alien: isolation
alvastia chronicles
ark: survival evolved
astroneer
@tigris
tigris / ruby2.6.7.log
Last active April 29, 2021 11:16
ruby-install ruby 2.6.7
>>> Installing ruby 2.6.7 into /Users/danial.pearce/.rubies/ruby-2.6.7 ...
>>> Installing dependencies for ruby 2.6.7 ...
Warning: automake 1.16.3_1 is already installed and up-to-date.
To reinstall 1.16.3_1, run:
brew reinstall automake
Warning: bison 3.7.6 is already installed and up-to-date.
To reinstall 3.7.6, run:
brew reinstall bison
Warning: [email protected] 1.1.1k is already installed and up-to-date.
To reinstall 1.1.1k, run: