Skip to content

Instantly share code, notes, and snippets.

View newage's full-sized avatar

Vadim Leontiev newage

View GitHub Profile
@newage
newage / gist:3edf7a8c0fc59b9174eefee5c30bb30a
Created March 27, 2017 14:57 — forked from zdne/gist:5f8295642af18aff27ec
Working with multiple API Blueprint files

Working with multiple blueprint files

This document describes 4 different solutions to work APIs that consist of multiple blueprint files. Every of this solution work with all Apiary.io features but editing. To edit a blueprint you have to do it outside of Apiary as Apiary editor does not support working with multiple files. In other words if you are using one of the solutions below avoid editing the blueprint in Apiary.

1. Hercule

Hercule is a CLI tool written in Node.js – available as an NPM package. It uses markdown referencing and linking syntax to transclude other files into a blueprint file. This solution is universal and would work with any Markdown files not just API Blueprint.

The major benefit – unlike any other solutions here – is also that the references are rendered as HTML links in any Markdown editor so the result is HTML that can be browsed!

@newage
newage / gist:5b4739a8f5a0c151ec9581fac2ba23e9
Last active June 30, 2016 11:43
Zend Frameword 2 create a table factory
namespace Album;
// Add these import statements:
use Album\Model\Album;
use Album\Model\AlbumTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
class Module
{
<?xml version="1.0" encoding="UTF-8"?>
<project name="ci-phing-behat-test" default="dev">
<!-- load variable definitions -->
<property file="build.properties"/>
<property name="behat.basedir" value="${project.basedir}/../test"/>
<!-- define custom tasks and types -->
<typedef name="args" classname="phing.behat.types.BehatArguments"/>
@newage
newage / gist:4937b014b4fbc8a4cbf4
Last active August 29, 2015 14:03
Add predicate to where with identifier and credential expressions in ZF2
$adapter = $this->getAdapter();
$platform = $adapter->getPlatform();
$predicateIn = 'DATE('.$platform->quoteIdentifierChain(array('dt_created')).')';
$predicateIn .= " IN (";
$predicateIn .= $platform->quoteValueList($days);
$predicateIn .= ")";
$select->where(array($predicateIn));
@newage
newage / gist:e7336d05747330b0524f
Created July 8, 2014 09:00
MySql multi insert for ZF2
/**
* Insert many rows as one query
* @param array $data Insert array(array('field_name' => 'field_value'), array('field_name' => 'field_value_new'))
* @return bool
*/
public function multiInsert(array $data)
{
$sqlStringTemplate = 'INSERT INTO %s (%s) VALUES %s';
$adapter = $this->tableGateway->adapter; /* Get adapter from tableGateway */
$driver = $adapter->getDriver();
@newage
newage / gist:227d7c3fb8202e473a76
Last active August 29, 2015 14:03
MySql INSERT ... ON DUPLICATE KEY UPDATE Syntax in ZF2
/**
* Use INSERT ... ON DUPLICATE KEY UPDATE Syntax
* @since mysql 5.1
* @param array $insertData For insert array('field_name' => 'field_value')
* @param array $updateData For update array('field_name' => 'field_value_new')
* @return bool
*/
public function insertOrUpdate(array $insertData, array $updateData)
{
$sqlStringTemplate = 'INSERT INTO %s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s';