Skip to content

Instantly share code, notes, and snippets.

View rileyhilliard's full-sized avatar

Riley Hilliard rileyhilliard

View GitHub Profile
@rileyhilliard
rileyhilliard / class-example.ts
Last active April 13, 2019 00:15
Class Example
// Example of a valid class instantiation that contains
// all the required class constructor object properties
import Person from 'person';
// Create a new person of the shape defined by our interfaces
const john = new Person ({
first: 'John',
last: 'Doe',
geo: {
country: 'USA',
@rileyhilliard
rileyhilliard / typescript-class-destructure.ts
Last active April 16, 2019 02:37
TypeScript Class Destructure
interface GeoInterface {
state: string;
country: string;
}
interface PersonInterface {
first: string;
last: string;
// a Person must contain a 'geo' object that matches
// the defined GeoInterface structure
@rileyhilliard
rileyhilliard / array-destructure.ts
Last active April 12, 2019 21:39
Array Destructure
// a 'Person' object requires 'first' and 'last'
// properties whose values are strings
interface Person {
first: string;
last: string;
}
// This defines that the first functional argument
// must be an Array of 'Person' objects, then destructs
// the first person's first and last name properties
const person = { first: 'John', last: 'Doe' };
/* -- Correct TypeScript Functional Destructure -- */
// Define a 'Person' interface with the shape of
// the expected Person object argument
interface Person {
first: string;
last: string;
}
@rileyhilliard
rileyhilliard / incorrect-destructure.ts
Last active April 7, 2019 23:44
Incorrect TypeScript Functional Destructure
const person = { first: 'John', last: 'Doe' };
/* -------------- TypeScript Function -------------- */
const hello1 = (first: string, last: string) =>
`Hello ${first} ${last}!`;
// outputs "Hello John Doe!"
hello1(person.first, person.last);
/* -- Incorrect TypeScript Functional Destructure -- */
@rileyhilliard
rileyhilliard / destructure.js
Created April 7, 2019 23:31
JS Functional Destructure
// JavaScript Functional Destructure
const hello = ({ first, last }) => `Hello ${first} ${last}!`;
const person = { first: 'John', last: 'Doe' };
// outputs "Hello John Doe!"
hello(person);
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
ascendingSort: ['shit:asc'],
randomSort: ['shit:fufdiosudf'],
descendingSort: ['shit:desc'],
defaultShit: ['shit'],
shitToSort: [1,5,2,7,3,9,5,3,0,9,2,-1,100].map(shit => {
return { shit };
@rileyhilliard
rileyhilliard / controllers.application.js
Created October 31, 2017 16:59
Undefined equality check
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
aPropertyThatsFalsey: 'NOT_CTA_BOTTOM',
aPropertyThatsTruthy: 'CTA_BOTTOM',
init() {
this._super(...arguments);
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
routes: [
'0',
'1',
'2',
'3',
'4',
import Ember from 'ember';
export default Ember.Component.extend({
});