Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Simon Renoult simonrenoult

🏠
Working from home
View GitHub Profile
View commit-msg.sh
COMMIT_MSG_SCRIPT_URL=https://raw.githubusercontent.com/angular/angular.js/c94329a891a1c082567c490ccf58ba8592b464ad/validate-commit-msg.js
COMMIT_MSG_SCRIPT_LOCATION=.git/hooks/commit-msg
touch $COMMIT_MSG_SCRIPT_LOCATION
curl $COMMIT_MSG_SCRIPT_URL > $COMMIT_MSG_SCRIPT_LOCATION
chmod +x .git/hooks/commit-msg
View changelog.js
#!/usr/bin/env node
const exec = require('child_process').exec
const path = require('path')
const moment = require('moment')
const prependFile = require('prepend-file')
const pkg = require('./package')
const version = pkg.version
const SEP = '##_'
View do-not-forget-to-return-promises.js
const sinon = require('sinon')
const chai = require('chai')
const expect = chai.expect
const foo = callback => {
return Promise.resolve().then(() => {
setTimeout(() => {
callback()
}, 5000)
})
View password.js
const bcrypt = require('bcrypt')
exports.encrypt = plainTextPassword => new Promise((resolve, reject) => {
bcrypt.hash(plainTextPassword, 10, (err, hash) => {
if (err) return reject(err)
return resolve(hash)
})
})
exports.compare = (plainTextPassword, hash) => new Promise((resolve, reject) => {
@simonrenoult
simonrenoult / server.js
Last active Apr 28, 2017
hapi dependency injection
View server.js
const Hapi = require('hapi')
function createServer({conf, controllers}) {
const server = new Hapi.Server()
server.connection(conf)
app.routes([
{
method: 'GET',
path: '/users',
@simonrenoult
simonrenoult / file.factories.coffee
Created Jun 15, 2017
Angularjs unit testing - factory
View file.factories.coffee
angular
.module('app.moduleA', ['app.moduleB'])
.factory('FactoryA', (FactoryB) ->
factory = {}
factory.sayHello = () -> FactoryB()
return factory
)
@simonrenoult
simonrenoult / javascript_array_methods.md
Last active Dec 23, 2017
JavaScript Array Methods
View javascript_array_methods.md
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->