Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
body {
position: relative;
height: 100px;
border-bottom: solid 2px hsl(340, 5%, 75%);
# Checkout files that were deleted
git status --porcelain | grep "^ D" | cut -c4- | xargs git checkout $1
var gulp = require('gulp');
// Let's make things more readable by
// encapsulating each part's setup
// in its own method
function startExpress() {
var express = require('express');
var app = express();
app.use(express.static(__dirname));
@romaricpascal
romaricpascal / hsbc-csv-statement.js
Last active January 1, 2016 23:38
Bookmarklet to export HSBC statements to CSV
(function () {
var months = {
'Jan': '01',
'Feb': '02',
'Mar': '03',
'Apr': '04',
'May': '05',
'Jun': '06',
'Jul': '07',
'Aug': '08',
@romaricpascal
romaricpascal / backbone-defaults-inheritance.js
Last active December 21, 2015 12:58
Inherit and extend defaults when extending a Backbone model
var Parent = Backbone.Model.extend({
defaults: function () {
return {
prop: 'value',
anotherProp: 'anotherValue'
}
}
});
@romaricpascal
romaricpascal / pre-commit.grunt.js
Created July 26, 2013 23:17
pre-commit Git hook that runs grunt to validate the sources before commit
#!/usr/bin/env node
var exec = require('child_process').exec;
// Runs the build task, in our case `grunt jshint`
exec('grunt jshint', function (error, stdout, stderr) {
// Build task output might be useful to the developer so let's print it
// We could also log it in a file
console.log(stdout);
@romaricpascal
romaricpascal / commit-msg.issue-id-prompt.js
Last active December 29, 2022 23:47
commit-msg Git hook to ask user for an issue ID when he commits and prepend it to the original commit message
#!/usr/bin/env node
var fs = require('fs'),
util = require('util');
// Rattern to format the message with the issue ID
var MESSAGE_FORMAT = '[%s] %s';
// Git commit messages are stored in a file, passed as argument to the script
// First and second arguments will be 'node' and the name of the script
var commitFile = process.argv[2];
@romaricpascal
romaricpascal / Gruntfile.livereload.js
Last active December 20, 2015 04:59
Gruntfile configuring grunt-express, grunt-contrib-watch and grunt-open with livereload as explained in my Grunt & livereload article: http://rhumaric.com/2013/07/renewing-the-g…vereload-magic/
// Gruntfile with the configuration of grunt-express and grunt-open. No livereload yet!
module.exports = function(grunt) {
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Configure Grunt
grunt.initConfig({
// grunt-express will serve the files from the folders listed in `bases`
@romaricpascal
romaricpascal / Gruntfile.express-connect.js
Last active December 20, 2015 04:59
Gruntfile configuring grunt-express and grunt-open to serve your projects file and open a browser, as a first step in my Grunt and livereload tutorial : http://rhumaric.com/2013/07/renewing-the-g…vereload-magic/
// Gruntfile with the configuration of grunt-express and grunt-open. No livereload yet!
module.exports = function(grunt) {
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Configure Grunt
grunt.initConfig({
// grunt-express will serve the files from the folders listed in `bases`
{
"name": "grunt-livereload-renewed",
"version": "1.0.0",
"devDependencies": {
"grunt": "~0.4.1",
"matchdep": "~0.1.2",
"grunt-express": "~1.0.0-beta2",
"grunt-contrib-watch": "~0.5.1",
"grunt-open": "~0.2.1"
}