Skip to content

Instantly share code, notes, and snippets.

View DimitarChristoff's full-sized avatar

Dimitar Christoff DimitarChristoff

View GitHub Profile
/** @jsx React.DOM */
var Dashboard = React.createClass({
render: function() {
return (
<div>
<h1>Dashboard!</h1>
<ul>
<li><Link to="inbox">Inbox</Link></li>
</ul>
@DimitarChristoff
DimitarChristoff / Browser.features.base64.js
Created February 10, 2011 21:21
Feature detect base64 support for images in mootools
(function() {
Browser.Features.base64 = null;
var callback = function() {
Browser.Features.base64 = this.width == 1 && this.height == 1;
// alert(Browser.Features.base64); // true || false
};
var img = new Image(), img = document.id(img) || new Element("img");
img.onload = img.onerror = img.onabort = callback;
// 1x1 px gif to test with
@nzakas
nzakas / noanon.md
Created June 8, 2012 21:19
Avoiding "new anonfn"

JSLint doesn't like using new function. This makes sense, because you're just creating a singleton, and so there's no point in using a constructor for that. If you have something like this:

var NowWithClosures = Backbone.Model.extend(new function(){
    var x = 1;
    this.initialize = function(){
        console.log('init');
    };
    this.AddOneToX = function(){
 x++;
var pop = new new Class({
Implements: [Options, Events],
options: {
// onBlock: Function.from(),
// onClose: Function.from(),
// onOpen: Function.from(),
width: 1024,
height: 768,
@getify
getify / 1.js
Last active December 14, 2015 18:38
requestEachAnimationFrame hopeful-fill.
(function(){
var
rAF = (window.requestAnimationFrame || window.msRequestAnimationFrame ||
window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame ||
window.oRequestAnimationFrame),
cAF = (window.cancelAnimationFrame ||
window.msCancelAnimationFrame || window.msCancelRequestAnimationFrame ||
window.mozCancelAnimationFrame || window.mozCancelRequestAnimationFrame ||
window.webkitCancelAnimationFrame || window.webkitCancelRequestAnimationFrame ||
window.oCancelAnimationFrame || window.oCancelRequestAnimationFrame),
@addyosmani
addyosmani / mediatorExample.md
Last active December 15, 2015 01:59
Mediator with Backbone 0.9.10

The Mediator pattern enables communication (mediation) between views using a mediator object.In the latest version of Backbone, the Backbone object itself can be used as a mediator without the need of a seperate helper.

In the following example, triggerSomething in our ToolbarView uses the global event-bus on the Backbone object to broadcast an application wide event somethingHappened with data.

// First view
var ToolbarView = Backbone.View.extend({
  className: ".toolbar",
  events: {
    "click .button":   "triggerSomething"

{{recruiter}},

On {{dates}} the attached messages were sent to my private email address. This email was unsolicited commercial email and, since we have never had any dealings previously, was unlawfully sent.

In particular, it was contrary to section 22 of The Privacy and Electronic Communications (EC Directive) Regulations, (SI2426/2003) ["PECR"]. In addition, this action breaches your obligations under the Data Protection Act 1998, as there was no consent to process the personal data comprised by the personal email address. As the affected data subject I require you to:

  1. Confirm whether you are registered as a data controller under the Data Protection Act 1998, and if so, explain how this activity complies with your registration.
  2. Cease any processing or sale of my data for all purposes, including direct marketing.
  3. Provide a copy of all data you hold which relates to me.
  4. Erase any personal data you hold about me.
@getify
getify / ex1-prototype-style.js
Last active September 7, 2016 16:24
A comparison of prototype-style of coding objects and Object.create()-style of coding objects. Both code snippets create two objects `b1` and `b2` which are `prototype` linked to behaviors defined by `Foo` and `Bar`. Take a look at both code snippets to see the pros and cons of each style of code, and decide for yourself which one is simpler to …
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,who);
@timwienk
timwienk / irc-notify.js
Last active January 27, 2017 17:50
Simple IRC notify script, sic (http://tools.suckless.org/sic) inspired.
#!/usr/bin/env node
"use strict"
var connection = null,
buffer = '',
listeners = {};
var options = {
host: 'chat.freenode.net',
port: 6667,
@mikermcneil
mikermcneil / example-of-how-to-import-data-into-sails-app.js
Last active March 23, 2020 10:59
An example script that imports data from a JSON file into a Sails.js app (feel free to use as a seed/boilerplate script, whatever you like)
#!/usr/bin/env node
/**
* Module dependencies
*/
var Async = require('async');
var Filesystem = require('machinepack-fs');
var Prompts = require('machinepack-prompts');
var Sails = require('sails').Sails;