Skip to content

Instantly share code, notes, and snippets.

Avatar

Hamish Hossack hamishhossack

View GitHub Profile
@hamishhossack
hamishhossack / SymfonyGulp.js
Last active Feb 25, 2017
Symfony 2 with Gulp for Front-End Assets (optimize & make universal)
View SymfonyGulp.js
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var uglifycss = require('gulp-uglifycss');
var less = require('gulp-less');
var rjs = require('requirejs').optimize;
var concat = require('gulp-concat');
var bower = require ('gulp-bower');
var watch = require('gulp-watch');
var batch = require('gulp-batch');
var path = require('path');
@hamishhossack
hamishhossack / reverse-nginx-proxy.conf
Created May 4, 2016
A simple setup for using a reverse proxy in micro services
View reverse-nginx-proxy.conf
# EXAMPLEONE
upstream exampleone {
server host-ip:3000;
}
# EXAMPLETWO
upstream exampletwo {
server host-ip:3001;
}
@hamishhossack
hamishhossack / watermark.js
Created May 3, 2016
Batch watermark images with GM
View watermark.js
var Q = require('q');
var async = require('async');
var fs = require('fs');
var gm = require('gm');
var join = require('path').join;
var readdir = Q.denodeify(fs.readdir);
var dir = join(__dirname, 'images');
var dest = join(__dirname, 'dest');
var logo = join(__dirname, 'resources/tlf-logo-medium.png');
@hamishhossack
hamishhossack / gist:96f8b6f766934d85c2d4
Created Oct 20, 2015 — forked from eparreno/gist:1845561
Install libmagic on Mac OS X via homebrew
View gist:96f8b6f766934d85c2d4
$ brew install libmagic
$ brew link libmagic (if the link is already created is going to fail, don't worry about that)
$ env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
@hamishhossack
hamishhossack / SimpleHTTPServer
Created Aug 3, 2015
Simple web server on MAC
View SimpleHTTPServer
python -m SimpleHTTPServer 8000
@hamishhossack
hamishhossack / TwigTemplateManager.js
Created Jul 27, 2015
Override Marionette With Twig Templates (use cache templates)
View TwigTemplateManager.js
var loadExistingTwigTemplate = function (templateId) {
return Twig.twig({
ref: templateId
});
};
Marionette.TemplateCache.prototype.compileTemplate = function (template) {
switch (template.type) {
case 'twig/template':
// first, see if the template is already loaded
@hamishhossack
hamishhossack / CropManager.js
Created Jul 27, 2015
Image Cropping Manager (needs optimising)
View CropManager.js
var Crop = {
elements: {
editor: null,
container: null,
slider: null,
img: null,
overlay: null,
preview: null
},
View isURL.js
var isURL = function isUrl(s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
console.info('Is URL ? ', regexp.test(s));
return regexp.test(s);
};
@hamishhossack
hamishhossack / GoogleAS.js
Created Jul 27, 2015
Backbone Integration for googleAdSense
View GoogleAS.js
window.adsbygoogle = window.adsbygoogle || [];
var async = ( typeof c != "undefined" && !_.isUndefined(c.script) ) ? c.sript : $.getScript;
async("//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js");
var GoogleAS = new Backbone.Model({
id: 'GoogleAS',
client: 'pub-9565436045946419',
currentCount: 0,
maxSlots: 3,
@hamishhossack
hamishhossack / StorageManager.js
Created Jul 27, 2015
Local Storage Manager (timestamped, extra functionality, session & local storage) Deps: [underscore]
View StorageManager.js
var CacheManager = window.CacheManager = function (storage) {
var name = '';
if (typeof storage !== "string") {
throw new TypeError('The name of storage needs to be a character string.');
}
name = _.capitalize(storage) + 'Storage';
You can’t perform that action at this time.