Skip to content

Instantly share code, notes, and snippets.

View kirkbushell's full-sized avatar

Kirk Bushell kirkbushell

  • Tectonic Digital
  • Sydney
View GitHub Profile
@kirkbushell
kirkbushell / .bash_profile
Created May 22, 2013 22:40
Bash profile colours/settings.etc.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
source "$HOME/.bash_aliases"
LS_COLORS='di=1:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:*.deb=90'
PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}: ${PWD}\007"'
@kirkbushell
kirkbushell / filters.js
Created May 28, 2013 04:11
Default value filter for Angular JS applications - allows you to output a variable, and assign it a default value if it has a value of 0, null, or is an empty string. Very similar to PHP's empty() function, but provides a default value instead of a boolean.
/**
* Sets a default value for a given input.
*
* @param mixed input
* @param string defaultValue
* @return string
*/
module.filter( 'default', [ '$filter', function( $filter ) {
return function( input, defaultValue ) {
if ( !input ) return defaultValue;
@kirkbushell
kirkbushell / resolver.js
Created June 6, 2013 02:52
Simpe AngularJS service resolver for controller resolution.
var resolver = [ '$q', 'Service', function( $q, Service ) {
var deferred = $q.defer();
Service.query({ paginate: false }, function( data ) {
deferred.resolve( data );
}, function() {
deferred.reject( null );
});
return deferred.promise;
@kirkbushell
kirkbushell / typeahead.js
Last active December 19, 2015 10:39
Typeahead (https://github.com/twitter/typeahead.js) in combination with angular + utilizing models
/**
* Typeahead directive for fields. Expects both a typeahead and location attribute.
*
* @param string typeahead - If a value is provided, this should be a two-way data binding to the model that you would like to utilize in partnership with this plugin.
* @param string location - Where the data can be found for remote queries.
*/
module.directive( 'typeahead', [ '$window', '$timeout', function( $window, $timeout ) {
return {
restrict: 'A',
scope: { model: '=typeahead', value: '@' },
var registration = {
create: function() {
var status = null;
var data = {
id: '',
status: ''
};
this.setStatus = function(value) {
@servers(['web' => '111.111.111.111'])
@task('deploy')
cd /var/www
git pull origin master
composer install
php artisan migrate
@endtask
@kirkbushell
kirkbushell / interceptor.js
Created June 11, 2014 15:27
Angular JS HTTP response interceptor
/**
* Interceptor
* Implements functionality to catch various requests and fire events when they happen. This is generally to ensure
* that responses from the server are handled in a uniform fashion across the application. Also, by firing events
* it allows to have any number of handlers attach to the response.
*
* @author Kirk Bushell
* @date 28th March 2013
*/
var module = angular.module('core.interceptor', []);
@kirkbushell
kirkbushell / gulpfile.js
Created August 24, 2014 21:23
Gulpfile for Laravel 4 projects, with a complete assets workflow
// Load all the required plugins.
var gulp = require('gulp'),
notify = require('gulp-notify'),
exec = require('gulp-exec'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename');
var input = 'assets/',
@kirkbushell
kirkbushell / gist:0a7477ad371b285554b9
Created October 8, 2014 20:01
Deferred service provider overloading other deferred provider objects
class ValidationServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
public function register()
@kirkbushell
kirkbushell / gist:aa60d05a39dba9288e25
Last active May 30, 2017 10:06
Value object usage within Laravel Eloquent example
<?php
// In model: Ensures values are consistent
class User extends Eloquent {
public function setEmailAttribute(Email $email) {
$this->attributes['email'] = $email;
}
}
// Value object
class Email {