Skip to content

Instantly share code, notes, and snippets.

View johnoscott's full-sized avatar

Johno Scott johnoscott

View GitHub Profile
@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
@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 / 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 / 12.md
Last active March 31, 2018 01:31
[Twelve Factor]
@johnoscott
johnoscott / markdown_cheats.md
Last active March 31, 2018 01:32
[Markdown HowTo] Cheats for Markdown syntax
@johnoscott
johnoscott / index.html
Last active March 31, 2018 01:47
[Matrix Rotation] Javascript implementation of 90degree clockwise rotation of nxn matrix
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<!--<link rel="stylesheet" href="styles.css">-->
</head>
<body>
<h1>Hello world!</h1>
<script src="rotate-matrix.js"></script>

Dockerize a React App in 2018 with CreateReactApp

TLDR

Markdown Less Pretty
Still renders nicely
1 2 3

References

@johnoscott
johnoscott / docker_cloud_stack_on_digital_ocean_for_$5_per_mo.md
Last active April 1, 2018 03:21
[Docker Cloud Stack on Digital Ocean $5 per mo]

Dockerize a React App in 2018 with CreateReactApp

TLDR

Markdown Less Pretty
Still renders nicely
1 2 3

References

@johnoscott
johnoscott / generateUUID.js
Created April 6, 2018 02:14
[Generat UUID] Create a UUID with JavaScript
function generateUUID() { // Public Domain/MIT
var d = new Date().getTime();
if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
d += performance.now(); //use high-precision timer if available
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
@johnoscott
johnoscott / rotate_pi.sh
Created April 16, 2018 02:18
[Rotate Raspberry Pi Display from Terminal] #raspberry-pi
INSTALLATION
We've created a one-liner that automates the installation procedure. To get started with this display, simply execute curl -L http://coreelec.io/2q | bash
If you want to see what this script does before running, save it to a file with curl -L http://coreelec.io/2q >> lcd35-installer
You can roll back to using the regular HDMI output at any time by executing the included LCD_hdmi script.
https://core-electronics.com.au/3-5inch-display-module-touch-lcd-with-stylus-for-raspberry-pi-3.html
To rotate your display, simply enter display_rotate or lcd_rotate at the bottom of your config file: