Skip to content

Instantly share code, notes, and snippets.

View ewinslow's full-sized avatar

Evan Winslow ewinslow

  • Google
  • Westminster, CA
View GitHub Profile
@ewinslow
ewinslow / inherit.js
Created October 16, 2011 09:24
Inheritance + super access in javascript
inherit = function(Child, Parent) {
Child.prototype = new Parent();
Child.prototype.constructor = Child;
Child.prototype.super_ = function(methodName) {
// Special case: calling from constructor
if (arguments.caller.callee.prototype.super_) {
return Parent.apply(this, arguments);
}
var varArgs = Array.prototype.slice.call(arguments, 1);
@ewinslow
ewinslow / ElggQueryString.php
Created February 17, 2012 18:19
Defines some classes for working with URLs in Elgg.
<?php
class ElggQueryString {
// TODO(evan): implement
}
@ewinslow
ewinslow / elgg.json
Last active December 19, 2015 23:18
Exploration of JSON-based configuration of Elgg
{
"// New idea for routing": "",
"routes": {
"site/activity": {
"// The url (or array of urls) that trigger this route": "",
"paths": "/activity",
"// Calls `get()` on an instance of this class and passes to page shell and body as `$vars`": "",
"controller": "Elgg_Site_ActivityController",
@ewinslow
ewinslow / docs-rewrite.md
Created August 24, 2013 23:30
Continuous Documentation

Great documentation makes great projects, so of course we want Elgg to have high quality, up-to-date documentation. We'd love your help making that a reality.

Our vision

Documentation should help you get stuff done, so we're embarking on a full rewrite of our docs to optimize for that goal. When writing the new docs, we'll:

  • Focus on common tasks
  • Eliminate the blah-blah
  • Write thorough, task-oriented articles
  • Include plenty of copy-pasteable code samples
@ewinslow
ewinslow / actions.rst
Last active August 29, 2015 14:01
Elgg OO Actions

Actions

Actions define the behavior of forms.

Defining an action

Map the action name to the action controller in your plugin's actions.php:

@ewinslow
ewinslow / List.php
Last active August 29, 2015 14:10
php collections interfaces
<?php
/**
* An ordered collection.
*
* could call it "Sequence"
*
* @generic V
*/
interface List extends Collection {
@ewinslow
ewinslow / classes.md
Last active January 24, 2018 04:03
How I wish ES6 classes were implemented

Introduction

ES6 classes are happening, and there's no way the syntax is going to change radically just for me this late in the game, but I still figure what the heck. Maybe I can write a language someday that has this feature. Or maybe I'm wrong and the feature can change with enough motivation...

Background

The main premise of the currently accepted syntax is to be simple sugar over the prototype style of class definitions:

function Foo() {
@ewinslow
ewinslow / Column.php
Last active August 29, 2015 14:15
Defining SQL schema with PHP
<?php
namespace Elgg\Schema;
/**
* A facade for tersely instantiating all the different types of columns
*/
class Column {
public static function bool(): BoolColumn {}
public static function blob(int $size): BlobColumn {}