Skip to content

Instantly share code, notes, and snippets.

View sackeyjason's full-sized avatar

Jason Sackey sackeyjason

View GitHub Profile
@sackeyjason
sackeyjason / steamshots.sh
Last active February 13, 2023 19:05
SteamDeck screenshot management
#!/bin/bash
# Store the user_id in a variable
user_id=0
# Store the provided date in a variable
input_date=$1
# Get the current date in the format yyyy-mm-dd
current_date=$(date +%F)
@sackeyjason
sackeyjason / stuff.md
Last active September 19, 2023 10:19
Web greyscale, colouring
@sackeyjason
sackeyjason / shuffle.js
Last active August 13, 2021 12:24
Shuffle array
/**
* Randomise array order
* @param {Array} arr Array to randomise
* @param {Object} [options]
* @param {Boolean} [options.mutate] Sets if should modify given array. Defaults to false
* @param {Function} [options.rand] Randomly generate an integer j: min <= j < max
* @returns {Array}
*/
const shuffle = (arr, options) => {
const len = arr.length;
@sackeyjason
sackeyjason / gist:29f38f0f16f4b826a5c63046aaf633e4
Last active April 28, 2021 15:03
Printable ascii symbols
' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
All 33 of 'em.
[ 32, ' ' ]
[ 33, '!' ]
[ 34, '"' ]
[ 35, '#' ]
[ 36, '$' ]
[ 37, '%' ]
@sackeyjason
sackeyjason / f
Last active August 24, 2020 19:13
Haskenthetical attempts
$ stack exec -- haskenthe examples/factorial.hth
failed
CEUnboundVar (Name "\9580\9559")
@sackeyjason
sackeyjason / primes.js
Created August 22, 2020 10:58
Sieve of Erastosthenes
// List the first n prime numbers
primes = n => {
const results = []
let i = 1
while (results.length < n) {
++i
results.find(r => i % r === 0) || results.push(i)
}
return results
}
@sackeyjason
sackeyjason / beersong.js
Last active June 29, 2020 18:19
99 bottles of beer
function beersong(count) {
let startCount = count;
let song = "";
const countBottles = (c, cap) => {
if (c === -1) return countBottles(startCount);
if (c === 0) return (cap ? 'N' : 'n') + 'o more bottles';
if (c === 1) return '1 bottle'
return `${c} bottles`;
}
@sackeyjason
sackeyjason / circle-bg.css
Created June 27, 2020 16:36
Material button focus
.selected-flag:before {
content: ;
content: '';
background-color: #94949454;
width: 48px;
height: 48px;
position: absolute;
left: 4px;
top: 0;
border-radius: 50%;
@sackeyjason
sackeyjason / conditionals.jsx
Last active June 17, 2020 10:51
Conditional props
<Component
aria-selected={highlight ? true : undefined}
/>
<Component
{...(highlight ? { "aria-selected": true } : {})}
/>
/* These are not the same ;_; */
exports.handler = async function http(req) {
return {
body: '{ "ok": true }',
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers":
req.headers["access-control-request-headers"],
},
};