Skip to content

Instantly share code, notes, and snippets.


Blair Anderson blairanderson

View GitHub Profile
blairanderson / fetch.rake
Last active Jul 22, 2020
Rakefile for fetching the current dist/sass/etc folders from the bootstrap and tachyons GitHub repository
View fetch.rake
namespace :fetch do
desc "fetch tachyons scss files"
task :tachyons do
`curl -LkSs | tar xz`
`mv -f ./tachyons-sass-*/scss ./_sass/tachyons-sass`
`mv -f ./tachyons-sass-*/tachyons.scss ./_sass/tachyons-sass`
`rm -rf ./tachyons-sass-*`
desc "fetch bootstrap scss files"
blairanderson / extract.rb
Created May 14, 2020
write JSON file data to multiple files [ruby]
View extract.rb
require 'active_support'
require 'active_support/core_ext'
require 'json'
JSON.parse("./_data/companies.json").read).each do |company|"./_companies/#{company['name'].parameterize}.md", "w") do |f|
f.write "---\n"
f.write "layout: company\n"
f.write "title: #{company['name']}\n"
f.write "categories: prep\n"
blairanderson / gist:f0b49fb84abfb56e32f13395ddba0196
Created Mar 5, 2020
idea for rails ETL with ActiveStorage
View gist:f0b49fb84abfb56e32f13395ddba0196
class HighAvailabilityETL < RailsFoo
has_one_attached :input
has_one_attached :translate_step1
has_one_attached :translate_step2
has_one_attached :translate_step3
has_one_attached :output
def runner
step1_errors = input_to_translate_step1! unless input.attached?
step2_errors = step1_to_step2! unless translate_step1.attached?
blairanderson / gist:40eb58d41a7f8a4271f01e3453b69154
Created Nov 7, 2019
DIRECT FULFILMENT (lead time calculation)
View gist:40eb58d41a7f8a4271f01e3453b69154
1. download all orders from
2. Move column Y to column E
3. Remove timezone string from the columns D & E
4. column F =ROUND(24*(E2-D2),1)
blairanderson / transfer.rb
Created Nov 5, 2019
Ruby / Rails transfer files from SFTP to FTP folder
View transfer.rb
# ftp_uri is calculated from environment variable and database encrypted account/password
class Transfer
def transfer
require 'net/sftp'
require 'net/ftp'
current_business = Business.find(business_id)
old_directory = "/orders/"
directory = "orders"
sftpuri = current_business.sftp_uri

Keybase proof

I hereby claim:

  • I am blairanderson on github.
  • I am blairanderson ( on keybase.
  • I have a public key ASBO7gg1K05ibXO41y3bjm2-S6xY6ixX2Zft1TXd2wJNkwo

To claim this, I am signing this object:


A simple way to add querying by email

# frozen_string_literal: true

module DomainQuery
  extend ActiveSupport::Concern

  class_methods do
    def by_email(domain=nil)
blairanderson / rails-email-multiple.rb
Last active Jul 1, 2019
RAILS email input with multiple=true
View rails-email-multiple.rb
# simple_form sends params inside an array
# [","]
def email_cc_list=(list)
# is it possible the array ever holds more than 1 value?
blairanderson /
Last active Jun 23, 2019
Spring Rolls with Fresh Prawns and Spicy Peanut Dipping Sauce

Easy Peanut Dipping Sauce

  • 125g (1/2 cup) creamy peanut butter
  • 35g (2 tbsp) hoisin sauce
  • 20g (4 tsp) soy sauce
  • 1 clove garlic
  • 10g (2 tsp) Sriracha
  • 25g (2 tbsp) warm water
  • tablespoon crushed peanuts
  • sprinkle of crushed red pepper
blairanderson / asin-to-dims.rb
Created Mar 16, 2019
get the product matches
View asin-to-dims.rb
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("")
request =
request["Authority"] = ""
request["Upgrade-Insecure-Requests"] = "1"
request["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36"
request["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"
You can’t perform that action at this time.