Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
mindplay-dk / github.xml
Last active August 7, 2016 12:38
GitHub Gadget for Blogger
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="GitHub Activity" />
<UserPref name="username" display_name="GitHub Username" required="true" />
<Content type="html">
<![CDATA[
<h2>GitHub Activity</h2>
<div id="github-activity"></div>
<script type="text/javascript">
@mindplay-dk
mindplay-dk / README.md
Created April 11, 2013 20:16
First attempt at implementing semantic grid mix-ins for Stylus.

A first attempt at semantic/stateful grid mix-ins for Stylus.

Override the $grid-gutter-size and $grid-column-size variables with desired grid-system metrics, and $grid-max-columns with the desired maximum number of columns.

Use row() to start a new row within the grid-system, then use col(1) to generate a column, etc.

The number of columns within a row is counted, and errors will be thrown if you don't start a row() before calling col(), or if the total number of columns exceeds $grid-max-columns.

Example:

@mindplay-dk
mindplay-dk / sample.txt
Last active December 16, 2015 07:49
An HTML/PHP template syntax (hey, some of us like curly braces.)
html {
/* block comments */
head {
title = $title // insert $title into the title tag (HTML-escaped)
}
body {
#left { // <div id="left">
@mindplay-dk
mindplay-dk / notes.md
Created May 2, 2013 20:12
Some thoughts about Controller/Action patterns in PHP - please feel free to post comments!

Does the Controller/Action pattern make sense in PHP?

I find myself wondering lately, why do we use the Controller/Action pattern in PHP?

Are there any real benefits to this?

class UserController extends Controller
{

public function create() {

@mindplay-dk
mindplay-dk / functional-xml-parser.md
Last active December 17, 2015 02:09
Functional XML Parser

Just an idea that popped into my head this morning and wouldn't go away...

What if every tag in an XML file was a method-name, and every attribute an argument?

So let's say you have this simple XML document:

<hello place="World">
    Hello, World.
</hello>
@mindplay-dk
mindplay-dk / LazyIterator.php
Last active December 18, 2015 09:18
An Iterator that computes it's values in a lazy way
<?php
abstract class LazyIterator implements Iterator, Countable, ArrayAccess
{
private $values;
private $results = array();
private $index = 0;
public function __construct(array $values)
{
@mindplay-dk
mindplay-dk / tinyAMD.js
Last active December 19, 2015 06:09 — forked from potch/tinyAMD.js
// # tinyAMD: a Minimal AMD shim.
// I define Minimal AMD as the following:
// * Every define() call provides a module id field (no filename magic)
// * Every require() call consistently provides a list of dependencies, and
// optionally a callback to receive the resolved dependencies
// * No additional network traffic to fetch modules
// * All dependencies must be defined before a module may be required
// ## Uses
@mindplay-dk
mindplay-dk / ChromePhpLogRoute.php
Created July 22, 2013 16:17
Basic integration for ChromeLogger with Yii
<?php
Yii::import('application.vendor.chromephp.ChromePhp');
class ChromePhpLogRoute extends CLogRoute
{
/**
* @var bool whether the log should be ignored for ajax calls. Defaults to true.
*/
public $ignoreAjax = false;
@mindplay-dk
mindplay-dk / events.ts
Last active December 23, 2015 16:59
Simple event hook in TypeScript
var template_escape = {"\\": "\\\\", "\n": "\\n", "\r": "\\r", "'": "\\'"}
var render_escape = {'&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;'}
function escape_fn(data) {
return (data || data === 0)
? (data + '').replace(/[&\"<>]/g, (e) => render_escape[e])
: ''
}
@mindplay-dk
mindplay-dk / example.css
Last active February 15, 2016 08:32
Simplified semantic grid calculation for SASS (based on http://semantic.gs/)
#layout {
display: block;
width: 940px; }
#left {
display: inline;
float: left;
width: 60px; }
#content {