Skip to content

Instantly share code, notes, and snippets.

View erikringsmuth's full-sized avatar

Erik Ringsmuth erikringsmuth

View GitHub Profile
@erikringsmuth
erikringsmuth / konami.md
Last active August 29, 2015 13:56
Konami Code JS
// listen for the konami code
function konami(callback) {
	var LEFT = 37, UP = 38, RIGHT = 39, DOWN = 40, A = 65, B = 66, matchedIndex = 0, konami = [UP, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, B, A];
	window.addEventListener('keydown', function(event) {
		event.keyCode === konami[matchedIndex] ? matchedIndex++ : matchedIndex = 0;
		if (matchedIndex === konami.length) {
			callback();
			matchedIndex = 0;
 }
@erikringsmuth
erikringsmuth / ractive-layouts.md
Last active August 29, 2015 13:55
Ractive.js Layouts

Ractive Layout Views

I'd like to propose a new Ractive feature. The goal is to use a JavaScript router to load a view without an intermediate step to render the layout (header, footer, etc.). In most frameworks you have to start the "App" then start the router. The "App" is the layout and the router loads and populates the main content. I prefer to have the router run the app without an intermediate step to render the layout. The router should load a view, let's start with the HomeView, and the HomeView should specify a LayoutView. Creating the home view should also create and render the layout. When you attach the home view to the document you're also attaching it's layout.

Here's an example:

// layout/layoutView.js
define([
  'ractive',