Skip to content

Instantly share code, notes, and snippets.

@learncodeacademy
learncodeacademy / iris-tensorflow-js.js
Last active June 25, 2024 21:40
Solving Iris with Tensorflow.js and Iris JSON dataset
import * as tf from "@tensorflow/tfjs"
import "@tensorflow/tfjs-node"
import iris from "./iris.json"
import irisTesting from "./iris-testing.json"
// convert/setup our data
const trainingData = tf.tensor2d(iris.map(item => [
item.sepal_length, item.sepal_width, item.petal_length, item.petal_width,
]))
const outputData = tf.tensor2d(iris.map(item => [
@learncodeacademy
learncodeacademy / gist:8acf7e3a2c4c33100f04c6715c662a01
Created June 11, 2018 14:23
Training a Neural Network - Enhanced Console Output From Brain.js
Start Training!...Here's the data, we'll do 2 iterations:
[ { input: [ 0, 1 ], output: [ 1, 0 ] },
{ input: [ 1, 1 ], output: [ 1, 1 ] } ]
======== TRAINING ITERATION 1 =========
--------- Run input set 0: 0,1 ----------
-> Layer 2 has 3 nodes
START NODE: 0
-> bias for node 0: 0.13861538469791412
-> weights for node 0:
-> input value: 0, weight: -0.03485306352376938
@learncodeacademy
learncodeacademy / .drone.yml
Created June 28, 2017 16:28
Rancher Drone CD Pipeline Setup
pipeline:
slack:
image: plugins/slack
webhook: <your slack webhook url>
channel: deployments
username: drone
template: "<{{build.link}}|Deployment #{{build.number}} started> on <http://github.com/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> by {{build.author}}"
when:
branch: [ master, staging ]
build:
@learncodeacademy
learncodeacademy / pickRandomComment.js
Created May 24, 2017 19:13
YouTube Random Comment Selector
const axios = require("axios");
const key = "AIzaSyB9e-dHIvdxxrbmorjYHWipwBKq7LJBhNk"
function getComments(pageToken, allItems = {}) {
const params = {
key,
videoId: "a4haLJdDRmc",
part: "snippet",
maxResults: 100,
pageToken,
@learncodeacademy
learncodeacademy / keymap.c
Created October 10, 2016 14:39
Ergodox EZ Keymap - layer 2: mouse - layer3: arrows
#include "ergodox_ez.h"
#include "debug.h"
#include "action_layer.h"
#define BASE 0 // default layer
#define MDIA 1 // mouse/media keys
#define ARROW 2 // arrow keys
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
@learncodeacademy
learncodeacademy / webpack.config.js
Created January 8, 2016 03:55
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@learncodeacademy
learncodeacademy / README.md
Last active June 17, 2021 15:43
Running a High Availability Service on CoreOS using Docker, Fleet, Flannel, Etcd, Confd & Nginx

Running a High Availability Service on CoreOS using Docker, Fleet, Flannel, Etcd, Confd & Nginx

Tools used:

  • coreos: server machine clustering via a shared cloud-config.yml
  • etcd: key value store for service registration and discovery
  • fleet: scheduling/failover of docker containers across coreos cluster
  • flannel: Gives each docker container a unique ip that allows you to access the internal port (i.e. port 80 not 32679)
  • confd: watch etcd for nodes arriving/leaving - template nginx configuration files / reload nginx on change
@learncodeacademy
learncodeacademy / pubsub.js
Created July 29, 2015 02:54
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@learncodeacademy
learncodeacademy / Dockerfile
Created March 27, 2015 02:20
Node Dockerfile
FROM node:0.12.0
# use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
ADD package.json /tmp/package.json
RUN cd /tmp && mkdir data && npm install --production --unsafe-perm
RUN mkdir -p /app && cp -a /tmp/node_modules /app/ && cp -a /tmp/data /app/
# From here we load our application's code in, therefore the previous docker
# "layer" thats been cached will be used if possible
@learncodeacademy
learncodeacademy / flightplan-html.md
Last active October 22, 2024 13:23
Deploy HTML site with Flightplan

###Prerequesites

Install flightplan globally

npm install -g flightplan

Install flightplan in your project folder