Skip to content

Instantly share code, notes, and snippets.

View johnoscott's full-sized avatar

Johno Scott johnoscott

View GitHub Profile
@johnoscott
johnoscott / 12.md
Last active March 31, 2018 01:31
[Twelve Factor]
@johnoscott
johnoscott / docker-01-containers.md
Last active March 31, 2018 08:32
[Docker HowtTo] How to create a Docker container #docker #howto

Docker Container

Command Cheat Sheet

Markdown Less Pretty
Intention command Comment
Delete an image docker image rmi react:app images can take a lot of space (e.g. 1GB for node)
1 2 3
@johnoscott
johnoscott / flatJSON.js
Last active September 20, 2016 07:26
Use lodash to inflate a flattened JSON object expressed as path, value, type triplets
export class FlatJSON {
/* @ngInject */
constructor() {
console.log("FlatJSON Service Init")
console.debug("FlatJSON running tests...")
this.test();
}
toJSON(keys) {
@johnoscott
johnoscott / controller.js
Created May 15, 2016 07:52
AngularJS Forms - Populate options in a SELECT form element (drop down)
angular.module('selectExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.colors = [
{name:'black', shade:'dark'},
{name:'white', shade:'light', notAnOption: true},
{name:'red', shade:'dark'},
{name:'blue', shade:'dark', notAnOption: true},
{name:'yellow', shade:'light', notAnOption: false}
];
$scope.myColor = $scope.colors[2]; // red
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
/**
* The MIT License (MIT)
*
* Copyright (c) 2013 Thom Seddon
* Copyright (c) 2010 Google
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@johnoscott
johnoscott / app.js
Created December 16, 2013 01:03 — forked from victorb/app.js
var myApp = angular.module('myApp', []);
myApp.directive('googleplace', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, model) {
var options = {
types: [],
componentRestrictions: {}
};
@johnoscott
johnoscott / resource.js
Created December 10, 2013 00:18
AngularJS $resource usage
// Create $resource singleton service with custom methods
// SERVICE DebugOrder
.factory('Order', ['$resource', '$http',
function ($resource, $http) {
return $resource(Prefs.getResourceBaseUrl() + '/api/orders/:_id', {}, {
'count': {method: 'PUT', params: {_id: 'count'}},
'distinct': {method: 'PUT', params: {_id: 'distinct'}},
'find': {method: 'PUT', params: {_id: 'find'}, isArray: true},
'group': {method: 'PUT', params: {_id: 'group'}, isArray: true},
/*
atrs:
size, lineWidth, bg, bc, val
*/
app.directive('clDonut', function() {
return {
restrict: 'E',
template: '<canvas></canvas>',
replace: true,
link: function(scope, el, attrs) {