Skip to content

Instantly share code, notes, and snippets.

View kangax's full-sized avatar

Juriy Zaytsev kangax

View GitHub Profile
// create new card
$('.js-add-list-popover').click();
var d = new Date();
var year = (d.getFullYear()+'').substring(2);
var month = d.getMonth() + 1;
var day = d.getDate();
var cardName = 'Published (' + month + '-' + day + '-' + year + ')';
$('.js-list-name').val(cardName);
(function(d, s) {
var deps = {
twitter: [
"//platform.twitter.com/widgets.js",
"twitter-wjs"
],
facebook: [
"//connect.facebook.net/en_US/all.js#xfbml=1",
"facebook-jssdk"
// run on http://browser.primatelabs.com/mac-benchmarks
function findFirst(text) {
return $('td a').filter(function(i, el){ return $(el).text().indexOf(text) > -1 }).eq(0).closest('tr');
}
var mine = findFirst('MacBook Pro (17-inch Early 2011)');
var topMbp = findFirst('MacBook Pro');
$('tbody tr').hide().eq(0).show();
var URL = require('url'),
HTTP = require('http'),
Canvas = require('canvas'),
Image = Canvas.Image,
img = new Image(),
canvas = new Canvas(200,200),
ctx = canvas.getContext('2d'),
// throws "Error: Image given has not completed loading"
/**
* Usage:
*
* scout()
* .when(typeof JSON === 'undefined')
* .load('/assets/json2.js')
*
* .when(typeof G_vmlCanvasManager !== 'undefined')
* .load('/assets/fabric/cufon.js')
*
loadFromJSON: function (json, callback) {
if (!json) return;
// serialize if it wasn't already
var serialized = (typeof json === 'string')
? JSON.parse(json)
: json;
if (!serialized || (serialized && !serialized.objects)) return;
@kangax
kangax / backbone.js
Last active October 17, 2015 05:07
bacon vs. backbone vs. react (just seeing how bacon's paradigm compares with other approaches)
var RegisterForm = Backbone.View.extend({
ui: {
username: '.username',
fullname: '.fullname',
register: '.register-btn',
loader: '.loader',
feedback: '.feedback'
}
events: {
'input username, fullname': 'onInput',

Sept 22 2015 Meeting Notes

Allen Wirfs-Brock (AWB), Sebastian Markbage (SM), Jafar Husain (JH), Eric Farriauolo (EF), Caridy Patino (CP), Mark Miller (MM), Adam Klein (AK), Michael Ficarra (MF), Peter Jensen (PJ), Domenic Denicola (DD), Jordan Harband (JHD), Chip Morningstar (CM), Brian Terlson (BT), John Neumann (JN), Dave Herman (DH), Brendan Eich (BE), Rick Waldron (RW), Yehuda Katz (YK), Jeff Morrison (JM), Lee Byron (LB), Daniel Ehrenberg (DE), Ben Smith (BS), Lars Hansen (LH), Nagy Hostafa (NH), Michael Saboff (MS), John Buchanan (JB), Gorkem Yakin (GY), Stefan Penner (SP)

On the phone: Mark Miller (MM), Dan Gohmann (DG), John McCutchan (JMC)

(Need attendance list)

initialize: function(id, settings) {
this.id = id;
this.settings = Object.extend(Object.clone(this.defaultOptions), settings || { });
this._container = $(this.id + '_Container');
this._controls = $(this.id + '_Controls');
// attach radio & check boxes
this._hueRadio = $(this.id + '_HueRadio');
this._saturationRadio = $(this.id + '_SaturationRadio');

At this point, however, we can begin to look at some complications. There's two areas where I've skipped over some awkward points that get in the way of MVC theory. The first problem area is to deal with setting the color of the variance. This shouldn't really fit into a domain object, as the color by which we display a value isn't part of the domain. The first step in dealing with this is to realize that part of the logic is domain logic. What we are doing here is making a qualitative statement about the variance, which we could term as good (over by more than 5%), bad (under by more than 10%), and normal (the rest). Making that assessment is certainly domain language, mapping that to colors and altering the variance field is view logic. The problem lies in where we put this view logic - it's not part of our standard text field.

This kind of problem was faced by early smalltalkers and they came up with some solutions. The solution I've shown above is the dirty one - compromise some of the purity of the doma