Skip to content

Instantly share code, notes, and snippets.

View hergaiety's full-sized avatar
🐶
Arf?

Ava Gaiety Wroten hergaiety

🐶
Arf?
View GitHub Profile
@hergaiety
hergaiety / components.the-bottom.js
Created July 15, 2016 19:48
Passing Actions Upward
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
foo: function(...args) {
console.log('Hit foo in bottom');
this.sendAction('foo', ...args);
}
}
});
@hergaiety
hergaiety / controllers.application.js
Last active June 1, 2016 16:15
Listening for All Sub Properties
import Ember from 'ember';
export default Ember.Controller.extend({
obj: Ember.Object.create({thing: 'Foo'}),
objThing: Ember.computed('obj.[]', function() {
return this.get('obj.thing');
}),
init: function() {
this._super();
Ember.run.later(() => {
@hergaiety
hergaiety / controllers.application.js
Last active June 1, 2016 16:21
AnyBy / IsAny Comparison
import Ember from 'ember';
export default Ember.Controller.extend({
pets: Ember.computed(function() {
return ['dog', 'cat', 'fish'];
}),
checkAnyBy: Ember.computed('pets', function() {
console.log(this.get('pets').anyBy('cat'));
return this.get('pets').anyBy('cat');
}),
@hergaiety
hergaiety / controllers.application.js
Last active April 11, 2016 18:00
Modal Rerendering
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
set nocompatible
let iCanHazNeoBundle=1
let neobundle_readme=expand($HOME.'/.vim/bundle/neobundle.vim/README.md')
if !filereadable(neobundle_readme)
echo "Installing NeoBundle.."
echo ""
silent !mkdir -p $HOME/.vim/bundle
silent !git clone https://github.com/Shougo/neobundle.vim $HOME/.vim/bundle/neobundle.vim
let iCanHazNeoBundle=0
endif
@hergaiety
hergaiety / Fuzzy-Finding html5 import partial
Created December 11, 2015 22:49
Test if given string is "fuzzy-found" within a longer string, the "pattern". Thanks Jan Dvorak!
/**
* Test if given string is "fuzzy-found" within a longer string, the "pattern"
* @return {[boolean]} [returns true if src can be "fuzzy-found" within the pattern]
*/
export default function(str, pattern) {
str = str.toLowerCase();
pattern = pattern.toLowerCase();
// Code shamelessly borrowed from Jan Dvorak, you're awesome! http://codereview.stackexchange.com/questions/23899/faster-javascript-fuzzy-string-matching-function
pattern = pattern.split("").reduce(function(a,b){ return a+".*"+b; });
var sample = _.chain(this.sidebarItems)
.pluck('title')
.sample(3)
.value();
var placeholder = '"' + sample.join('", "') + '"';
// Result: '"Blink", "Tear flow", "Acommodation"'
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
myBool: false,
actions: {
toggleBool: function() {
this.set('myBool', !this.get('myBool'));
}
a.upload {
display: inline-block;
position: relative;
input[type=file] {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
@hergaiety
hergaiety / fdtn_close.js
Last active August 29, 2015 14:18
Foundation Don't Close on Esc key if Fullscreen anything is fullscreened
// Don't forget to turn off close_on_esc in your foundation initialization
// $(document).foundation({ reveal: { close_on_esc: false } });
$(document).on('keydown.reveal.custom', dom('reveal'), function(event) {
var isFullscreen = (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement);
if (event.keyCode === 27 && !isFullscreen) $(document).foundation('reveal', 'close');
});