Features
- watch and livereload in development mode
- embedded server
- rules are as simple as possible (DRY)
- rules are semantic
Dependencies
<?php | |
/** | |
* Extracts a list of values from an array. | |
* | |
* @param array $values | |
* @param array $vars An array containing keys to be extracted and | |
* references to the variables that should be assigned. | |
*/ | |
function array_extract(array $values, array $vars) |
# http://EditorConfig.org | |
# | |
# Julien Fontanet's configuration | |
# https://gist.github.com/julien-f/8096213 | |
root = true | |
[*] | |
charset = utf-8 | |
end_of_line = lf |
<?php | |
// It must be a class because the destructor is used to restore the | |
// object. | |
class Resilient | |
{ | |
public static function &create() | |
{ | |
// A variable is created containing a instance of this class. | |
$ref = new self(); |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>SVG to canvas</title> | |
</head> | |
<body> | |
<svg height="100" width="100" xmlns="http://www.w3.org/2000/svg" version="1.1"> | |
<circle cx="50" cy="50" r="45"></circle> | |
</svg> | |
<canvas height="100" width="100"></canvas> |
// Let M be a n×n hollow symmetric matrix. | |
// M = ⋅ | M(0, 1) | M(0, 2) | … | M(0, n - 1) | |
// ⋅ | ⋅ | M(1, 2) | … | M(1, n - 1) | |
// ⋅ | ⋅ | … | … | M(n - 2, n - 1) | |
// | |
// M can be stored as an array A. | |
// M(i, j) = A(i * (i - 1) / 2 + j) for j < i. | |
// Hollow symmetric matric. | |
var HSM = function (n) { |
/** | |
* Pros: | |
* - do not need files (works with buffers/streams) | |
* | |
* Cons: | |
* - do not work with external stylesheets | |
* - librsvg2 headers must be installed | |
* - synchronous | |
* | |
* > apt-get install librsvg2-dev |
/** | |
* > npm install d3 | |
*/ | |
// In Node.js, d3.js works in a virtual document provided by jsdom. | |
var d3 = require('d3'); | |
//-------- | |
// Create the SVG element. |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Offline canvas to PNG</title> | |
</head> | |
<body> | |
<script> | |
// Create the canvas and set its size. | |
var canvas = document.createElement('canvas'); |
// It is probably best to use `lodash.is*` instead but this is a lightweight alternative :) | |
var is = module.exports = (function () { | |
var toS = Object.prototype.toString | |
var _ = function (ref) { | |
ref = toS.call(ref) | |
return function (val) { | |
return (toS.call(val) === ref) | |
} | |
} |