Skip to content

Instantly share code, notes, and snippets.

😊

Benjamin newbenhd

😊
Block or report user

Report or block newbenhd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tensorflow
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,
View network_scanner.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 Jul 12, 2019
mongodb client wrapper
View mongodb.js
// 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 Jul 11, 2019
mapbox service test cases
View mapbox.test.js
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?");
});
View async
return new Promise(async (resolve, reject) => {
try {
const depnString = JSON.stringify(this.depn);
await fs.writeFile(path.join(this.dest, this.fileName), depnString);
} catch (err) {
reject(err);
}
});
View index.js
"use strict"
const bodyParser = require('body-parser')
const serveStatic = require('serve-static')
function wrapper = () => {
const locals = {}
return (path, callback) => {
on,
}
}
View auth.js
import config from '../config'
import { User } from '../resources/user/user.model'
import jwt from 'jsonwebtoken'
export const newToken = user => {
return jwt.sign({ id: user.id }, config.secrets.jwt, {
expiresIn: config.secrets.jwtExp
})
}
View test cases
if (typeof module !== 'undefined') {
var JSONParser = require('../src/main.js');
var expect = require('chai').expect;
}
describe('JSON Parser', function() {
describe('Numbers', function() {
it('should work on single-digit', function() {
expect(JSONParser(JSON.stringify(1))).to.eql(1);
View parser
/**
* returns a javascript object from a JSON formatted string
* Example json to javascript object:
* "5" -> 5
* "'hello'" -> 'hello'
* "[]" -> []
* "{}" -> {}
* "["hello"]" -> ['hello']
*
* For more examples, use the JSON.stringify method in the console
@newbenhd
newbenhd / prototype
Created Jun 18, 2019
Prototype Inheritance
View prototype
function createArray() {
this.array = [];
}
createArray.prototype.push = val => {
this.array.push(val);
};
You can’t perform that action at this time.