Skip to content

Instantly share code, notes, and snippets.

@mistahenry
mistahenry / file_io.scala
Created April 19, 2014 21:56
Read file into List of lines in Scala
import scala.io.Source
val listOfLines = Source.fromFile("filename.txt").getLines.toList
@mistahenry
mistahenry / 0_reuse_code.js
Created April 19, 2014 21:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mistahenry
mistahenry / controllers.application.js
Created January 5, 2018 19:21
Event Propogation with Closure Actions
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
foo(event){
if($(event.target).is("#list")){
alert("Foo");
}
@mistahenry
mistahenry / components.dynamic-table.js
Last active November 12, 2018 10:47
Ember Light Table based on Ember Data model definition
import Component from '@ember/component';
import { computed } from '@ember/object';
import Table from 'ember-light-table';
export default Component.extend({
init() {
this._super(...arguments);
let table = new Table(this.get('columns'), this.get('models'), { enableSync: this.get('enableSync') });
let sortColumn = table.get('allColumns').findBy('valuePath', this.get('sort'));
import Ember from 'ember';
import {computed} from '@ember/object';
export default Ember.Controller.extend({
init(){
this._super(...arguments);
this.set('placeholder', "type here");
},
appName: 'Ember Twiddle',
passwordsMatch: computed('password', 'passwordConfirm', function(){
return this.get('password') === this.get('passwordConfirm');
import Ember from 'ember';
import { inject } from '@ember/service';
import { computed } from '@ember/object';
export default Ember.Component.extend({
modeService: inject(),
renderList: computed('modeService.mode', function(){
let mode = this.get('modeService.mode');
return mode === 'list';
})
import Controller from '@ember/controller';
export default Controller.extend({
init(){
this._super(...arguments);
this.set('images', [
"https://avatars0.githubusercontent.com/u/4096934?s=460&v=4"
]);
}
});
import Component from '@ember/component';
export default Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
init(){
this._super(...arguments);
this.name = 'foo';
},
actions: {
toggleName(){
this.set('name', this.name === 'foo' ? 'bar' : 'foo')
import Ember from 'ember';
import { computed } from '@ember/object';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init(){
this._super(...arguments);
this.first = "Mista";
this.last = "Henry";
this.name = 'Not MistaHenry';