Skip to content

Instantly share code, notes, and snippets.

View IlmariKu's full-sized avatar

Ilmari IlmariKu

  • Compile Oy
  • Helsinki
View GitHub Profile
@IlmariKu
IlmariKu / henkilotunnus.js
Created April 2, 2024 11:31
Henkilötunnus 2023 regex - new finnish social security number regex to identify
// Henkilötunnus 2023 regex - new finnish social security, regex to identify potential numbers
// Does not actually validate using the checksum
// Allows for case-insensitivity using the /i in the end.
// Includes test variables and tests, just copy the old-form regex or new one
const oldSsnRegex = /^(\d{6}[-+A]\d{3}\S{1})$/i;
/** Compatible with old-form */
const newSsnRegex = /^(\d{6}[a-zA-Z]\d{3}\S{1})$/i;
/** Old-form social security numbers
@IlmariKu
IlmariKu / index.js
Last active January 8, 2024 07:52
Mock Azure OpenAI Node Server For Genie (VSCode)
// Mock-server for Azure OpenAI
// Using this as a basis to create a reverse-proxy, with our own API-system
// for different teams / people / billing to use OpenAI in our company
// This server is specifically built for VSCode Genie-responses
// https://github.com/ai-genie/chatgpt-vscode
// and uses Node GPT-wrapper underneath
// https://github.com/transitive-bullshit/chatgpt-api
// Code totally not cleaned up. Has artificial delay of 100ms
@IlmariKu
IlmariKu / notification-hook.tsx
Last active June 2, 2022 18:54
Notification-hook for React + Redux + Typescript + Material-UI Snackbar - 2022
// Global notification hook for React-applications. Easy way to send Notification for user in your application when needed
// Using: React + Redux + Typescript + Material-UI Snackbar
// Versions:
// Redux: 4.0.1
// "@mui/material": "^5.4.1",
// "react": "^17.0.2",
// "react-router-dom": "^5.2.0",
@IlmariKu
IlmariKu / gist:c89d8fa474907e1c623a00c2792bf859
Created March 18, 2021 11:37
Loop unknown amount of nested Javascript arrays and convert all found values to something else.
// I used this function to find nested geoJson float values and round the values up to smaller decimals
function loopArray(nestedArrays) {
return nestedArrays.map(arrayNow => {
if (isArray(arrayNow)) {
return loopArray(arrayNow)
} else if (isNumber(arrayNow)) {
return 'your operation here'
}
})
@IlmariKu
IlmariKu / run.py
Last active June 4, 2021 11:15
run.py - Python command-line runner for repeated repository tasks
#!/usr/bin/env python3
import os
import datetime
import sys
import subprocess
"""
Command line tool to run simple commands from repository root