Skip to content

Instantly share code, notes, and snippets.

@nathanhammond
nathanhammond / index.html
Created November 16, 2015 16:27
Service Worker fetch intercept timing.
<script>
function insertScript(src) {
var scripts = document.getElementsByTagName('script');
var newScript = document.createElement('script');
newScript.src = src;
scripts[0].parentNode.insertBefore(newScript, scripts[0]);
}
// This is contrived.
@nathanhammond
nathanhammond / router.js
Last active February 23, 2018 18:09
willBeActive
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('products', function() {
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['something'],
filter: null,
actions: {
reloadList() {
this.transitionToRoute('list.details', { queryParams: { filter: 'hello' } });
},
import Ember from 'ember';
export default Ember.Controller.extend({
value: {
id: 12,
name: 'james'
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['category', 'term'],
category: 0,
term: 0,
actions: {
increment(qp) {
let routeArgument = {};
import Ember from 'ember';
function makeIterable(someObject) {
someObject[Symbol.iterator] = function() {
let nextIndex = 0;
return {
next: function() {
if (nextIndex < someObject.order.length) {
return { value: someObject[someObject.order[nextIndex++]], done: false };
@nathanhammond
nathanhammond / hide-post-see-less.js
Created June 12, 2017 17:36
Hide Post, See Less
/**
* You can navigate the Facebook feed interface using `j` and `k`.
* This script allows you to use the `x` key once focused on a story
* to hide a post and see less from its author to train Facebook's model
* as to whether you'll be interested in a particular piece of content.
* Install it as either a UserScript or bookmarklet.
*
* License: MIT
*/
function seeLess() {
@nathanhammond
nathanhammond / router.js
Last active April 25, 2017 17:38
Route Transition Error
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
this.route('standalone');
@nathanhammond
nathanhammond / router.js
Last active April 8, 2017 21:25
New Twiddle
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
this.route('standalone');
import Ember from 'ember';
let i = 0;
export default Ember.Controller.extend({
foo: function(event) {
console.log(++i, this, event);
},
actions: {
thing: function(event) {