Skip to content

Instantly share code, notes, and snippets.

View DashBarkHuss's full-sized avatar
💙
Working on WishTender

Dashiell Bark-Huss DashBarkHuss

💙
Working on WishTender
View GitHub Profile
@DashBarkHuss
DashBarkHuss / App.js
Last active August 11, 2022 21:16
bullmq worker and react example converted from heroku example
// run your react frontend on port 3000
import React, { useState, useEffect, useRef } from "react";
function useInterval(callback, delay) {
const savedCallback = useRef();
// Remember the latest callback.
useEffect(() => {
savedCallback.current = callback;
@DashBarkHuss
DashBarkHuss / App.js
Last active August 11, 2022 18:28
background worker node.js with react frontend using polling
// run your react frontend on port 3000
import React, { useState, useEffect, useRef } from "react";
function useInterval(callback, delay) {
const savedCallback = useRef();
// Remember the latest callback.
useEffect(() => {
savedCallback.current = callback;
@DashBarkHuss
DashBarkHuss / App.js
Created December 17, 2021 21:32
reconnecting websocket message sent from route node.js react
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import LiveStorePurchases from "./LiveStorePurchases";
function App(props) {
return (
<div className="App">
<Router>
<Switch>
@DashBarkHuss
DashBarkHuss / App.js
Created December 16, 2021 17:54
Sample WebSocket node.js, react, express.js with broadcast and send happening in a route
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import LiveStorePurchases from "./LiveStorePurchases";
function App(props) {
return (
<div className="App">
<Router>
<Switch>
@DashBarkHuss
DashBarkHuss / html2canvas.js
Last active August 31, 2021 02:33
html2canvas
/*!
* html2canvas 1.3.2 <https://html2canvas.hertzen.com>
* Copyright (c) 2021 Niklas von Hertzen <https://hertzen.com>
* edited by Dashiell Bark-Huss github.com/DashBarkHuss
* Released under MIT License
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.html2canvas = factory());
@DashBarkHuss
DashBarkHuss / background.js
Created July 20, 2021 22:33
Sample Chrome Extension Message Passing Background to Content Script Manifest V3
try {
// This is the background script for the extension
// A listener for when the user clicks on the extension button
// chrome.action.onClicked.addListener(buttonClicked);
chrome.action.onClicked.addListener(buttonClicked);
// Handle that click
function buttonClicked(tab) {
@DashBarkHuss
DashBarkHuss / attackersSite.html
Last active June 16, 2021 19:31
Sample Node CSRF attack (simple, no cookies, no sessions)
<!-- To test this CSRF attack, this page should be launched on a different local server (not localhost:4000) than the backend -->
<!DOCTYPE html>
<html lang="en">
<body>
<form action=http://localhost:4000/item method=post >
<input name ="itemName" value="Shirt" type="text">
<input type=submit>
</form>
@DashBarkHuss
DashBarkHuss / APIContract.md
Last active March 21, 2021 15:37
API contract example

Order Object

  • Order object
{
_id: string,
  gifts: [
    {
 // gift object
const countryData = require("country-data");
const fx = require("money");
/**
* Currency helper
* @constructor
* @param {Object} exchangeRateInterface an api interface for an exchange rate api site
*/
function CurrencyHelper(exchangeRateInterface) {
this.exchangeRateInterface = exchangeRateInterface;
@DashBarkHuss
DashBarkHuss / package.json
Last active August 19, 2020 15:58 — forked from vesse/login.jade
Node.js, Passport.js, connect-flash message when login. Doesn't work with axios
{
"dependencies": {
"axios": "^0.19.2",
"body-parser": "^1.9.0",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.5",
"express": "^4.17.1",
"express-session": "^1.17.1",
"passport": "^0.4.1",
"passport-local": "^1.0.0"