Skip to content

Instantly share code, notes, and snippets.

View MichaelDimmitt's full-sized avatar
:shipit:
𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫

MichaelDimmitt

:shipit:
𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫𒐫
View GitHub Profile
@MichaelDimmitt
MichaelDimmitt / ImageHelper.js
Last active November 16, 2019 16:44
html canvas: orient an image to position 1.
/* Usage
import { readFile, profileOrient, createImage } from '../../helpers/ImageHelper';
readFile(file)
.then(createImage)
.then(profileOrient.bind(undefined, file.type))
.then(blob => {})
*/
// nodemodule used to learn the orientation of an image.
import exif from 'exif-js';
@MichaelDimmitt
MichaelDimmitt / aTopLevelList.js
Last active August 21, 2020 17:00
Given a nested html lists return the top level.
// used to simplify: http://www.databaseanswers.org/data_models/index.htm
// and http://www.databaseanswers.org/data_models/index_all_models.htm
var parentList = document.getElementsByTagName('li');
for(var x = 0; x < parentList.length; x++) {
var childList = parentList[x].getElementsByTagName('ol')
for(var y = 0; y < childList.length; y++) {
childList[y].remove()
}
}
@MichaelDimmitt
MichaelDimmitt / graph_producer.js
Created August 31, 2020 00:48
Lets me make graphs sequentially or with an air or randomness for highcharts https://www.highcharts.com/docs/chart-and-series-types/network-graph
const alphabet = [
'a', 'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z'
]
const deepCopyAlphabet = () => JSON.parse(JSON.stringify(alphabet));
const getRandomInt = (arr) => Math.floor((Math.random() * arr.length))
let mainGraph = []
const connectNodesByNumber = ({letter, num, arr, mainGraph, isRandom}) => {
@MichaelDimmitt
MichaelDimmitt / javascript_when to use_preventDefault stopPropagation.md
Last active May 3, 2024 14:43
Today I learned, when to use: event.preventDefault(); event.stopPropagation();

Today I learned, when to use:

  event.preventDefault();
  event.stopPropagation();

Ever need to have a click event on a child element trigger but not on the parent element?

Anyone use event.preventDefault on a regular basis?

Found a really good explanation with working examples on stack overflow πŸŽ‰

@MichaelDimmitt
MichaelDimmitt / javascript_checking the inferred type.md
Last active December 20, 2020 19:22
Checking types in javascript.md

https://stackoverflow.com/a/332445/5283424

function a() { this.foo = 1;}
function b() { this.bar = 2; }
b.prototype = new a(); // b inherits from a
var f = new b();
function type(obj){
 return Object.prototype.toString.call(obj).match(/\s\w+/)[0].trim()
#!/usr/bin/env bash
#{{{ MARK:Header
#**************************************************************
##### Author: JACOBMENKE
##### Date: Mon Jul 10 12:10:25 EDT 2017
##### Purpose: bash script to contain open, copy and paste commands
##### Notes:
#}}}***********************************************************
if [[ -z "$ZPWR_OS_TYPE" ]]; then
@MichaelDimmitt
MichaelDimmitt / poor-mans-render-one-time.md
Created March 6, 2021 20:20
quick poor mans, way for react to tell how many of these components exist by rendering one time.

Everyone seems to know this, but here is a good refresher in case I ever forget.

  useEffect(() => { console.log('I am a component, 1 render') }, [true]);

Pointed empty array works you dont need true, My paranoid self thought that I read in the documentation that empty array would track all. This was not the case.

  useEffect(() => { console.log('I am a component, 1 render') }, []);
@MichaelDimmitt
MichaelDimmitt / links-beginners-found-helpful.md
Last active April 26, 2021 00:07
try it out add a comment if you have a question. cheers!