Skip to content

Instantly share code, notes, and snippets.

😍
Mautic WOOOO

Don Gilbert dongilbert

😍
Mautic WOOOO
Block or report user

Report or block dongilbert

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
@dongilbert
dongilbert / README.md
Created Nov 8, 2016 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle
View README.md

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@dongilbert
dongilbert / geocode.php
Created May 10, 2014
Geocode an address, passed as array params
View geocode.php
<?php
/**
* Geocode an address.
*
* @param mixed $params Array containing address info or string address.
*
* @return array Array of longitude or latitude data.
*/
function getLatLng($params)
{
@dongilbert
dongilbert / formmod.php
Created May 7, 2014
System plugin to modify form inputs.
View formmod.php
<?php
/**
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
class plgSystemFormmod extends JPlugin
{
View benchmark.php
<?php
function benchmark($name, $iterations, Closure $function)
{
echo "Starting Benchmark: {$name} (".number_format($iterations)." Iterations)\n";
$start = microtime(true);
for ($i = 0; $i < $iterations; $i++) {
$function();
}
$elapsed = microtime(true) - $start;
@dongilbert
dongilbert / AbstractBaseEntity.php
Created Apr 25, 2014
AbstractBaseEntity - the solution to the problem was to wrap the constructor `$this->entityData = $data` in an `if(empty($data))` block.
View AbstractBaseEntity.php
<?php
namespace Entities;
abstract class AbstractBaseEntity
{
protected $entityData = [];
final public function __construct($data = [])
{
View keybase.md

Keybase proof

I hereby claim:

  • I am dongilbert on github.
  • I am dongilbert (https://keybase.io/dongilbert) on keybase.
  • I have a public key whose fingerprint is 11E8 E1EB C4AC 096D 18B1 2D07 73BC 273C 63F2 EDFE

To claim this, I am signing this object:

@dongilbert
dongilbert / results
Created Jan 17, 2014
Benchmark newInstanceWithoutConstructor vs unserialize for object creation
View results
ReflectionClass::newInstanceWithoutConstructor: 0.039168834686279
unserialize: 0.14324808120728
@dongilbert
dongilbert / ArrayOf.php
Created Jan 16, 2014
Abstract ArrayOf Class
View ArrayOf.php
<?php
abstract class ArrayOf implements ArrayAccess, Iterator
{
protected $type = null;
protected $data = [];
protected $index = 0;
@dongilbert
dongilbert / .profile
Created Nov 15, 2013
PHP Quick Switching I've linked up the libphp5.so to a symlinked version in `~/.phpenv/` and also linked up the current version's `bin` folder.
View .profile
alias php53='brew unlink php53 > /dev/null; brew unlink php54 > /dev/null; brew unlink php55 > /dev/null; brew link php53 > /dev/null; ln -sf /usr/local/Cellar/php53/5.3.26/libexec/apache2/libphp5.so /Users/admin/.phpenv/libphp5.so; ln -sf /usr/local/Cellar/php54/5.3.26/bin /Users/admin/.phpenv/bin; sudo apachectl restart; echo "PHP 5.3 Enabled";'
alias php54='brew unlink php53 > /dev/null; brew unlink php54 > /dev/null; brew unlink php55 > /dev/null; brew link php54 > /dev/null; ln -sf /usr/local/Cellar/php54/5.4.19/libexec/apache2/libphp5.so /Users/admin/.phpenv/libphp5.so; ln -sf /usr/local/Cellar/php54/5.4.19/bin /Users/admin/.phpenv/bin; sudo apachectl restart; echo "PHP 5.4 Enabled";'
alias php55='brew unlink php53 > /dev/null; brew unlink php54 > /dev/null; brew unlink php55 > /dev/null; brew link php55 > /dev/null; ln -sf /usr/local/Cellar/php55/5.5.3/libexec/apache2/libphp5.so /Users/admin/.phpenv/libphp5.so; ln -sf /usr/local/Cellar/php54/5.5.3/bin /Users/admin/.phpenv/bin; sudo apachectl restart; e
View streamcsv.php
<?php
class SomeClass
{
public function resortCsv()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('robot_id, title, address1, city, state, zip, sub_title, description')
->from('#__rv_resorts');
You can’t perform that action at this time.