Skip to content

Instantly share code, notes, and snippets.

View juandopazo's full-sized avatar

Juan Dopazo juandopazo

View GitHub Profile
@juandopazo
juandopazo / result.js
Created October 6, 2012 17:33
YUI TypeScript definitions
module Y {
interface Anim extends Base {
}
interface App extends App_Base, App_Content, App_Transitions, PjaxContent {
(config?: any);
@juandopazo
juandopazo / gist:3718393
Created September 13, 2012 22:59
Why I want ES.next yesterday
// some code I'm writing...
class Matrix {
/* ... */
transpose() {
var [n, m] = this.size(),
rows = this.rows,
result = [],
i = 0, j = 0;
@juandopazo
juandopazo / client.js
Created August 19, 2012 15:04
localtunnel in Node
var http = require('http');
module.exports = function (config) {
console.log("Starting client");
var client = http.request({
host: config.remoteHost,
port: config.remotePort,
method: 'CONNECT',
path: 'new'
@juandopazo
juandopazo / gist:3390395
Created August 18, 2012 23:49
Express static route
var express = require('express');
module.exports = function staticRoute(dir, opts) {
var static = express.static(dir, opts);
return function (req, res, next) {
static({ url: req.params[0] }, res, next);
};
};
@juandopazo
juandopazo / gist:3305606
Created August 9, 2012 16:23
Inheriting constructor properties with __proto__
function Superclass() {
}
Superclass.prototype.someMethod = function () {
console.log('foo');
};
Superclass.staticMethod = function () {
console.log('I\'m "static"');
};
@juandopazo
juandopazo / gist:3244053
Created August 3, 2012 03:24
Geometric linear algebra for 3d CSS3

@mapagella came to me with a question. A friend of his was trying to do ray tracing with CSS3. He wanted to rotate in 3D a <div> element shaped like a line so that it started and ended in specific points in space.

Ray tracing gone wrong

It turns out that CSS3 defines a rotate3d() transform function that allows you to rotate an HTML element a certain angle around a certain direction in 3D space. The function looks like rotate3d(x, y, z, angle) where x, y and z define the direction around which the element will be rotated. The question then is what direction and which angle to use.

Let's start by defining what our line will be. We'll use a div element with a line class: <div class="line"></div>. And we'll define line as:

.line {
 background: green;

The Button widget is removing the type attribute from the Cancel button. This makes that button behave like a submit button.

There are many possible paths to make this work. I'll start from simple to complex. The first is to avoid the issue entirely and not use JavaScript at all. Just use a link:

<form action="/Administration/Department/Create2" method="post">
    <button class="yui3-button">Save</button>
 <a class="yui3-button" href="/Administration/Department/List">Cancel</a>
@juandopazo
juandopazo / gist:3218679
Created July 31, 2012 17:19
PluginObserver
function PluginObserver() {
this.publish('plug', {
emitFacade: true,
defaultFn: '_plug'
});
this.publish('unplug', {
emitFacade: true,
defaultFn: '_unplug'
});
}