validation types work like this:
[+]typename[(arg,[arg,...])]
The +
in the beginning makes it required
any arguments applied will be passed to that type's validation function
function regexMatch(regex, str){ | |
let m; | |
let g=[] | |
while ((m = regex.exec(str)) !== null) { | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
g.push({...m.groups}) | |
} |
I needed a tool to tell me the first time a certain string appeared in the git-history of a file. It was a node package, and I wanted to find out why it first got included.
node git.find.first.js <path-to-file> <search-term> [--open]
--open
will open a github-url for that commit if you have a github repository
Vue.component("async", { | |
props: { | |
url: { type: String, default: "", required: true }, | |
params: { type: Object, default: () => ({}) } | |
}, | |
data() { | |
return { | |
pending: true, | |
error: false, | |
data: null |
#!/bin/bash | |
clear | |
fileList=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(js|vue)$') | |
if [ ${#fileList} -lt 1 ]; then | |
echo -e "You have no staged .js or .vue files to test\n" | |
exit | |
fi | |
npx eslint ${fileList[*]} "$@" | |
if [ $? -ne 0 ]; then | |
echo -e "\nPlease fix the above linting issues before committing.\n" |
const SECONDS = { | |
MINUTE: 60, | |
HOUR: 3600, | |
DAY: 86400, | |
WEEK: 604800, | |
MONTH: 2630016, //30.44 day month average | |
YEAR: 31557600, //based on 365.25 days per year | |
} | |
class DForm { |
import { serve } from "https://deno.land/std@v0.30.0/http/server.ts"; | |
const s = serve({ port: 8000 }); | |
console.log("http://localhost:8000/"); | |
let c=0 | |
let st=null | |
for await (const req of s) { | |
if(st===null)st=Date.now() | |
let sd=(Date.now()-st)/1000 | |
let rps=(c+1)/sd | |
req.respond({ body: `Hello World\nRequests Handled:${c++}\nSeconds:${sd}\nRPS: ${rps}` }); |
module.exports = (bytes, siUnits = false, m, l, d, e) => (m = Math, l = m.log, d = siUnits ? 1024 : 1e3, e = l(bytes) / l(d) | 0, `${bytes / m.pow(d, e).toFixed(2)} ${e ? `${'KMGTPEZY'[--e]}${siUnits ? 'iB' : 'B'}` : 'Bytes'}`) |
const humanMs = function(ms) { | |
let s = Math.floor(ms / 1000) | |
let m = Math.floor(s / 60) | |
let h = Math.floor(m / 60) | |
let d = Math.floor(h / 24) | |
ms = ms - s * 1000 | |
s = s - m * 60 | |
m = m - h * 60 | |
h = h - d * 24 |
function Elem2Xpath(elt) { | |
function getElementIdx(elt) { | |
let count = 1; | |
for (let sib = elt.previousSibling; sib; sib = sib.previousSibling) { | |
if (sib.nodeType == 1 && sib.tagName == elt.tagName) | |
count++ | |
} | |
return count; | |
} |