Skip to content

Instantly share code, notes, and snippets.

Matthew Setter settermjd

Block or report user

Report or block settermjd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@settermjd
settermjd / select-count.php
Created Dec 16, 2013
An example of using an SQL Expression in Zend\Db\Sql
View select-count.php
/**
* First construct the Select object for the SQL query to run
*/
$select = new Select('tblusers');
$select->columns(array(
"recordCount" => new \Zend\Db\Sql\Expression("COUNT(*)")
));
/**
* Then execute the query, retrieving the first record, if available
@settermjd
settermjd / gist:8430918
Created Jan 15, 2014
A Zend Form created via annotations, modelling a very simple user record.
View gist:8430918
<?php
namespace MyApplication\Form;
use Zend\Form\Annotation;
/**
* @Annotation\Name("user")
* @Annotation\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty")
*/
@settermjd
settermjd / compact-child-routes
Created Apr 2, 2014
Simple example of using child routes, using the Segment type, to keep a routing table in Zend Framework 2 simple and compact. For more information, check out http://www.masterzendframework.com/tutorial/child-and-segment-routes.
View compact-child-routes
return array(
'router' => array(
'routes' => array(
'forecaster' => array(
'type' => 'Literal',
'options' => array(
'route' => '/forecaster',
'defaults' => array(
'__NAMESPACE__' => 'Forecaster\Controller',
'controller' => 'Forecaster',
View zf2-constructor-Injection.php
// IndexControllerFactory.php
namespace YourModule\Controller\Factory;
use Zend\ServiceManager\FactoryInterface,
Zend\ServiceManager\ServiceLocatorInterface,
Zend\ServiceManager\Exception\ServiceNotCreatedException,
YourModule\Controller\IndexController;
class IndexControllerFactory implements FactoryInterface
{
@settermjd
settermjd / CustomSelectElementWithFormElementManager.php
Created Apr 22, 2014
A simple example of creating a custom select element, using the FormElementManager to handle the external dependencies.
View CustomSelectElementWithFormElementManager.php
<?php
/**
* Define the custom form element
*/
namespace Forecaster\Form\Element;
use Zend\Form\Element\Select;
use Zend\InputFilter\InputProviderInterface;
use Zend\Validator\Db\RecordExists;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
@settermjd
settermjd / nginx owncloud config
Created Sep 3, 2014
A configuration of nginx for ownCloud (doesn't quite work yet)
View nginx owncloud config
server {
listen 80;
server_name owncloud.app
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
server_name owncloud.app;
root /home/vagrant/owncloud;
View gist:762e3297639d8e9e8675
// The following is a route to simplify getting started creating
// new controllers and actions without needing to create a new
// module. Simply drop new controllers in, and you can access them
// using the path /application/:controller/:action
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
@settermjd
settermjd / gist:b9f4c875c252c587e737
Created Feb 26, 2015
Attempting to know if the following examples are effectively the same thing
View gist:b9f4c875c252c587e737
/**
* Are these two examples the same, with the second just being more verbose?
*/
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
@settermjd
settermjd / spark-service
Created Mar 2, 2015
A simple chkconfig script to manage starting and stopping the Maven/Jetty server, which supports a SparkJava application
View spark-service
#! /bin/bash
#
# spark-service Start/Stop the Maven Jetty process
#
# chkconfig: 235 90 60
# description: This will manage the starting and stopping of the Maven/Jetty
# server which will render the SparkJava application. It's
# rather simple, so don't expect miracles of it.
#
View query-with-winston.sh
node winston.query.js | tr "[{:,'" ' ' | tr -s " " | awk '/country/ { print $2 }' | sort | uniq | wc -l | tr -s " "
You can’t perform that action at this time.