Skip to content

Instantly share code, notes, and snippets.

@mohuk
mohuk / prepare.sh
Created December 26, 2017 07:07
Preparatino Script for Docker Labs
#! /bin/ash
apk --update add git nano
@mohuk
mohuk / controllers.js
Last active August 29, 2015 14:25
Passing read-only values as function parameters and not relying on the scope/this/vm available on the closure
/**
It is always a better idea to pass the readable items as function parameters when defining functions
on the scope/this/vm. Although the change is very subtle but as the code base grows bigger, this helps
identifying whats being read and written when a function is handling multiple things. Also, when calling
the function from the view, putting in the parameters there an then keeps the code readable and identifiable.
e.g.
<ul>
<!-- Clearly identifiable that the user being passed in is being selected -->
<li ng-repeat="user in users" ng-click="vm.select(user)"></li>
</ul>
@mohuk
mohuk / p.js
Created November 28, 2014 07:28
test
function (url) {
return api.attempt(url).then(insert)
.catch(function (error) {
return Q.reject(error);
});
@mohuk
mohuk / Ctrl.js
Last active August 29, 2015 14:01
'use strict';
angular.module('SampleApp',[])
.controller('SampleAdminsCtrl', function ($scope, Admins, AdminsServ) {
//Admins is a route resolve
//$scope.Admins will hold whatever Admins object brings in itself
$scope.isAdminView = true;
$scope.Admins = Admins;
//onViewPortals is a ngClick handler which calls in a service function upon a condition