Skip to content

Instantly share code, notes, and snippets.

View hazmatzo's full-sized avatar

Zoe Madden-Wood hazmatzo

View GitHub Profile
@hazmatzo
hazmatzo / simple-es6-example.js
Created April 1, 2016 17:49
Simple ES6 Example
// ES6
// example 1
([param] [, param]) => {
statements
}
// example 2
param => expression
@hazmatzo
hazmatzo / simple-es5-example.js
Created April 1, 2016 17:54
Simple ES5 Example
// ES5
// example 1
function ([param] [, param]) {
statements
}
// example 2
function (param) {
return expression
@hazmatzo
hazmatzo / people-function-in-es5.js
Created April 1, 2016 17:55
People Function in ES5
function People() {
var self = this; // Some choose `that` instead of `self`.
self.size = 0;
setInterval(function addMorePeople() {
// The callback refers to the `self` variable of which
// the value is the expected object.
self.size++;
}, 1000);
}
@hazmatzo
hazmatzo / people-function-in-es6.js
Created April 1, 2016 17:56
People Function in ES6
function People() {
this.size = 0;
setInterval(() => {
this.size++;
}, 1000);
}
@hazmatzo
hazmatzo / implicit-return-example.js
Created April 1, 2016 17:57
Implicit Return Example
(param1, param2) => expression
// equivalent to: { return expression; }
@hazmatzo
hazmatzo / arrow-mapping-example.js
Created April 1, 2016 17:58
Arrow Mapping Example
var someArray = [1, 2, 3, 4]
someArray.map( num => num + 1);
@hazmatzo
hazmatzo / function-binding.js
Created April 1, 2016 17:59
Function Binding
function() { }.bind(this)
@hazmatzo
hazmatzo / credentials.rb
Created June 26, 2018 16:39
Shows the standard way to display credentials in Rails
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
@hazmatzo
hazmatzo / attaching_a_file_from_url.rb
Created June 26, 2018 16:56
This is how to attach a file from a URL in Active Storage.
filename = "resume.pdf"
uri = URI.parse(“https://someresume.com/resume.pdf”)
candidate.resume.attach(io: uri.open, filename: filename)
// String literal example
type Easing = "ease-in" | "ease-out";