Skip to content

Instantly share code, notes, and snippets.

View jcayzac's full-sized avatar

Julien Cayzac jcayzac

View GitHub Profile
var fs = require('fs'),
    connect = require('connect')

var oneYear = 31557600000,
    app = connect(
        connect.favicon(),
        connect.logger(),
        connect.staticCache(),
        connect.static(__dirname + '/static', { maxAge: oneYear }),
var util = require('util'),
cp = require('child_process'),
p = cp.spawn(
'/opt/redis/redis-server',
[__dirname + '/redis/redis.conf'],
{
cwd: __dirname,
env: process.env,
setsid: false
}
:xxx Hi, I'm metadata! I apply to my parent element and I will be translated to whatever form supported by Google, FaceBook and the rest!
# Hi there!
:icon https://lh3.ggpht.com/I5NYwBKCBphMQvQLC7DWgTbMabYxqrwR83wEe2o4IryOJBfcndjz4ZN4cc2rMNPlCA=w124
:author Julien Cayzac <[email protected]>
:published 2010-09-20 13:05:34
I'm a new article about something super interesting. This might look like Markdown, but it's not!
You should check [https://youtu.be/g2FOLrC2e6E](this video) out! Here, I just put it below:
CGRect frame = self.frame;
float aspect = frame.size.height/frame.size.width;
// Assuming:
// - the phone is held 30cm away from the eye,
float near = 0.3f;
// - objects farther than 10Km aren't shown,
float far = 10000.f;
// iPhone4S:
// http://stackoverflow.com/questions/3594199/iphone-4-camera-specifications-field-of-view-vertical-horizontal-angle
// In portrait mode, horizontal angle is 47.5 degrees
@jcayzac
jcayzac / x.html
Created March 28, 2012 09:19
Responsive loading of iframes (e.g. youtube embeds)
<h1>This is loaded only after the DOM is ready, if JS is supported</h1>
<p>Loading the iframe normally would block until the iframe's own DOM is ready, resulting in slow loading times. Non-Javascript browsers get normal (inefficient) behaviour.</p>
<!-- note: on JS-enabled browsers, the noscript element will get replaced by its content (keep that in mind for CSS) -->
<noscript class="noblock">
<iframe src="https://www.youtube-nocookie.com/embed/g2FOLrC2e6E?wmode=opaque&amp;vq=hd720&amp;autohide=1&amp;fs=1&amp;iv_load_policy=3&amp;loop=1&amp;rel=0&amp;showsearch=0&amp;showinfo=0&amp;modestbranding=1"></iframe>
</noscript>
@jcayzac
jcayzac / gist:2252804
Created March 30, 2012 16:51
Google Charts API: TeX formulas to transparent PNG, over HTTPS
@jcayzac
jcayzac / gist:2265478
Created March 31, 2012 14:25
Regular expressions

Catch all html/xml tags (even with namespaces)

It only captures the tag's FQN along with the optional leading ! and leading/trailing /.

/<((?:\/|\!)?(?:[a-zA-Z0-9_-]+:)?[a-zA-Z0-9_-]+)(?:\s*(?:(?:[a-zA-Z0-9_-]+:)?[a-zA-Z0-9_-]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s]+))?)*\s*(\/?)>/g

Parsing XML/HTML with one regex

var sortedJSON = function (obj) {
if (obj === null) {
return 'null';
}
if (Array.isArray(obj)) {
return '[' + obj.map(sortedJSON).join(',') + ']';
}
if (obj instanceof RegExp) {
// sortedJSON is from https://gist.github.com/2318775
var crypto = require('crypto'),
getStableHash = function (obj) {
return crypto.createHmac('sha1', 'woot').update(sortedJSON(obj)).digest('hex');
};
var ParentClass = function() { }
ParentClass.prototype = {}
ParentClass.prototype.constructor = ParentClass;
var SubClass = function() {
ParentClass.prototype.constructor.apply(this, []);
};
SubClass.prototype = Object.create(ParentClass.prototype)
SubClass.prototype.constructor = SubClass