Skip to content

Instantly share code, notes, and snippets.

View SteGriff's full-sized avatar
🎸
Neow

Stephen Griffiths SteGriff

🎸
Neow
View GitHub Profile
@SteGriff
SteGriff / playground.kt
Created January 28, 2026 14:37
Kotlin playground
import java.time.LocalDate
fun main(){
// Currying and function types
val sum = {a : Int, b : Int -> a + b}
fun add(a: Int, b: Int) = a + b
val add2 = {a : Int -> sum(a,2)}
println(sum(2,2))
println(add2(3))
println(add(3,3))
@SteGriff
SteGriff / day_of_week.rb
Created January 2, 2025 16:30
A Ruby function to get day of week (Gregorian)
def day_of_week(day, month, year)
# Zeller's Rule - Jan/Feb are Month 13/14 of previous year
if month < 3
month += 12
year -= 1
end
k = year % 100
j = year / 100
# Zeller's congruence
h = (day + (13 * (month + 1)) / 5 + k + (k / 4) + (j / 4) - (2 * j)) % 7
@SteGriff
SteGriff / blogroll.txt
Last active December 19, 2025 14:27
Blogroll
# Blogroll
## IRL friends and colleagues who have websites
https://dominicbisset.co.uk/ - Dom and I met as teens, worked together for years at Village, and we occasionally play board games.
https://stevenjwright.me/ - Steven has been my friend since high school and we recently reconnected. He turned out pretty cool.
https://michaelbanner.substack.com/ - Mike taught me a lot of dev stuff at Village, and is now an engineering manager.
https://mtempleheald.github.io/ - Mark is an engineer at MSG.
https://rodlaycock.co.uk/ - Rod is a principal eng at MSG.
https://www.mjwals.co.uk/ - Matt worked with me for a few years at Paymentshield/Atlanta.
@SteGriff
SteGriff / yetnoti.txt
Created January 27, 2024 21:52
Yet not I lyrics
What gift of grace is Jesus my redeemer,
There is no more for heaven now to give
He is my joy, my righteousness, and freedom
My steadfast love, my deep and boundless peace
To this I hold, my hope is only Jesus
For my life is wholly bound to his
Oh how strange and divine, I can sing: all is mine!
Yet not I, but through Christ in me
@SteGriff
SteGriff / StringExtensions.cs
Created September 22, 2023 13:53
C# String ReplaceFirst
public static class StringExtensions
{
public static string ReplaceFirst(this string target, string oldString, string newString)
{
int start = target.IndexOf(oldString);
if (start < 0)
return target;
int end = start + oldString.Length;
@SteGriff
SteGriff / async-promises.htm
Created February 9, 2023 16:14
Async and promises in JS - a proof of concept for returning values from async fns
<html>
<head><style>div{margin:2em;} ul{padding:0;}</style>
<body>
<div>
<ul>
<li>Open the DevTools console</li>
<li>Press Go</li>
<li>Data will be fetched from server (<code>return await fetch().then()</code>)</li>
<li>Press Go again</li>
<li>Data will be returned locally from the async function (<code>return todos</code>)</li>
@SteGriff
SteGriff / move-last-git-commit-to-different-branch.md
Last active January 25, 2023 14:42
Move last git commit to a different branch

Move last git commit to a different branch

So you committed to main instead of your feature branch? Oops! But it's ok. All commits in git are special little things that are easy to chip up and kick around ⚽

If you need to do any sleuthing first, use

git log
@SteGriff
SteGriff / move-commits.sh
Created October 8, 2021 13:08
Git move commits to another branch
# == Check how many commits to move ==
git log
# == Move commits to a new branch ==
# Creates the branch at current HEAD but doesn't check it out:
git branch new-branch
# Resets master/main/current back x commits
git reset --keep HEAD~2
@SteGriff
SteGriff / toSentenceCase.js
Created August 26, 2021 13:09
JS String toSentenceCase
String.prototype.toSentenceCase = function(){ return this.slice(0,1).toUpperCase() + this.slice(1) }
@SteGriff
SteGriff / predict-indexes.sql
Created June 10, 2021 13:48
Predict useful SQL indexes
SELECT
dm_mid.database_id AS DatabaseID,
dm_migs.avg_user_impact*(dm_migs.user_seeks+dm_migs.user_scans) Avg_Estimated_Impact,
dm_migs.last_user_seek AS Last_User_Seek,
object_name(dm_mid.object_id,dm_mid.database_id) AS [TableName],
'CREATE INDEX [IX_' + object_name(dm_mid.object_id,dm_mid.database_id) + '_'
+ REPLACE(REPLACE(REPLACE(ISNULL(dm_mid.equality_columns,''),', ','_'),'[',''),']','') +
CASE
WHEN dm_mid.equality_columns IS NOT NULL AND dm_mid.inequality_columns IS NOT NULL THEN '_'
ELSE ''