Skip to content

Instantly share code, notes, and snippets.

View Ethan-Arrowood's full-sized avatar
🐶

Ethan Arrowood Ethan-Arrowood

🐶
View GitHub Profile
@Ethan-Arrowood
Ethan-Arrowood / instructions.py
Created April 25, 2017 16:57
FCC-Python-Variable-Challenge created by Ethan.Arrowood - https://repl.it/HTLB/4
'''
Title: Variables
Description/Explanation/Lesson:
Variables in Python are defined using the '=' operator. For example: myAge = 18
Variables can contain Strings, Numbers, Lists, Class Instances, and many more things!
Variables can also contain operations & methods i.e. eightSquared = 8 ** 2
Or, binaryFromDecimal = bin(243)
@Ethan-Arrowood
Ethan-Arrowood / instructions.py
Created April 25, 2017 16:57
FCC-Python-Variable-Challenge created by Ethan.Arrowood - https://repl.it/HTLB/5
'''
Title: Variables
Description/Explanation/Lesson:
Variables in Python are defined using the '=' operator. For example: myAge = 18
Variables can contain Strings, Numbers, Lists, Class Instances, and many more things!
Variables can also contain operations & methods i.e. eightSquared = 8 ** 2
Or, binaryFromDecimal = bin(243)
@Ethan-Arrowood
Ethan-Arrowood / ObjectHistoryTrackAPI.js
Created November 22, 2017 05:20
Adds a very simple history tracking feature to javascript objects.
var moment = require('moment');
function createHistoryObj(id, obj) {
return {
id,
...obj,
removed: false,
history: {
[moment().valueOf()]: { ...obj, change: "created" }
},
@Ethan-Arrowood
Ethan-Arrowood / genereate_hdb_env.js
Created December 28, 2017 04:27
Automatically generate .env variables for HarperDB connection.
const fs = require("fs");
fs.readFile("./install_log.log", (err, data) => {
if (err) throw err;
const s = data.toString();
// prettier-ignore
const regex_ports = /HTTPS?_PORT\\\"\:\\\"(\d+)/g;
let port_match = regex_ports.exec(s);
@Ethan-Arrowood
Ethan-Arrowood / server.js
Created March 19, 2018 10:12
This is an example Fastify plugin and server from my medium article:
const fastify = require('fastify')()
const superPlugin = require('./superPlugin.js')
fastify.register(superPlugin, {
secretCode: 'JavaScript is awesome!'
})
fastify.get('/', (request, reply) => {
reply.send({ hello: 'world' })
})
@Ethan-Arrowood
Ethan-Arrowood / DataAnalytics.md
Last active May 25, 2018 07:51
DataAnalytics.md

Data Analytics Assignment

Nana Tsujikawa & Ethan Arrowood

Nana's Source Code repository

Ethan's Source Code repository

Table Of Contents

@Ethan-Arrowood
Ethan-Arrowood / hdb_studio.js
Created June 6, 2018 04:41
HDB_Studio with harperDBCallout replaced by HarperDBConnect
"use strict";
const express = require('express'),
app = express(),
bodyParser = require('body-parser'),
path = require('path'),
favicon = require('express-favicon'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
session = require('express-session'),
@Ethan-Arrowood
Ethan-Arrowood / fcopy.go
Created September 29, 2018 19:39
First implementation of a file copy program written in Go
package main
import (
"io/ioutil"
"log"
"os"
)
func fcopy(src, dst string) {
content, err := ioutil.ReadFile(src)
@Ethan-Arrowood
Ethan-Arrowood / mtsort.js
Created November 25, 2018 06:03
Multithreading qsort and merge sort implementation.
const { performance } = require('perf_hooks')
const {
Worker, isMainThread, parentPort, workerData, theadId, MessageChannel
} = require('worker_threads')
/*
* Multithreading qsort and merge sort implementation.
* Written by Ethan Arrowood (https://github.com/Ethan-Arrowood) in
* Node.js v11.2.0
*
@Ethan-Arrowood
Ethan-Arrowood / qsort.js
Created November 27, 2018 06:33
This code caused a segmentation fault in a one-off occurance. Fixed by fixing the TypeError that is thrown first by line 33 of script.js
const {
Worker, isMainThread, parentPort, workerData, threadId, MessageChannel
} = require('worker_threads')
//getting array from workerData
const array = workerData
// sort array
let sortedArray = array.sort((a, b) => a - b)
let thr = {
threadId,
sortedArray