Skip to content

Instantly share code, notes, and snippets.

View newbenhd's full-sized avatar
😊

Ben M newbenhd

😊
  • Loading...
  • Chicago, Illinois
View GitHub Profile
@newbenhd
newbenhd / iris.csv
Created October 4, 2023 06:15 — forked from r-wheeler/iris.csv
iris
sepal length sepal width petal length petal width species
5.1 3.5 1.4 0.2 Iris-setosa
4.9 3.0 1.4 0.2 Iris-setosa
4.7 3.2 1.3 0.2 Iris-setosa
4.6 3.1 1.5 0.2 Iris-setosa
5.0 3.6 1.4 0.2 Iris-setosa
5.4 3.9 1.7 0.4 Iris-setosa
4.6 3.4 1.4 0.3 Iris-setosa
5.0 3.4 1.5 0.2 Iris-setosa
4.4 2.9 1.4 0.2 Iris-setosa
@newbenhd
newbenhd / file-concatenation.js
Last active September 25, 2023 07:24
concat src files to destination file in order
/**
* Write the implementation of concatFiles(), a callback-style function that takes two or more paths
* to text files in the filesystem and a destination file:
* ```js
* function concatFiles (srcFile1, srcFile2, srcFile3, ..., dest, cb) {
* // ...
* }
* ```
* This function must copy the contents of every source file into the destination file, respecting
* the order of the files, as provided by the arguments list. For instance, given two files, if the
@newbenhd
newbenhd / ticker.js
Last active September 25, 2023 06:30
ticker event emitter subscribe propagating error function
/**
* Write a function that accepts a number an a callback as the arguments. The function will return an EventEmitter
* that emits an event called 'tick' every 50 milliseconds until the number of milliseconds is passed from the invocation
* of the function. The function will also call the callback when the number of milliseconds has passed, providing, as
* the result, the total count of tick events emitted. Hint: you can use setTimeout() to schedule another setTimeout()
* recursively.
*/
module.exports = function ticker(number, cb) {
const ee = new (require('events').EventEmitter)()
let count = 0
@newbenhd
newbenhd / propagate-error-with.js
Last active September 25, 2023 06:04
Ticker event emitter decorator with error propagation
/**
* Modify the function created in exercise 3.3 so that it produces an error if the timestamp at the moment of a
* tick (including the initial one that we added as part of exercise 3.3) is divisible by 5. Propagate the error
* using both the callback and the event emitter. Hint: use Date.now() to get the timestamp and the remainder (%)
* operator to check whether the timestamp is divisible by 5.
*/
const ticker = require('./ticker.js')
function callback(error, ...args) {
if (error) return console.error(error.message)
/**
* Modify the function created in exercise 3.3 so that it produces an error if the timestamp at the moment of a
* tick (including the initial one that we added as part of exercise 3.3) is divisible by 5. Propagate the error
* using both the callback and the event emitter. Hint: use Date.now() to get the timestamp and the remainder (%)
* operator to check whether the timestamp is divisible by 5.
*/
const ticker = require('./ticker.js')
function callback(error, ...args) {
if (error) return console.error(error.message)
@newbenhd
newbenhd / ticker.js
Last active September 25, 2023 04:25
ticker event emitter factory
/**
* Write a function that accepts a number an a callback as the arguments. The function will return an EventEmitter
* that emits an event called 'tick' every 50 milliseconds until the number of milliseconds is passed from the invocation
* of the function. The function will also call the callback when the number of milliseconds has passed, providing, as
* the result, the total count of tick events emitted. Hint: you can use setTimeout() to schedule another setTimeout()
* recursively.
*/
module.exports = function ticker(number, cb) {
const ee = new (require('events').EventEmitter)()
let count = 0
const VideoComponent = props => {
useEffect(() => {
const video = document.getElementById('srcVideo');
video.crossOrigin = "anonymous";
const bind = async () => {
const net = await posenet.load({
architecture: input.architecture,
outputStride: input.outputStride,
inputResolution: input.inputResolution,
multiplier: input.multiplier,
@newbenhd
newbenhd / network_scanner.py
Created August 7, 2019 08:13
network_scanner2.py
#!/usr/bin/env python
from optparse import OptionParser
from scapy.all import srp, ARP, Ether
def get_args():
parser = OptionParser()
parser.add_option('-t', '--target', dest='ip', help='IP address range')
options = parser.parse_args()[0]
if not options.ip:
@newbenhd
newbenhd / mongodb.js
Last active July 12, 2019 18:15
mongodb client wrapper
// CRUD operator
const mongodb = require("mongodb");
class dbClient {
constructor() {
this.MongoClient = mongodb.MongoClient;
this.connectionURL = "";
this.client = undefined;
this.error = undefined;
@newbenhd
newbenhd / mapbox.test.js
Created July 11, 2019 19:47
mapbox service test cases
const mapbox = require("./mapbox");
const { assert } = require("chai");
describe("--> mapbox module test <--", () => {
describe("forwardGeocoding() test", () => {
it("should have response with default", () => {
mapbox.forwardGeocoding(undefined, undefined, {}, (error, response) => {
// if (error) throw error;
assert.isObject(response, "is not an object?");
});