Skip to content

Instantly share code, notes, and snippets.

View newbenhd's full-sized avatar
😊

Ben M newbenhd

😊
  • Loading...
  • Chicago, Illinois
View GitHub Profile
#!/bin/bash
# Name: bscript.sh
# Author: ben
# Date: 2024-05-24
# Description: Generate an executable bash script with path
path="$HOME/bin/custom/"
echo "zsh script name:"
read name
@newbenhd
newbenhd / tmux.conf
Created May 9, 2024 23:42 — forked from Lartza/tmux.conf
vim friendly tmux configuration
#Prefix is Ctrl-a
set -g prefix C-a
bind C-a send-prefix
unbind C-b
set -sg escape-time 1
set -g base-index 1
setw -g pane-base-index 1
#Mouse works as expected
@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: