Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
mindplay-dk / gist:4083141
Created November 16, 2012 01:38
GitHub feature request: "micro edits"

Micro Edits

A GitHub Feature Request

I propose a feature that lets you edit one line of code, in place, instantly, no hassle - providing nothing but the updated line of code, and a short 1-line comment explaining why you'd like to make this change.

Why? Because it's the little things that count. How often do you glance over code on GitHub and think, "oh, I could fix that real quick". But you don't want to fork the project and submit a pull-request, much less have to maintain your own fork (and have it show up on your GitHub page) so you just leave it alone.

Think of the overall quality increase, if all those little tweaks got made every time somebody spots something ugly, and actually made it into people's codebases - many drops make an ocean, right?

@mindplay-dk
mindplay-dk / gist:4215727
Created December 5, 2012 14:02
Why you should not sort conversations in reverse order
B: Because the temporal aspects of conversation are lost!
A: Why is that important?
B: Because they're conversations.
A: Why not?
B: Of course not!
A: Should I sort conversation items in reverse order?
See the problem here?
@mindplay-dk
mindplay-dk / GAutoloader.php
Created December 7, 2012 16:43
GAutoloader
<?php
/**
* Simple autoloader mapping namespaces to paths.
*
* @property array $namespaces hash where namespace => absolute root-path
* @property array $classes hash where fully qualified class-name => absolute path
*/
class GAutoloader
{
@mindplay-dk
mindplay-dk / ErrorHandler.php
Last active October 13, 2015 20:48
Simple PHP Error-handler
/**
* Simple error-handler mapping PHP errors to PHP's ErrorException, and registering
* a global exception-handler that slightly improves Exception display.
*
* @see ErrorException
*/
class ErrorHandler
{
/**
* Register error-handler and Exception-handler.
@mindplay-dk
mindplay-dk / TestServer.php
Last active November 20, 2019 12:23
Minimal (copy and paste) unit testing
<?php
/**
* This class will launch the built-in server in PHP 5.4+ in the background
* and clean it up after use.
*/
class TestServer
{
/**
* @var resource PHP server process handle
@mindplay-dk
mindplay-dk / README.md
Last active December 10, 2015 11:39
This test-script demonstrates a bug in TrueType rendering in PHP.
@mindplay-dk
mindplay-dk / GDateTimeBehavior.php
Last active December 11, 2015 07:29
A CBehavior (for the Yii-framework) that automatically converts to/from DATE/DATETIME values
<?php
/**
* This behavior implements synchronous timestamp-accessors for DATE and DATETIME values
* by convention - attributes with a "_date" or "_datetime" suffix, respectively, can be
* accessed as UNIX timestamps (integers) by leaving out the suffix; for example, a
* DATETIME attribute $test->created_datetime can be accessed as $test->created.
*
* This behavior can be attached to a CModel or descendants, e.g. CFormModel, CActiveRecord, etc.
*
@mindplay-dk
mindplay-dk / README.md
Last active September 3, 2024 11:39
ISO 3166-2 Country and State/Region Tables for MySQL
@mindplay-dk
mindplay-dk / COMMENT.md
Last active August 4, 2017 02:23
MySQL ALTER TABLE issue with COMMENT on columns

This gist documents a problem with MySQL Workbench, which may be related to an SQL parser bug in MySQL, I'm not 100% certain yet.

This is repeatable with MySQL 5.5.25 on Windows 8, I have not tested this on other versions or environments yet.

First, create a database and populate it with two tables for testing:

DROP DATABASE IF EXISTS `test`;

USE `test`;
@mindplay-dk
mindplay-dk / README.md
Last active December 15, 2015 07:29
datetime() helper prototype for PHP