Skip to content

Instantly share code, notes, and snippets.

View rmcsharry's full-sized avatar
💭
Building my own SaaS apps in Angular and Rails

Richard McSharry rmcsharry

💭
Building my own SaaS apps in Angular and Rails
View GitHub Profile
@rmcsharry
rmcsharry / faking_it.rb
Last active June 8, 2018 02:04
Using faker gem, creates a rake task to easily create people, address datasets ini one go ... customise to create whatever models and sizes you need!
require 'faker'
module FakingIt
# GNU License - copy, use, change as you see fit, just keep this header in place please
#
# by Richard McSharry 2016 based on Matt Hutchinson's gist
# see https://gist.github.com/matthutchinson/2654461
#
# Built/Tested with Ruby 2.3.1 and Rails 5.0.1
#
@rmcsharry
rmcsharry / blob64_snippet.ts
Last active May 22, 2017 21:16
Code snippet for Angular2 typescript to convert file to Blob64 encoded string
onFileChange(event){
let files = event.srcElement.files;
this.selectedFile = files[0];
if (files && this.selectedFile) {
let reader = new FileReader();
reader.onload = this._handleReaderLoaded.bind(this);
reader.readAsBinaryString(this.selectedFile);
}
}
class Bob
def reply_to(statement)
public_send("reply_to_#{Statement.build(statement).class}".downcase.to_sym)
rescue NoMethodError
default_reply
end
def reply_to_silence
"Fine. Be that way!"
end
@rmcsharry
rmcsharry / Clump.rb
Created July 19, 2019 08:19
A factory with no if statements inspired by Sandi Metz "Polly want a message" talk
class Clump
def initialize(spec:, input:)
@spec = spec
@possibilities = @input
end
def self.build(spec:, possibilities: [])
descendants.detect { |klass| klass.match?(spec) }.new(spec: spec, input: possibilities).lines
end

Keybase proof

I hereby claim:

  • I am rmcsharry on github.
  • I am rmcsharry (https://keybase.io/rmcsharry) on keybase.
  • I have a public key whose fingerprint is 1193 CC22 BA3A 5A22 BF57 D3AB D826 65AA 8271 F162

To claim this, I am signing this object: