Skip to content

Instantly share code, notes, and snippets.

View TravisMullen's full-sized avatar

Travis Mullen TravisMullen

View GitHub Profile
@TravisMullen
TravisMullen / ProgressGauge.vue
Last active September 29, 2022 23:29
ProgressGauge
<template>
<div class="progress-gauge">
<!-- <strong>{{ progress | floor10 }}</strong> -->
<svg ref="container" class="progress" :width="size" :height="size" :viewBox="`0 0 ${size} ${size}`"
:style="{ strokeDashoffset: dashoffset, strokeDasharray: circumference }">
<circle ref="meter" class="progress-meter" :cx="innerSize" :cy="innerSize" :r="radius" stroke-width="12" />
<circle ref="value" class="progress-value" :cx="innerSize" :cy="innerSize" :r="radius" stroke-width="12" />
</svg>
<!-- <input id="control" type="range" value="60" /> -->
</div>
@TravisMullen
TravisMullen / truncate-middle.js
Created September 29, 2022 23:10
Truncate Text
// truncate text
function trimMiddle (text, maxLength, div) {
let t
let d = div || ' '
let l = text.length
let a
let b
if (l > maxLength) {
a = Math.floor((maxLength / 2) - 1)
@TravisMullen
TravisMullen / classDiagram.js
Created September 16, 2021 00:06
Helper for Mermaid Diagrams
// classDiagram
// [classA][Arrow][ClassB]:LabelText
// classA <|-- classB
// classC *-- classD
// classE o-- classF
// classG <-- classH
// classI -- classJ
@TravisMullen
TravisMullen / csv-to-json.js
Last active September 7, 2021 21:50
Covert CSV or TSV file to JSON file.
/**
* Standardize Task Data.
* Service to be run in nodejs as an npm process (`npm run pre:serve`)
* Drop into directory with CSV/TSV files to be parsed, and run as
* @example `node path/to/csv-to-json.js`
*/
const { once } = require('events')
const { createReadStream } = require('fs')
const { createInterface } = require('readline')
const { writeFile, readdir } = require('fs/promises')
@TravisMullen
TravisMullen / debug-element-structure.css
Created December 25, 2020 23:43
CSS Visual Cues for potential HTML issues.
/* no LANG attributes in HTML document */
html:([lang])::before {
content: "No lang declared in HTML element.";
display: block;
color: white;
background-color: red;
}
@TravisMullen
TravisMullen / video-integrity.js
Last active November 7, 2020 04:46
Calculate positions offset value for each frame provided.
const MODULE_NAME = 'Calculate positions offset value for each frame provided.'
/**
* Convert time into seconds which is the smallest increment of time encoded into the video.
* @param {string} time Time in the format of HH:MM:SS using colons as the delimiter.
* @return {number} Time converted to seconds.
*/
const seconds = time => {
const [hours,minutes,seconds] = time.split(':')
return parseInt((((parseInt(hours) * 60) + parseInt(minutes)) * 60) + parseInt(seconds))
@TravisMullen
TravisMullen / integrity.js
Last active October 20, 2019 18:55
Generate hash from file.
import { createHash } from 'crypto'
import { createReadStream } from 'fs'
/**
* Generate hash from file.
* @param {string} filename - path to file.
* @param {string} algorithm
* @returns {Promise}
*/
export const shasum = (filename, algorithm = 'sha256') => (
@TravisMullen
TravisMullen / i_want_it_now.sh
Last active October 19, 2019 22:48
Emergency nodejs: when you need that bin yesterday.
#!/bin/bash
# /** instant nodejs **/
# get it
wget https://nodejs.org/dist/v12.12.0/node-v12.12.0-linux-x64.tar.xz
tar xf node-v12.*.*-linux-*.tar.xz
# validate it
echo 'console.log(`versions: ${console.log(process.versions)} - nodejs.`)' > versions.js
@TravisMullen
TravisMullen / update-release.sh
Last active October 10, 2019 22:06
Generate static files for a vue cli repo.
bin/bash -e
DOMAIN=example.org
BUILD_DIR=/tmp/www-build
PRODUCTION_DIR=/var/www/html/$DOMAIN
OWNER=TravisMullen
REPO=TravisMullen-Vue
APP_TITLE="'Travis Mullen Brochure'"
# start ====
@TravisMullen
TravisMullen / update-cli-binaries.sh
Last active November 16, 2019 22:03
Update binaries (WIP)
#!/bin/bash -e
# @example
# ./update-cli-binaries.sh zcoin zcoinofficial/zcoin linux64
#
BINARY_INSTALL_DIR='/usr/local/bin'
# get CRYPTO_NAME
if [ "$#" -lt 1 ]