Skip to content

Instantly share code, notes, and snippets.

View gryzzly's full-sized avatar

Misha Reyzlin gryzzly

View GitHub Profile
@petermichaux
petermichaux / gist:2593030
Created May 4, 2012 07:50
Golfing Maria Views
// The following is sugar for writing out in full a view constructor function, its prototype, and the boilerplate
// for inheriting from maria.ElementView. This sugar uses naming conventions to wire together
// the view with its model, controller, and their methods.
//
// A checkit.TodoView will observe a checkit.TodoModel. When the model changes, the update method below is called.
// When a user clicks on the todo element, the handling is delegated to the checkit.TodoController's
// handleRootClick method.
//
maria.ElementView.declareConstructor(checkit, 'TodoView', {
template: '<li><span class="todo-content"></span></li>', // the template can live elsewhere, of course
(ns ^{ :doc "Library implemented eventual value abstraction."
:author "Irakli Gozalishvili" }
eventuals)
(defprotocol IDeferred
"Protocol for deferred values"
(-realize [this value] "Resolves deferred with this value"))
(defprotocol IEventual
"Protocol for eventual values"
@petermichaux
petermichaux / gist:2360670
Created April 11, 2012 17:19
observer pattern interesting use cases
/*
It's interesting to think about event/observer libraries for the first time after years of using
the same library, making messes, and trying to figure out how best to build reasonably large
browser apps. I realize that I want an event library that eases writing MVC applications in JavaScript.
*/
/*
@tinnefeld
tinnefeld / gist:2324599
Created April 7, 2012 02:32
Deichkind - Leider Geil / Unfortunately Awesome - Englisch lyrics / Englischer Songtext
I'm sorry, but I have to admit, there are things in this world, which are - unfortunately awesome.
Cars cause pollution, the environment suffers, but a fancy new ride is - unfortunately awesome.
I'm chewing on a crayon, mom tells me to 'Stop it!', but it relaxes me - unfortunately awesome.
Diagnosis: psychosis!, I don't care, a joint first thing in the morning - unfortunately awesome.
"Stop nuclear energy!" you hear them screaming and I charge my smartphone - unfortunately awesome.
Finally a new job, gotta' get up early in the morning, getting wasted in a pub - unfortunately awesome.
My teeth are rotten, but they don't hurt yet, I'm not going to the dentist - unfortunately awesome.
I'm decorating drunken friends, it's mean indeed, - but unfortunately awesome.
Bad for the offspring, bad for the North-sea, bad for your head - but unfortunately awesome.
@WebReflection
WebReflection / each.js
Created April 3, 2012 19:28
all you need to `each(obj, cb [,context])`
var each = function (Array) {"use strict";
/*! all you need to `each(obj, cb [,context])`
* @author WebReflection
* @license WTFPL - http://en.wikipedia.org/wiki/WTFPL
* @gist https://gist.github.com/2294934
*/
var
toString = {}.toString,
hasOwnProperty = {}.hasOwnProperty,
array = toString.call([]),
@aemkei
aemkei / LICENSE.txt
Last active March 7, 2025 20:08 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@NV
NV / clone_object_with_circular_references.js
Created November 26, 2011 18:22
Clone an Object with all its circular references. Take that jQuery.extend!
function cloneObject(object) {
return extendObject({}, object);
}
function extendObject(base, object) {
var visited = [object];
// http://en.wikipedia.org/wiki/Adjacency_list_model
var set = [{value: base}];
// duck typing ( maybe all you need )
var me = {name: "WebReflection"};
// basic class
function Person() {}
Person.prototype.getName = function () {
return this.name;
};
Person.prototype.setName = function (name) {
this.name = name;
// Here is a proposal for minimalist JavaScript classes(?), that does not
// introduces any additional syntax to the language, instead it standardizes
// approach already used by majority of JS frameworks today.
// !!! What is a PROBLEM!!!
function Dog(name) {
// Classes are for creating instances, calling them without `new` changes
// behavior, which in majority cases you need to handle, so you end up with
// additional boilerplate.
@paulirish
paulirish / data-markdown.user.js
Last active October 22, 2024 14:19
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.