Skip to content

Instantly share code, notes, and snippets.

View intellix's full-sized avatar

D intellix

View GitHub Profile
@intellix
intellix / build.js
Created February 9, 2015 10:48
gulp deploy task for creating a number incremented folder for symlinking to
/**
* For creating a numbered folder inside /deploys,
* shoving in the contents of /dist and for symlinking to when happy. Eg:
* /deploys/2
* /www --> symlinks to --> /deploys/2
*/
gulp.task('deploy', function (cb) {
var deploys = fs.readdirSync('./deploys');
var version = 1;
if (deploys.length) {
@intellix
intellix / Dockerfile
Created February 6, 2015 14:06
Recipe for prerender
# Prerender server with S3 cache
FROM dockerfile/nodejs
RUN apt-get update -y
RUN apt-get install -y \
python2.7 python-pip \
libfreetype6 libfontconfig
RUN cd / && git clone https://github.com/prerender/prerender
@intellix
intellix / _glyphicons.scss
Created January 22, 2015 10:32
glyphicon-pro CSS consistent with Bootstrap naming
//
// Glyphicons for Bootstrap
//
// Since icons are fonts, they can be placed anywhere text is placed and are
// thus automatically sized to match the surrounding child. To use, create an
// inline element with the appropriate classes, like so:
//
// <a href="#"><span class="glyphicon glyphicon-star"></span> Star</a>
// Import the fonts
@intellix
intellix / Gruntfile.js
Created May 30, 2014 12:25
ngtemplates
module.exports = function(grunt) {
grunt.initConfig({
ngtemplates: {
yourModuleName: {
options: {
// This will add a / so make sure you ng-include="/app/blah.tpl.html" etc
prefix: '/'
},
cwd: '<%= yeoman.src %>',
src: 'app/{,**/}*.tpl.html',
'use strict';
angular.module('myApp').service('UserService', function($http, $q, $location) {
var self = {
identity: {
id: 'guest'
},
@intellix
intellix / form.html
Created February 13, 2014 09:04
One field with validation Bootstrap/Angular
<div class="form-group" ng-class="{'has-error': stepForm.email.$invalid && (stepForm.email.$dirty || stepForm.submitted), 'has-success': !stepForm.email.$invalid, 'has-feedback': (stepForm.email.$invalid && stepForm.email.$dirty) || !stepForm.email.$invalid || stepForm.submitted}">
<div class="col-md-12">
<input type="email" placeholder="{{ 'Email' | translate }}" class="form-control" ng-model="user.email" name="email" required>
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-ok': !stepForm.email.$invalid, 'glyphicon-remove': stepForm.email.$invalid && (stepForm.email.$dirty || stepForm.submitted)}" ng-show="(stepForm.email.$invalid && stepForm.email.$dirty) || !stepForm.email.$invalid || stepForm.submitted"></span>
<p class="help-block error" ng-show="stepForm.email.$error.required && (stepForm.email.$dirty || stepForm.submitted)">{{ 'This field is required' | translate }}</p>
<p class="help-block error" ng-show="stepForm.email.$error.email && (stepForm.email.$dirty || stepForm.s
@intellix
intellix / perspective-back.js
Last active November 25, 2017 11:44
Moving a background and having foreground sit on top in AngularJS
'use strict';
angular.module('myApp').directive('perspectiveBack', function($window) {
return {
link: function(scope, element, attrs) {
var distance = attrs.distance || 2;
element.css({
'background-image': 'url(' + attrs.foreground +'), url(' + attrs.background + ')',
@intellix
intellix / item-controller.js
Created January 12, 2014 13:49
AngularJS - Loading from AJAX once and caching within the service. Promise is always returned for consistency
'use strict';
angular.module('myApp').controller('ItemCtrl', function ($scope, ItemService) {
$scope.items = ItemService.items;
ItemService.load().then(function() {
console.log('Items are loaded:', $scope.items);
});
});
@intellix
intellix / application.config.php
Last active December 26, 2015 12:29
SlmLocale config
<?php
return array(
// This should be an array of module namespaces used in the application.
'modules' => array(
'SlmLocale',
'Application',
),
// These are various options for the listeners attached to the ModuleManager
'module_listener_options' => array(
@intellix
intellix / ApplicationTest\Service\AccountServiceTest.php
Last active December 26, 2015 11:39
Testing a Doctrine ZF2 Application with rollbacking of data inserted into your database during the test. Listener solution found through stackoverflow: http://stackoverflow.com/questions/12456281/how-to-clean-a-test-database-with-doctrine And apparently since creating this, I've been provided this by ocramius for a Doctrine testing environment: h…
<?php
namespace ApplicationTest\Service;
use PHPUnit_Framework_TestCase;
use ApplicationTest\Bootstrap;
use Application\Service;
use Application\Entity;