Skip to content

Instantly share code, notes, and snippets.

View sethdavis512's full-sized avatar
🤖

Seth Davis sethdavis512

🤖
View GitHub Profile
@sethdavis512
sethdavis512 / post.md
Last active May 3, 2016 20:19
#post Find Max/Min Value in Array
@sethdavis512
sethdavis512 / remove-duplicate-paths.sh
Created May 7, 2017 18:42
Remove duplicate paths from $PATH
# Taken from https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command
if [ -n "$PATH" ]; then
old_PATH=$PATH:; PATH=
while [ -n "$old_PATH" ]; do
x=${old_PATH%%:*} # the first remaining entry
case $PATH: in
*:"$x":*) ;; # already there
*) PATH=$PATH:$x;; # not there yet
esac
for (var i = 0, headings = $$('h1,h2,h3,h4,h5,h6');
i < headings.length; i++) {
console.log(headings[i].textContent.trim() + " " +
headings[i].tagName,
headings[i]);
}
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Vue</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.5.0/css/bulma.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat">
<script src="https://unpkg.com/vue"></script>
<style>
import os
import math
import csv
def humanizeFileSize(filesize):
filesize = abs(filesize)
if (filesize==0):
return "0 Bytes"
p = int(math.floor(math.log(filesize, 2)/10))
return "%0.2f %s" % (filesize/math.pow(1024,p), ['Bytes','KB','MB','GB','TB','PB','EB','ZB','YB'][p])
@sethdavis512
sethdavis512 / objectDiff.js
Created September 20, 2017 13:51
Lodash - Find difference between objects
_.reduce(obj1, (result, value, key) => {
const variantValue = obj2[key];
return _.isEqual(value, variantValue) ? result : result.concat(value);
}, []);
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello Bulma!</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.0/css/bulma.min.css">
</head>
<body>
// HTML5 Pattern
// http://html5pattern.com/
const alphaNumeric = /[a-zA-Z0-9]+/;
const userNameWith20Chars = /^[a-zA-Z][a-zA-Z0-9-_\.]{1,20}$/;
const twitterHandle = /^[A-Za-z0-9_]{1,15}$/;
const password = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$/; // Uppercase, lowercase, and number
const password2 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$/; // Password (UpperCase, LowerCase, Number/SpecialChar and min 8 Chars)
var ageInput = document.getElementById("age")
ageInput.addEventListener("keydown", function(e) {
// prevent: "e", "=", ",", "-", "."
if ([69, 187, 188, 189, 190].includes(e.keyCode)) {
e.preventDefault();
}
})