Skip to content

Instantly share code, notes, and snippets.

View linxlad's full-sized avatar

Nathan Daly linxlad

  • Bury St Edmunds, England
View GitHub Profile
/**
* Initialize form (extended from HouseSimple_Form)
*
* @return void
*/
public function init()
{
$this->setMethod('post');
$this->setAttrib('class', 'Form Form--user');
$this->setAction($this->getView()->url());
/**
* hs.property-questionnaire.js
*
* Property questionnaire scripts.
*/
(function($) {
// Set-up questionnaire namespace.
Hs.questionnaire = {};
@linxlad
linxlad / Version20150701100015.php
Last active August 29, 2015 14:24
Referral Migration
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Create tables for the referral system.
@linxlad
linxlad / Version20150625094625.php
Created July 3, 2015 10:13
Status corrections
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20150625094625
* @package Application\Migrations
@linxlad
linxlad / progress-bar.php
Created July 3, 2015 10:16
CLI progress bar
<?php
printf("\r" . str_repeat("=", round(($key / $count) * 100)) . "> %d%% (%s/%s)", round(($key / $count) * 100), $key, $count);
@linxlad
linxlad / shoutLogic.php
Last active August 29, 2015 14:24
Shout boxes
// Configure any shout boxes
$shoutBoxes = [];
$shouts = $this->entityManager->getRepository('AppBundle:ShoutBox')
->findBy(['active' => 'active', 'deleted' => 0]);
if (!empty($shouts)) {
foreach ($shouts as $shout) {
$shoutBoxes[] = [
'name' => $shout->getName(),
'icon' => '',
// Configure any shout boxes
$shoutBoxes = [];
$shouts = $this->entityManager->getRepository('AppBundle:ShoutBox')
->findBy(['active' => 'active', 'deleted' => 0]);
if (!empty($shouts)) {
foreach ($shouts as $index => $shout) {
$shoutBoxes[$index] = [
'name' => $shout->getName(),
'icon' => '',
@linxlad
linxlad / Buzz.php
Created July 8, 2015 14:05
Buzz Browser Service in Symfony2
<?php
namespace AppBundle\Util;
use Buzz\Browser;
use Buzz\Exception\RequestException;
/**
* Class Buzz
* @package AppBundle\Util
@linxlad
linxlad / camelCaseToUnderscore.php
Created July 8, 2015 16:57
Camel case to underscore with unicode support
/**
* @param string
* @return string
*/
function camelCaseToUnderscore($string)
{
// Default patterm
$pattern = array('#(?<=(?:[A-Z]))([A-Z]+)([A-Z][A-z])#', '#(?<=(?:[a-z0-9]))([A-Z])#');
// Check fo unicode support
@linxlad
linxlad / price-percentages.sql
Created July 9, 2015 10:00
Price range percentages
SELECT
concat(round((Count(case when pr.`price` > 0 AND pr.`price` <= 50000 then 1 end) / Count(1) * 100), 2 ),'%') As '£0 - £50K',
concat(round((Count(case when pr.`price` > 50000 AND pr.`price` <= 100000 then 1 end) / Count(1) * 100), 2 ),'%') As '£50 - £100K',
concat(round((Count(case when pr.`price` > 100000 AND pr.`price` <= 150000 then 1 end) / Count(1) * 100), 2 ),'%') As '£100 - £150K',
concat(round((Count(case when pr.`price` > 150000 AND pr.`price` <= 200000 then 1 end) / Count(1) * 100), 2 ),'%') As '£150K - £200K',
concat(round((Count(case when pr.`price` > 200000 AND pr.`price` <= 250000 then 1 end) / Count(1) * 100), 2 ),'%') As '£200K - £250K',
concat(round((Count(case when pr.`price` > 250000 AND pr.`price` <= 300000 then 1 end) / Count(1) * 100), 2 ),'%') As '£250K - £300K',
concat(round((Count(case when pr.`price` > 300000 AND pr.`price` <= 350000 then 1 end) / Count(1) * 100), 2 ),'%') As '£300K - £350K',
concat(round((Count(case when pr.`price` > 350000 AND pr.`price` <= 400000 then 1 end)