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
@linxlad
linxlad / gist:a5f8604a4e3159eb8ef0
Created February 15, 2016 11:02 — forked from plasticbrain/gist:3887245
PHP: mime types (array format)
<?php
$mime_types = array(
'.3dm' => 'x-world/x-3dmf',
'.3dmf' => 'x-world/x-3dmf',
'.a' => 'application/octet-stream',
'.aab' => 'application/x-authorware-bin',
'.aam' => 'application/x-authorware-map',
'.aas' => 'application/x-authorware-seg',
'.abc' => 'text/vnd.abc',
'.acgi' => 'text/html',
@linxlad
linxlad / Navigation.service.js
Created October 18, 2015 23:30
Service model that is the setter and getter for the current page.
(function () {
'use strict';
angular
.module('app')
.factory('Navigation', Navigation);
Navigation.$inject = [];
@linxlad
linxlad / Navigation.directive.js
Created October 18, 2015 23:27
Navigation directive in AngularJS that watches for a change from current page.
;(function() {
'use strict';
/**
* Main navigation, just a HTML template
* @author Nathan Daly
* @ngdoc Directive
*
* @example
@linxlad
linxlad / UserAccount.service.js
Created October 14, 2015 10:09
AngularJS user account service for registering and logging in.
(function () {
'use strict';
angular
.module('common.service')
.factory('UserAccount', UserAccount);
UserAccount.$inject = ['$resource', 'appSettings'];
function UserAccount($resource, appSettings) {
@linxlad
linxlad / CanTransitionToVerifyListener.php
Created September 23, 2015 10:24
Check if any of the referee properties can verify the referral.
<?php
namespace AppBundle\EventListener\Referral;
use AppBundle\Entity\Referral;
use SM\Event\TransitionEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class CanTransitionToVerifyListener
{
@linxlad
linxlad / character-counter.js
Last active August 29, 2015 14:27
JavaSscript TextArea Character counter
App.questionnaire.TextAreaCharacterCounter = function () {
var textMax = 300,
textAreas = ['summary', 'directions'];
textAreas.forEach(function(textArea) {
var $textArea = $('#' + textArea);
App.questionnaire.updateTexAreaDescriptionWithCharacterCount($textArea, textMax);
$textArea.on('focus keyup' , function () {
@linxlad
linxlad / findMissingNumber.php
Last active August 29, 2015 14:26
Find Missing Number in PHP (Shortes Solution Challenge)
<?php
function findMissingNmber($A) {
return reset(array_diff(range(min($A),max($A)),$A));
}
@linxlad
linxlad / avg_time_to_sell.sql
Created July 27, 2015 10:44
AVG Time To Sell
SELECT
p.id AS 'PROPERTY ID',
CONCAT_WS(
', ',
CONCAT_WS(
' ',
NULLIF(TRIM(a.building_number), ''),
NULLIF(TRIM(a.building_name), ''),
a.street
),
<div class="large-12 columns">
<input type="radio" id="user_gender_0" name="user[gender]" required="required" class="" value="male"> <label class="is-required">Male<input type="radio" id="user_gender_1" name="user[gender]" required="required" class="" value="female"> <label class="is-required">Female</label></label>
</div>
@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)