Skip to content

Instantly share code, notes, and snippets.

View DimitarChristoff's full-sized avatar

Dimitar Christoff DimitarChristoff

  • Marketaxess
  • London
View GitHub Profile
@DimitarChristoff
DimitarChristoff / breaking-buster-sinon-spy.js
Created June 20, 2012 15:39
circular references and .spy cause RangeError: Maximum call stack size exceeded
buster.testCase('breaking call stack when using circular references and spies', {
setUp: function() {
var A = function() {
this.collections = [];
}, B = function() {
this.models = [];
this.add = function(what) {
what.collections.push(this);
(function(){
/*
---
description: DynamicTextarea
license: MIT-style
authors:
- Amadeus Demarzi (http://amadeusamade.us)
@DimitarChristoff
DimitarChristoff / bootstrap-dropdown.js
Created May 30, 2012 13:43
bootstrap dropdown nicer
(function($) {
"use strict"; // jshint ;_;
/* DROPDOWN CLASS DEFINITION
* ========================= */
var toggle = '[data-toggle="dropdown"]',
Dropdown = function (element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle);
@DimitarChristoff
DimitarChristoff / app.js
Created May 30, 2012 09:49
poor man's AMD and mootools
require.config({
baseUrl: 'scripts/',
paths: {
'text': 'lib/text',
'mustache': 'lib/mustache',
'mootools': 'lib/mootools-core',
'mootools-more': 'lib/mootools-more',
'router': 'lib/router',
'breadcrumb': 'modules/breadcrumb',
'settings': 'modules/settings',
@DimitarChristoff
DimitarChristoff / doubleclick.js
Created May 30, 2012 09:07
pixel tracking ftw
;(function() {
var lazyLoadScript = function(url) {
// make sure the script being loaded does not do document.write and can be deferred.
var ns = document.createElement('script'),
s = document.getElementsByTagName('script')[0];
ns.type = 'text/javascript';
ns.async = true;
ns.src = url;
s.parentNode.insertBefore(ns, s);
@DimitarChristoff
DimitarChristoff / refutal.md
Created April 29, 2012 11:46
why jquery is not better than mootools

saw this artcile quoting 10 reasons why jquery is better than mootools. source: http://www.jquery4u.com/articles/jquery-mootools/

jQuery has better mobile support than Mootools – the latest release of jQuery Mobile Alpha 3 has been a breakthrough in how easy it can be to get your website “mobile efficient”. Mootools has mobile support including touch events but it’s not as widely available as jQuery options. (#1 was Previously jQuery vs Mootools filesizes).

not true. see http://moobilejs.com/

jQuery is less confusing than Mootools! – It has less native extensions (including element) – jQuery has about a dozen for Array, Object, and String and Mootools has about six dozen for Array, Object, String, Function, and Number.

how is less power and methods a good thing? the reason why mootools has more native methods is because it also shims browsers that lack ES5 functionality for all the natives that it extends. if anything, this goes against jquery.

if (range == -200) {
indx = 0;
range = 0;
}
else {
if (range < 0 && range > -199) {
indx = 0;
}
else {
if (range <= this.options.scores[0]) {
@DimitarChristoff
DimitarChristoff / buster-test.js
Created March 30, 2012 08:52
failing buster.js setUp async delay before testing
buster.testCase('dummy async test', {
setUp: function(done) {
var self = this;
this.yes = false;
setTimeout(function() {
self.yes = true;
done();
}, 3000);
},
@DimitarChristoff
DimitarChristoff / buttontext.js
Created March 21, 2012 10:12
flipping button values
var flipText = function(el, map) {
e.set('text', map[el.get('text').clean()];
};
flipText(document.getElement("button"), {
"No Email": "With Email",
"With Email": "No Email"
});
@DimitarChristoff
DimitarChristoff / product map
Created March 16, 2012 14:50
prototype for json
var foo = {
"Section": {
type: "subHeading",
output: "Insurance Provider",
values: [
{
type: "image",
value: "imagesrouce.gif"
},
{