Skip to content

Instantly share code, notes, and snippets.

@eddieajau
eddieajau / Collection.js
Created December 16, 2014 00:51
Clean architecture for basic entity CRUD in Node.
/**
* Collection Interface.
*
* Concrete implementations would exist INSIDE the boundary interfaces.
*
* - Must be able to add one or more entities to the collection.
* - Must be able to find entities in the collection.
* - Must be able update entities in the collection.
* - Must be able to remove entities from the collection.
*
@eddieajau
eddieajau / package.json
Created May 25, 2015 00:01
NPM Package Scripts
{
"devDependencies": {
"app-root-path": "^1.0.0",
"jshint": "^2.7.0",
"mocha": "^2.2.5",
"supertest": "^1.0.1"
},
"scripts": {
"check": "npm outdated",
"lint": "node_modules/.bin/jshint lib/ test/",
@eddieajau
eddieajau / waterline-error.md
Created August 3, 2015 23:23
Waterline validation error
model.create(someData)
  .catch(function (err) {
    console.error('ValidationError:', err.ValidationError);
    console.error('Message:', err.message);
  });

Outputs:

ValidationError: {
@eddieajau
eddieajau / database_iterator.php
Created February 21, 2012 07:28
Joomla Database Iterator
<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
@eddieajau
eddieajau / gist:2505017
Created April 27, 2012 01:57
A class method that can be used to import a CSV file of any size using SplFileObject.
/**
* Import a CSV file.
*
* @param string $fileName The name of the file to import. If omitted, the state is used.
* @param integer $offset The number of lines/rows to ignore (default = 0).
*
* @return void
*
* @since 1.0
* @throws InvalidArgumentException if file name is invalid or does not exist.
@eddieajau
eddieajau / PSR-1.md
Created May 4, 2012 23:29
PSR-1,2 Combined variant

PSR-1 PHP Code Style Standard

Version: 1 2012-05-??

This standard comprises the code style requirements for interoperability (Section 1) and the best practices guidelines (Section 2) for PHP projects.

O Definitions

studly-caps refers to a naming convention where all 'words' in the name are conactenated and have only the first letter in uppercase followed by lower case letters (for example "StudlyCaps").

@eddieajau
eddieajau / libraries_cms_version_compatibility.php
Created December 13, 2012 04:33
Joomla version compatibility class.
<?php
class JVersionCompatibility
{
/**
* Class constructor.
*
* @param SimpleXmlElement $node The compatibility node from a manifest file.
*
* @see https://github.com/joomla/joomla-cms/issues/598 for XML specification.
*/
@eddieajau
eddieajau / backend_lists_20130124.xml
Created January 27, 2013 23:58
Eclipse snippet category for backend component lists in Joomla 2.5 (all except view layouts are applicable for Joomla 3.0). Includes: Controller Set Default View, Backend List View, Backend List Layout, Backend List Model, Backend List Layout Search Filter, Backend List Model Search Filters (state), Backend List Model Search Filters (query), Bac…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1276571415504" initial_state="1" label="Backend Lists" largeicon="" smallicon="">
<description><![CDATA[Snippets specifically for creating backend list views.]]></description>
<item category="category_1276571415504" class="" editorclass="" id="item_1276485904815" label="Controller Set Default View" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet is intended for the master controller and adds the "default_view" property to class definition. The default view is assumed to be the name of the component (less the com_ prefix). If you want to change the default view then add this snippet.]]></description>
<content><![CDATA[ /**
* @var string The default view.
* @since ${SINCE}
*/
@eddieajau
eddieajau / backend_edit_pages.xml
Created January 28, 2013 00:05
Eclipse snippet category for backend component edit pages in Joomla 2.5 (all except view layouts are applicable for Joomla 3.0). Includes: Backend Item Sub-controller, Backend Item Model, Backend Item XML Form, Backend Item Edit View, backend Item Edit Layout, Backend Item Edit Params Sub-layout, Backend Item Edit Metadata Sub-layout, Backend It…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1276571442053" initial_state="1" label="Backend Edit Pages" largeicon="" smallicon="">
<description><![CDATA[Snippets specifically for creating backend edit views.]]></description>
<item category="category_1276571442053" class="" editorclass="" id="item_1276505902148" label="Backend Item Subcontroller" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet adds the basic sub-controller for single item.]]></description>
<content><![CDATA[jimport('joomla.application.component.controllerform');
/**
* ${VIEW} Subcontroller.
@eddieajau
eddieajau / backend_support.xml
Created January 28, 2013 01:18
Eclipse snippet category for backend component support code in Joomla 2.5 (all except CSS should be applicable for Joomla 3.0). Includes: Add submenu method for backend component helper, Add submenu call to master backend controller, Adds a call to JSubMenuHelper that will show a link to the categories view., Text prefix for item subcontroller, …
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1303255935762" initial_state="1" label="Backend Support" largeicon="" smallicon="">
<description><![CDATA[Additional snippets that support backend components.]]></description>
<item category="category_1303255935762" class="" editorclass="" id="item_1303256255316" label="Add submenu method for backend component helper" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet provides the addSubmenu method that should be added to the backend helper class (usually found in /com_{component}/helpers/{component}.php). One sub-menu entry is provided - copy and paste to suit the number of views that need to be supported. Remember to add the hook into the controller to invoke this method.]]></description>
<content><![CDATA[ /**
* Configure the Linkbar.
*
* @param string $vName The name of