Skip to content

Instantly share code, notes, and snippets.

@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
@visualjeff
visualjeff / gist:c7ad3f51845c79476fc7b6da5d4dc722
Created July 30, 2016 22:25
Node.js best practices (to build over time)
Node best practices:
#!/usr/bin/env node
'use strict';
// Provide a title to the process in `ps`
process.title = 'description of what is actually running';
Use "nopt" package for option parsing from command line input.
//Check to see if promise is already running
if (this.isRunning) { return; }
//Promise is success, but we need to check on the parent before we make
changes to the parent.
if (this.isDestroyed) { return; }