Skip to content

Instantly share code, notes, and snippets.

View microbial's full-sized avatar

Dwayne Ford microbial

View GitHub Profile
import Ember from 'ember';
import layout from './template';
export default Ember.Component.extend({
layout
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@microbial
microbial / shop.js
Created February 16, 2016 08:00
Shopping List
var arr = [];
var obj = {};
var fun = function () {};
var shoppingList = [
'cheese',
'milk',
'bacon'
];
@microbial
microbial / ezzyfivey.js
Last active May 17, 2024 02:09
es6-style-js
//NON ES6 way
function actionWord () {
//Put your action here
}
//for example
//CREATE the function
function drive () {
console.log('I am driving now')
}
@microbial
microbial / user_record_on_register.js
Created January 11, 2016 21:06
Make user node in firebase
//Assuming you're already in an angular controller...
$scope.user = {};
//$scope.user will get filled with "email" and "password" keys
var enteredUsername = angular.copy($scope.username);
$scope.register = function() {
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
var user = angular.copy($scope.user);
ref.createUser({
@microbial
microbial / rename.js
Last active May 17, 2024 01:54
lodash helpers - rename (renames object keys)
/*
* var person = { firstName: 'bill', lastName: 'johnson' }
*
* person = _.rename(person, 'firstName', 'first')
* person = _.rename(person, 'lastName', 'last')
*
* console.log(person) // { first: 'bill', last: 'johnson' }
*/
_.rename = function(obj, key, newKey) {
@microbial
microbial / app_access_global.js
Created December 4, 2015 04:27
Middleware with access to app instance
var express = require('express');
var app = express();
//Normal way - won't work if function is extracted to a module
app.use(function(req, res, next) {
'use strict';
app.locals.greeting = 'hello';
next();
@microbial
microbial / express_init.js
Last active December 4, 2015 04:11
Express Init
//In the express server file
var express = require('express');
var app = express();
app.use((function(appInstance) {
'use strict';
return function(req, res, next) {
appInstance.locals.mongo = require('mongodb');
appInstance.locals.uuid = require('uuid');
@microbial
microbial / msg-ctr.js
Created July 10, 2015 18:57
msg-ctr-for-jsbin
/*jshint strict:false */
'use strict';
// Create a new angular module.
var MessageCenterModule = angular.module('MessageCenterModule', []);
// Define a service to inject.
MessageCenterModule
.provider("$messageCenterService", function() {
var _this = this;
@microbial
microbial / is_absolute_path.js
Last active May 17, 2024 02:12
isAbsolutePath
//Refactor of absolute path check from Express
module.exports = function (path){
var pathIsAbsolute = false,
firstCharIsSlash = path[0] === '/',
containsWinChars = path[1] === ':' && path[2] === '\\';
if(firstCharIsSlash || containsWinChars) {
pathIsAbsolute = true;
}