Skip to content

Instantly share code, notes, and snippets.

View hopeseekr's full-sized avatar

Theodore R. Smith hopeseekr

View GitHub Profile
@hopeseekr
hopeseekr / redis-active-lines.log
Last active March 25, 2024 02:17
Redis Authorship Stats 2024-03-20
Redis Contributors with more than 10 Active lines of code in the `unstable` branch, ignoring whitespace changes.
Statistics based on HEAD
Active files: 1,566
Active lines: 417,517
Total commits: 9,516
Note: Files matching MIME type image, binary has been ignored
+----------------------------------+---------+---------+-------+--------------------+
@hopeseekr
hopeseekr / thin_space.php
Created January 21, 2023 19:50
ASCII Space vs UTF-8 Thin Space in PHP
<?php
/** See it live: https://onlinephp.io/c/551a0 **/
$helloWorld = [
'ascii' => 'Hello, World!',
'utf-8' => 'Hello, World!',
];
$spacePos = strpos($helloWorld['ascii'], ' ');
@hopeseekr
hopeseekr / conditional.js
Created June 25, 2021 03:19
Conditionally load non-minified JS if needed.
<!DOCTYPE html>
<html lang="en">
<head>
<script src="js/our.min.js"></script>
<!-- Conditionally load the non-minified JS if needed -->
<script>
(function() {
if (typeof SOME_VAR === 'undefined') {
document.write('<script src="js/our.js"><\/script>');
}
@hopeseekr
hopeseekr / part1.md
Last active December 27, 2020 09:30
The Ether and The DAO: A cryptocoin Sci-FI short-story

The Inspiration

You know, I want to write a scifi story now about how aliens make #FirstContact with us, despite our aggression and disunity...

They choose to land at an #Ethereum conference in 2023 and say, “We want to welcome you to export consensus algorithm DAOs to the #GalacticFederation!”


The Backdrop

@hopeseekr
hopeseekr / grab-document.sh
Created October 22, 2020 16:11
Grab the text from an existing file -or- user input in BASH
#!/bin/bash
#############################################################
# Grab the text from an existing file -or- user input... #
# #
# Copyright © 2020 Theodore R. Smith #
# License: Creative Commons Attribution v4.0 International #
# From: https://github.com/hopeseekr/BashScripts/ #
# @see https://stackoverflow.com/a/64486155/430062 #
#############################################################
function grabDocument()
@hopeseekr
hopeseekr / youtube-duration-sorter.js
Last active September 21, 2020 13:13
Sort YouTube Videos by Duration, Descending
# Sorts YouTube duration, descending, in the Videos Tab
# Add as a bookmarklet
# See https://mreidsma.github.io/bookmarklets/installing.html (https://archive.is/zTp0O)
# Demo: ![image](https://user-images.githubusercontent.com/1125541/93770778-49596f00-fbe2-11ea-8095-9feee6ba6753.png)
javascript:(function(){l=[].map.call(document.querySelectorAll("span.ytd-thumbnail-overlay-time-status-renderer"),function(e){l=e.innerHTML.trim().split(":").map(function(t){return parseInt(t)}).reduce(function(p,c){return p*60+c});return{a:e.parentElement.parentElement.parentElement,l:l}}).sort(function(a,b){return b.l-a.l});i=document.querySelector("#primary #items");l.forEach(function(o){i.appendChild(o.a.parentElement.parentElement.parentElement)})})()
@hopeseekr
hopeseekr / amazing-aliases.sh
Last active September 18, 2020 19:26
Amazing Linux, PHP and Git aliases
# Dev aliases
alias free="free -m"
alias dup='(docker-compose up -d && docker-compose logs -ft)'
# I recomment putting this in /etc/cron.daily/
alias docker-prune='docker rmi $(docker images | grep "^<none>" | awk "{print $3}")'
# Git
alias gd='git diff'
alias ga='git add'
alias gco='git checkout --ours'
@hopeseekr
hopeseekr / Cookie Clicker Save.md
Created September 1, 2020 21:31
Cookie Clicker Save
@hopeseekr
hopeseekr / stop_sequencer.php
Created May 3, 2020 20:25
Splits long DNA strings into sequences and then counts the stop codons.
<?php
$DNA = file($argv[1]);
$splitDNA = str_split($DNA[1], 3);
$stopCodons = [
'TAG',
'TAA',
'TGA',