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
@blairanderson
blairanderson / conv.sh
Last active Sep 11, 2019
Optimize Videos for Web - Compress MP4 and remove Audio with FFMPEG. encodes as 264 with CRF 30, scales down to 1920x1080, strips audio
View conv.sh
#! /bin/bash
# The Purpose of this Script is to batch convert and compress any video file to mp4 format
#
# WARNING: LOSSY COMPRESSION !!!
# Variable used:
# sourcedir is the directory where to be converted videos are. Converted video will be saved in the same folder
# usage:
View keybase.md

Keybase proof

I hereby claim:

  • I am blairanderson on github.
  • I am blairanderson (https://keybase.io/blairanderson) on keybase.
  • I have a public key ASBO7gg1K05ibXO41y3bjm2-S6xY6ixX2Zft1TXd2wJNkwo

To claim this, I am signing this object:

@blairanderson
blairanderson / DependencyInjectionInRuby.md
Last active Sep 5, 2019
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.
View DependencyInjectionInRuby.md

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

View rails-query-by-email-domain.md

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
blairanderson / radio-html.md
Created Mar 11, 2017
5 star rating system HTML using radio buttons. credit to https://jsfiddle.net/leaverou/CGP87/
View radio-html.md
<fieldset class="rating">
    <legend>Please rate:</legend>
    <input type="radio" id="star5" name="rating" value="5" /><label for="star5" title="Rocks!">5 stars</label>
    <input type="radio" id="star4" name="rating" value="4" /><label for="star4" title="Pretty good">4 stars</label>
    <input type="radio" id="star3" name="rating" value="3" /><label for="star3" title="Meh">3 stars</label>
    <input type="radio" id="star2" name="rating" value="2" /><label for="star2" title="Kinda bad">2 stars</label>
    <input type="radio" id="star1" name="rating" value="1" /><label for="star1" title="Sucks big time">1 star</label>
</fieldset>
@blairanderson
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
# ["first@email.com,second@email.com"]
def email_cc_list=(list)
write_attribute(:email_cc_list,
Array.wrap(list).first.split(",").uniq.join(",")
)
end
# is it possible the array ever holds more than 1 value?
@blairanderson
blairanderson / ruby-pipe-ampersand.md
Last active Jun 25, 2019
Ruby: Union and Intersection Guide ( Pipe | and Ampersand & operators )
View ruby-pipe-ampersand.md

Ruby Array Pipe | (Union) and Ampersand &(Intersection) operators

&, intersection, overlap

The ampersand is an array method that returns the overlapping items.

ary & other_ary → new_ary

Also known as Set Intersection

@blairanderson
blairanderson / recipe.md
Last active Jun 23, 2019
Spring Rolls with Fresh Prawns and Spicy Peanut Dipping Sauce
View recipe.md

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
blairanderson / jekyll.html
Last active Jun 12, 2019
Fullscreen Background Video Slideshow on iOS devices - note currently uses jquery :)
View jekyll.html
{% for video in site.static_files %}
{% if video.path contains 'img/videos' %}
<video muted playsinline>
<source src="{{ site.baseurl }}{{ video.path }}" type="video/mp4">
</video>
{% endif %}
{% endfor %}
You can’t perform that action at this time.