Skip to content

Instantly share code, notes, and snippets.

@visualjeff
visualjeff / passport-mock.js
Created March 20, 2017 17:02 — forked from mweibel/passport-mock.js
Mock passport.js with an own strategy
/**
* Author: Michael Weibel <michael.weibel@gmail.com>
* License: MIT
*/
var passport = require('passport')
, StrategyMock = require('./strategy-mock');
module.exports = function(app, options) {
// create your verify function on your own -- should do similar things as
@visualjeff
visualjeff / gist:f6de98d08cce7f7eb14972d1d636c16e
Created October 14, 2016 17:05
Automated testing example for Node.js Hapi apps using Lab
Node.js testing:
1. Use the package lab (also code and sinon).
npm install lab --save-dev
npm install code --save-dev // assertion library
npm install sinon --save-dev
2. Add the following test script to your package.json
@visualjeff
visualjeff / gist:b52309b99e31fb2a3351113a3c300dcd
Created October 7, 2016 00:09
I'm tired of for loops inside for loops for array hashing...
'use strict';
var userRolesInNewApp = [
{displayName: 'tester', value: 't'},
{displayName: 'hacker', value: 'h'},
{displayName: 'manager', value: 'm'}
];
var object = {
appRoles: [
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
const {$}= Ember; //JQuery reference for events
import layout from '../templates/components/checkbox-component';
const {
Component,
get
} = Ember;
const MyComponent = Ember.Component.extend({
import Ember from 'ember';
const {$}= Ember; //JQuery reference for events
import layout from '../templates/components/checkbox-component';
const {
Component,
get
} = Ember;
const MyComponent = Ember.Component.extend({
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'EAM V.2.0.0'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
yenConverter: Ember.inject.service(),
actions: {
switchCurrency(){
this.get('yenConverter').switchCurrency();
}
}
@visualjeff
visualjeff / gist:3382931063d0f7659be5e6663569b866
Created August 3, 2016 18:21
VS Code TypeScript Code completion how to and how to debug node.js in VS Code
To add code completion for node.js
==================================
sudo npm install typings --global
typings search --name node
typings install env~node --global --save
Then I added the following to the top of my index.js file.
/// <reference path="typings/index.d.ts"/>
Regex tips for JOI:
^ asserts that the regular expression must match at the beginning of the subject
[] is a character class - any character that matches inside this expression is allowed
A-Z allows a range of uppercase characters
a-z allows a range of lowercase characters
. matches a period rather than a range of characters
\s matches whitespace (spaces and tabs)
_ matches an underscore
- matches a dash (hyphen); we have it as the last character in the character class so it doesn't get interpreted as being part of a character range. We could also escape it (\-) instead and put it anywhere in the character class, but that's less clear