This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
You want to use webworkers, but you host all of your js files on a different domain than where | |
your app lives (es. app.example.com and js.example.com). Given that the static file served from | |
js.example.com are CORS ready (in that the response header includes Accept-origin: *), I thought | |
I could load a Worker from other domains. I was almost wrong, but at last I found a solution: | |
XHRing the worker source and create an inline worker. This is tested only on Firefox (latest). | |
*/ | |
// This is an example webworker that is on js.example.com. It just echoes messages it receive. | |
self.onmessage = function(e) { | |
self.postMessage(e.data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import logging.config | |
logging.dictConfig({ | |
'version': 1, | |
'disable_existing_loggers': False, | |
"formatters": { | |
"standard": { | |
"format": '%(asctime)s %(name)s %(levelname)s %(message)s' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53); | |
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19); | |
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22); | |
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06); | |
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035); | |
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335); | |
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94); | |
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1); | |
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Python(ish) string formatting: | |
* >>> format('{0}', ['zzz']) | |
* "zzz" | |
* >>> format('{x}', {x: 1}) | |
* "1" | |
*/ | |
var format = (function() { | |
var re = /\{([^}]+)\}/g; | |
return function(s, args) { | |
return s.replace(re, function(_, match){ return args[match]; }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html class="ynap-fe-exercise" lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet"> | |
<link href="index.css" rel="stylesheet"> | |
<script src="index.js"></script> | |
<script id="ynap-news-story-tmpl" type="text/x-template"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper 'each_with_index', (array, fn) -> | |
buffer = '' | |
for i in array | |
item = i | |
item.index = _i | |
buffer += fn(item) | |
buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
YouTube Footer Buttons | |
*/ | |
.button { | |
border: 1px solid #DDD; | |
border-radius: 3px; | |
text-shadow: 0 1px 1px white; | |
box-shadow: 0 1px 1px #fff; | |
font: bold 11px Sans-Serif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Return a new object from an array of key/value pairs. | |
* Inspired by the "dict" constructor in python. | |
* | |
* @method dict | |
* @param {Array} arr An array of key/value pairs. | |
* @return {Object} A new object | |
* @static | |
*/ | |
Y.namespace('Object').dict = function(arr) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global YUI=true */ | |
/* Note: the "png" prefix you're seeing through this file is just my own | |
namespace. No reference to the Portable Network Graphic intended. */ | |
YUI.add('png-entity', function(Y) { | |
/** | |
The ContainmentUnit's purposes are: creating Entity extensions, store them and handle | |
the relations between them. | |
@class ContainmentUnit | |
@constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CONAN(cls) { | |
/* Arbitrary Number of Arguments Object Constructor, | |
ANAOC | |
but everyone calls him | |
CONAN | |
CONAN takes a Object Constructor and adds a static method named "build", whose only | |
argument is an array that get passed to the Constructor with an apply. | |
*/ | |
var _helper = function(s) { | |
cls.apply(this, s); |
NewerOlder