Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Simon Renoult simonrenoult

🏠
Working from home
View GitHub Profile
@simonrenoult
simonrenoult / config.rb
Created Sep 5, 2013
Default Compass configuration file.
View config.rb
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
@simonrenoult
simonrenoult / timeout.js
Last active Jan 25, 2021
Managing timeout. Especially handy with autocomplete.
View timeout.js
// Props to : http://nathanleclaire.com/blog/2013/11/16/the-javascript-question-i-bombed-in-an-interview-with-a-y-combinator-startup/
var processOnTime = function ( next, delay ) {
var d = delay;
if ( ! next ) {
throw new ReferenceError();
}
if ( ! d || isNaN ( d ) ) {
d = 200;
View typeChecking.js
// Props to : http://techblog.badoo.com/blog/2013/11/01/type-checking-in-javascript/
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements
if (o && (o.nodeType === 1 || o.nodeType === 9)) {
@simonrenoult
simonrenoult / random.js
Created Nov 25, 2013
Generate a random number. Default range is 10 000. Will fail with a boolean (range will be cast into a number).
View random.js
var getRandomID = function ( range ) {
var r = range;
if ( isNaN ( r ) ) {
r = 10000;
}
return Math.floor ( Math.random() * r );
};
@simonrenoult
simonrenoult / inheritance.js
Last active Dec 29, 2015
Classical inheritance. Use Object.create to inherit object. Javascript >= 1.8.5
View inheritance.js
var Parent = function ( settings ) {
this.name = settings.name;
};
Parent.prototype.greet = function () {
console.log ( 'Hello ' + this.name );
};
var Child = function ( settings ) {
Parent.call ( this, settings );
@simonrenoult
simonrenoult / hexToRGB.coffee
Created Dec 20, 2013
Hexadecimal color to RGB.
View hexToRGB.coffee
color = '#' + ( @model.get 'stroke_color' )
.map ( color ) ->
xColor = color.toString 16
if xColor.length is 1 then "0" + xColor else xColor
.reduce ( prev, cur, i ) ->
if i < 3 then prev + cur else prev
@simonrenoult
simonrenoult / hexToRGBA.coffee
Created Dec 20, 2013
Hexadecimal color to RGBA.
View hexToRGBA.coffee
color = '#' + ( @model.get 'stroke_color' )
.map ( color ) ->
xColor = color.toString 16
if xColor.length is 1 then "0" + xColor else xColor
@simonrenoult
simonrenoult / inheritance.coffee
Created Feb 26, 2014
Inherit parent property in Backbone
View inheritance.coffee
# Inherits parent events and allow overriding.
@events = _.extend {}, CardView::events, @events
# Call parent initialize method
SpellsCreateView.__super__.initialize.apply @,arguments
@simonrenoult
simonrenoult / Gulpfile.js
Created Dec 23, 2014
Gulpfile with browserify, handlebars, webserver, lint, minification, bower, watch, reload
View Gulpfile.js
var gulp = require('gulp'),
del = require('del'),
plugins = require('gulp-load-plugins')(),
bower = require('main-bower-files'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
browserify = require('browserify'),
browserSync = require('browser-sync');
var conf = {
View bumper.sh
#!/bin/bash
# Borrowed from a github gist somewhere on the Internet, can't find the source :(
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use