Skip to content

Instantly share code, notes, and snippets.

@gregstewart
gregstewart / gist:74573eea38adc51c1ee6
Last active August 29, 2015 14:13
Different factory patterns
function ObjectFactory () {
this.build = {
chocolate: function () {
console.log('built a chocolate factory');
},
fudge: function () {
console.log('built a fudge factory');
}
}
}
@gregstewart
gregstewart / gist:fae1a7be9d2fbbea5fb6
Last active August 29, 2015 14:13
Playing with blocks and partition
class Order
attr_accessor :size, :value
def initialize size, value
@size = size
@value = value
end
end
# This is a comment
FROM ubuntu:14.04
MAINTAINER Greg Stewart <gregs@tcias.co.uk>
RUN apt-get update && apt-get install -y curl --assume-yes
RUN \curl -sSL https://get.rvm.io | bash
RUN echo 'source /etc/profile.d/rvm.sh' >> ~/.bashrc
RUN /usr/local/rvm/bin/rvm-shell -c "rvm requirements"
# install Ruby
RUN /usr/local/rvm/bin/rvm-shell -c "rvm autolibs enable"
RUN /usr/local/rvm/bin/rvm-shell -c "rvm install 2.1.4"
@gregstewart
gregstewart / gist:dcb0055d3a8bc1cbac2b
Created October 6, 2014 12:40
Compare functions again
_.uniq(array.filter(function (fn) { return fn === element; }))
@gregstewart
gregstewart / gist:44e8520d479116146fea
Created October 6, 2014 12:39
Compare functions and let me know if you found matching ones (toString comparison)
_.uniq(array.map(function (f) { return f.toString(); }), element.toString())
@gregstewart
gregstewart / plato.js
Created August 21, 2014 10:10
configuration for grunt-plato task
(function (module) {
'use strict';
var config = {
plato: {
options : {
exclude: /assets\/.+/
},
files: {
'reports/plato': ['src/**/*.js', 'test/**/*.js']
@gregstewart
gregstewart / gist:a2ea45d7ca35d424d83e
Created June 2, 2014 09:19
Git store and unset credentials snippet
# store credentials
git config credential.helper store
# unset storing of credentials
git config --unset credential.helper
@gregstewart
gregstewart / inner outer border radius button
Created February 22, 2013 11:52
Basic css button with an exterior and interior rounded border
.button {
display: inline-block;
@include border-radius(1.5em);
padding: 0.25em 2em;
margin: 0.25em 0;
font: {
weight: normal;
size: 100%;
family: $brand-face-bold;
}
@gregstewart
gregstewart / gist:4124152
Created November 21, 2012 10:27
Global namespace checker spec file
describe("our use of global namespace", function () {
var in_array = function (value, array) {
return ($.inArray(value, array) !== -1);
};
var global_namespace_provenance = function (thing) {
var previous_global_things = _global_namespace_things;
if (in_array(thing, previous_global_things)) {
return "existed in global before: " + thing;