Skip to content

Instantly share code, notes, and snippets.

View cobbweb's full-sized avatar

Andrew Bucknall cobbweb

  • QLD, Australia
  • 21:20 (UTC +10:00)
View GitHub Profile
@cobbweb
cobbweb / example.conf
Created July 29, 2011 04:19
Nginx and PHP-FPM
server {
listen 8080;
server_name example.dev www.example.dev;
location / {
root /Users/Cobby/Sites/Example;
if ($host = 'www.example.dev' ) {
rewrite ^/(.*)$ http://example.dev:8080/$1 permanent;
}
@cobbweb
cobbweb / flatMap.ts
Created November 23, 2018 04:15 — forked from kakajika/flatMap.ts
Array.prototype.flatMap method in TypeScript.
interface Array<T> {
flatMap<E>(callback: (t: T) => Array<E>): Array<E>
}
Object.defineProperty(Array.prototype, 'flatMap', {
value: function(f: Function) {
return this.reduce((ys: any, x: any) => {
return ys.concat(f.call(this, x))
}, [])
},
@cobbweb
cobbweb / lazyload-child.js
Created December 9, 2015 04:43
Lazyload Children
(function(window) {
'use strict';
var raf = window.requestAnimationFrame;
var CLOSESNESS = 2;
function startLoop(fn) {
var running = false;
var lastExit;
@cobbweb
cobbweb / index.html
Created January 16, 2014 03:41
Demonstrating Sir Trevor Format Bar inside a scrolling element/container
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@cobbweb
cobbweb / listeners-demo.js
Last active January 2, 2016 10:48
Idea for listening to objects in a view, runs after `initialize` so you can add custom vent objects too.
var MyView = Marionette.ItemView.extend({
listeners: {
model: {
'add': 'modelAdd'
},
collection: {
'reset': 'reset'
},
appVent: {
@cobbweb
cobbweb / nav.js
Created December 20, 2012 04:10
Event-based nav object
MyApp.module('Nav', function(Nav, App) {
'use strict';
var render = Marionette.Renderer.render;
Nav.Navbar = Marionette.ItemView.extend({
template: 'nav/templates/navbar',
initialize: function()
@cobbweb
cobbweb / app.js
Created November 23, 2012 03:26
Queued Triggers in Backbone.Events
App.module('ModuleOne', function(ModuleOne, App) {
var members = new Backbone.Collection();
members.on('reset', function() {
App.vent.queueTrigger('moduleone:members:reset', members);
});
members.fetch();
@cobbweb
cobbweb / backbone.collectioncache.js
Created November 8, 2012 23:38 — forked from tbranyen/backbone.collectioncache.js
Backbone.Collection caching by URL
/*!
* backbone.collectioncache.js v0.0.2
* Copyright 2012, Tim Branyen (@tbranyen)
* backbone.collectioncache.js may be freely distributed under the MIT license.
*/
(function(window) {
"use strict";
// Dependencies
@cobbweb
cobbweb / compiler.js
Created April 30, 2012 01:11
Inject yylineno into AST nodes
var parser = require('./parser');
parser._performAction = parser.performAction;
parser.performAction = function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
var ret = parser._performAction.call(this, yytext, yyleng, yylineno, yy, yystate, $$, _$);
// do stuff
if (this.$._type) {
this.$.lineNo = yylineno;
}
return ret;
@cobbweb
cobbweb / index.html
Created April 19, 2012 04:06 — forked from anonymous/css
jacksons
<!DOCTYPE HTML>
<html>
<head>
<!-- Head is the container for all of the head elements -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>QUT Video Gaming Society</title>
<!-- The title is what is shown in the window of the browser or in the tab of the browser -->
<meta name="description" content="Come join us play Video Games at QUT" />
<!-- This is the meta tag for the description of the website which will be given to search engines -->
<link rel="stylesheet" type="text/css" href="stylesheet.css" />