Skip to content

Instantly share code, notes, and snippets.

View darmentrout's full-sized avatar
💭
I've got fun Gists, too.

Damion Armentrout darmentrout

💭
I've got fun Gists, too.
View GitHub Profile
@darmentrout
darmentrout / generatePassword.php
Last active June 27, 2018 14:05 — forked from zyphlar/generatePassword.php
Generating secure passwords in PHP
<?php
// usage: $newpassword = generatePassword(12); // for a 12-char password, upper/lower/numbers.
// functions that use rand() or mt_rand() are not secure according to the PHP manual.
function getRandomBytes( $nbBytes = 32 ){
$bytes = openssl_random_pseudo_bytes( $nbBytes, $strong );
if ( false !== $bytes && true === $strong ) {
return $bytes;
}
@darmentrout
darmentrout / user-theme-example.html
Created August 13, 2018 20:45
Setting custom themes for users with the HSL color model, CSS custom properties, and JavaScript Cookies.
<!DOCTYPE html>
<html lang="en" data-theme="green">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CSS Custom Properties Test</title>
<!-- Assembled by Damion Armentrout, 2018. -->
<style>
/* HSL is cool. https://www.sarasoueidan.com/blog/hex-rgb-to-hsl/ */
@darmentrout
darmentrout / dishwalla.js
Last active April 3, 2019 19:17
This is a stupid joke based on a song from 1996.
var cars = {
"acura": {
"color": "blue",
"year": 2009
},
"buick": {
"color": "gray",
"year": 2010
},
"chevy": {
@darmentrout
darmentrout / always-updated.html
Created April 12, 2019 14:25
A way of including .CSS and .JS files so that users always get the most current version. Bustin' caches makes me feel good.
<!-- put this in the HEAD -->
<script>
var newestVersion = Date.now();
var linkSrc = 'style.css?version=' + newestVersion;
var theLink = document.createElement("link");
theLink.href = linkSrc;
theLink.rel = 'stylesheet';
document.head.appendChild(theLink);
</script>
# -*- coding: utf-8 -*-
# ABV 1.0 12/31/2012
# This is one of my very first side projects as a programmer/developer!
print '''
Calculate the Alcohol by Volume (ABV) of your
homebrewed beer using the following formula:
ABV = ((((OG-FG)*1.05)/FG)/0.79)*100
1.05 g — the amount of CO2 per gram of ethanol produced
0.79 g/mL – the density of ethanol alcohol
@darmentrout
darmentrout / crt-text.html
Last active January 8, 2020 20:50
an imitation of CRT RGB pixels
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CRT TEXT</title>
<meta name="inspiration" content="https://i.redd.it/cgcpgwpa60841.jpg">
<style>
* { box-sizing: border-box; }
@darmentrout
darmentrout / boxes.html
Created January 9, 2020 20:15
Fill a viewport with colorful boxes.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Boxes</title>
<style>
:root {
--box-w: 10vw;
@darmentrout
darmentrout / sharePointCalendarColorCoding.html
Last active February 24, 2020 15:45
Color-Code and Toggle SharePoint Calendar Events
<style>
#WPQ2_nav_header {
font-size: 3em;
float: left;
}
.ms-acal-header td, .ms-acal-rootdiv td, .ms-acal-rootdiv th {
vertical-align: middle;
}
.ms-acal-item {
background-color: #666;
@darmentrout
darmentrout / mouse.html
Last active May 7, 2020 16:22
Experiments in mouse movement
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>mouse</title>
<style>
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; padding: 0px; margin: 0px; }
@darmentrout
darmentrout / simple-text-editor.html
Last active January 8, 2021 17:53
A simple text editor for the browser
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Text Editor</title>
<style>
* { box-sizing: border-box; }
html,
body {