Skip to content

Instantly share code, notes, and snippets.

View chukShirley's full-sized avatar

Chuk Shirley chukShirley

  • Sure Consulting LLC
  • Alabama
View GitHub Profile
SELECT a.*, b.NumberOfRows
FROM MYTABLE a
CROSS JOIN (SELECT COUNT(*) AS NumberOfRows FROM MYTABLE) b
@chukShirley
chukShirley / MyController.php
Last active August 29, 2015 14:20
Value Objects
<?php
namespace Sabel;
class MyController
{
public function myMethod($data)
{
SysemReferenceNumberValue::fromString($data['systemReferenceNumber']);
// Use SystemReferenceNumber value object from here on out
@chukShirley
chukShirley / myFile.js
Created May 21, 2015 13:28
Treat $.ajax() calls as promises
function saveNewCustomer(customerData){
return $.ajax({
type:'POST',
url:'myUrl',
data:customerData,
dataType:'json'
});
}
saveNewCustomer.done(function(response){
@chukShirley
chukShirley / test.php
Last active August 29, 2015 14:23
Library list mixup
<?php
// Simulate connections to production applications
$db = connectToProduction('ADAM','MYPASS');
$db = connectToProduction('AS400','MYPASS');
$db = connectToProduction('CHIP','MYPASS');
$db = connectToProduction('WEBUSER','WEBUSER');
$i = 0;
while($i <= 5) {
<?php
// config/application.config.php
$env = getenv('APPLICATION_ENV');
return [
'appVersion' => '1.2.9',
'modules' => [
'Application',
'Scrap'
],
'module_listener_options' => [
@chukShirley
chukShirley / db2.travis.xml
Last active August 29, 2015 14:25
Travis.xml for Doctrine (IBM DB2)
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="../Doctrine/Tests/TestInit.php" colors="true">
<php>
<var name="db_type" value="ibm_db2"/>
<var name="db_host" value="myDbName" />
<var name="db_username" value="WEBTEST" />
<var name="db_password" value="WEBTEST" />
<var name="db_name" value="DCTRNTST" />
<var name="db_port" value="3306"/>
LoadModule ibm_ssl_module /QSYS.LIB/QHTTPSVR.LIB/QZSRVSSL.SRVPGM
# Enable compression
LoadModule deflate_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
# Specify content types to compress
AddOutputFilterByType DEFLATE application/x-httpd-php application/json text/css application/x-javascript application/javascript text/html
# Browser caching rules
ExpiresActive On
@chukShirley
chukShirley / CustomerId.php
Created August 12, 2015 01:15
value object for unique key containing multiple columns
<?php
class CustomerId
{
private $name;
private $address;
public function __construct($name, $address)
{
$this->name = (string) $name;
@chukShirley
chukShirley / PostMapper.php
Last active August 29, 2015 14:27
Persistence
<?php
class PostMapper
{
public function objectToDb(Post $post)
{
return [
'title' => $post->getTitle(),
'content' => $post->getContent()
];
}
<?php
// /Module/IbmiToolkit/src/IbmiToolkit/Factory/ToolkitFactory.php
namespace IbmiToolkit\Factory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Class ToolkitFactory