Skip to content

Instantly share code, notes, and snippets.

View variousauthors's full-sized avatar
🐢
Doubling Down

Various Authors variousauthors

🐢
Doubling Down
View GitHub Profile
@variousauthors
variousauthors / gist:6809872
Created October 3, 2013 13:31
Adding event management to a backbone.marionette Layout.
MyApp.Views.MasterDetailLayout = Backbone.Marionette.Layout.extend({
template: 'backbone/templates/master_detail_layout',
regions: {
master: "#master",
detail: "#detail"
},
initialize: function() {
console.log('MasterDetailLayout->initialize');
@variousauthors
variousauthors / gist:6867013
Created October 7, 2013 12:26
This is the only way I could find to namespace a group of methods in an object.
var obj = (function (){
var self = {
foo: function () {
return 'foo';
},
namespace: {
bar: function () {
return self.foo();
}
}
@variousauthors
variousauthors / gist:6919826
Created October 10, 2013 14:59
An example of Handlebars.
{{!-- a handlebars template might look like this --}}
<div class="{{#if myLibrary}}active{{/if}} library">
{{#each books}}
<div class="book">
<h3 class="title">{{ title }}</h3>
<span class="author">by {{ author }}</span>
{{#if isAvailable }}
<span class="availability">Available!</span>
{{else}}
@variousauthors
variousauthors / readme.txt
Last active December 29, 2015 05:09 — forked from anonymous/readme.txt
This is "Signal", my second puzzle script game. It is nearly finished, and it really is a puzzle game. You can play this build of it by visiting this link: http://www.puzzlescript.net/play.html?p=7620162
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@variousauthors
variousauthors / gist:7640545
Created November 25, 2013 12:27
This is a stack implemented without assignment statements.
var Stack = function () {
return {
pop: function() {
throw "popped from an empty stack";
},
push: function(value) {
return (function (self) {
return _.extend({}, self._incrementCount(), {
head: value,
pop: function () {
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@variousauthors
variousauthors / gist:61b7202d4aff016746f1
Last active July 9, 2016 07:22
Infinite Parallax Starfield
love.viewport = require('libs/viewport').newSingleton()
local STAR_SEED = 0x9d2c5680;
local STAR_TILE_SIZE = 256;
local rshift, lshift, arshift, bxor, tohex = bit.rshift, bit.lshift, bit.arshift, bit.bxor, bit.tohex
-- Robert Jenkins' 96 bit Mix Function.
-- Taken from http://nullprogram.com/blog/2011/06/13/
local function mix (a, b, c)
@variousauthors
variousauthors / script.txt
Last active November 4, 2016 23:21 — forked from anonymous/readme.txt
This is my first Puzzlescript game. It is a work in progress, clearly, and it is not really much of a puzzle game. You can play this build of it by visiting this link: http://www.puzzlescript.net/play.html?p=7126774
title An Auspicious Day v0.2.1
author arrogant.gamer
homepage www.arrogantgamer.com
flickscreen 20x10
color_palette proteus_rich
========
OBJECTS
========
@variousauthors
variousauthors / declarative.md
Last active March 29, 2018 17:21
Declarative

Preface: The Case for Map

In a declarative style the idea is to write code that describes what will be done, not how it will be done. My fav examples are from recursion:

const reverseString = (str) => {
  if (str.length < 2) return str
  
  const [first, ...rest] = str
 return reverseString(rest) + first
// this code is safe to copy/paste into your browser
// but you should really try to write it out line-by-line ;)
// this gist is based on a number of other excellent introductions to lambda calculus
// classic: https://github.com/sjsyrek/presentations/blob/master/lambda-calculus/lambda.js
// ornithology: https://www.youtube.com/watch?v=3VQ382QG-y4&t=3349s
// and this one, in Ruby, called "Programming With Nothing" (excellent title) https://www.youtube.com/watch?v=VUhlNx_-wYk
pair = x => y => a => a(x)(y)