Skip to content

Instantly share code, notes, and snippets.

Blair Anderson blairanderson

Block or report user

Report or block blairanderson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

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"
View invoice-working.mjml
<mj-body background-color="#ccd3e0" font-size="13px">
<mj-section background-color="#fff" padding-bottom="20px" padding-top="20px">
<mj-column width="100%">
<mj-image src="" alt="" align="center" border="none" width="100px" padding-left="0px" padding-right="0px" padding-bottom="10px" padding-top="10px"></mj-image>
<mj-text align="center" color="#356cc7" font-size="13px" font-family="Helvetica" padding-left="25px" padding-right="25px" padding-bottom="28px" padding-top="28px">
<span style="font-size: 28px">Anderson & Associates</span><br/>
<span style="font-size: 20px">Invoice [[InvoiceDate]]</span>
blairanderson / downloader.rb
Created Jan 28, 2019
ActiveStorage Downloader takes attachment input and yields a tempfile
View downloader.rb
# frozen_string_literal: true
module ActiveStorage
class Downloader #:nodoc:
def initialize(blob, tempdir: nil)
@blob = blob
@tempdir = tempdir
def download_blob_to_tempfile
blairanderson / ruby_module_with_class_instance.rb
Created Nov 13, 2018
Ruby Module with Class and Instance methods extended
View ruby_module_with_class_instance.rb
module Persistence
def self.included(klass)
module ClassMethods
def all
puts 'all'
blairanderson / fromPdfToJpg
Created Jul 16, 2018 — forked from dvcama/fromPdfToJpg
bash: extract high-res images from pdf using imagemagick (recursively)
View fromPdfToJpg
# extract jpg from PDF
# based on a script edited by Purch
if [ -z $1 ];then echo Give target directory; exit 0;fi
find "$1" -depth -name '*.pdf' | while read file ; do
directory=$(dirname "$file")
oldfilename=$(basename "$file")
blairanderson /
Last active Feb 27, 2018
Easiest WYSIWYG implementation I have found. 2018 Edition

I found it very annoying how quickly these WYSIWYG editors go out of date.

The open sources ones have mostly rotted away, and the others are paid.

<% content_for :head do %>
  <%= stylesheet_link_tag('') %>
<% end %>
You can’t perform that action at this time.