Skip to content

Instantly share code, notes, and snippets.

View codeconscious's full-sized avatar
👾
Learning

CodeConscious codeconscious

👾
Learning
View GitHub Profile
@codeconscious
codeconscious / 2024-03.fsx
Last active December 4, 2024 02:55
Advent of Code 2024 Day 3
open System
open System.Text.RegularExpressions
let input = System.IO.File.ReadAllLines("input/2024/03.txt") |> String.concat String.Empty
Regex.Matches(input, "mul\((\d{1,3}),(\d{1,3})\)")
|> Seq.map (fun m -> Int32.Parse m.Groups[1].Value *
Int32.Parse m.Groups[2].Value)
|> Seq.sum
|> printfn "%d"
@codeconscious
codeconscious / enquoten.fsx
Last active May 5, 2024 12:04
F# script to "enquoten" files
(* Enquoten: An F# Script
Summary: Reads a single text file and splits its lines to the maximum line length
limit provided. The prefix is included in the line length calculation, and it
must be shorter then the line length limit. The script will try to split lines
at spaces, but if none are found, it will cut the line at the line length limit.
Requirements: .NET 8 runtime (Untested on previous versions, though it might work)
Usage: dotnet fsi <lineLengthLimit> <quotePrefix> <filePath>
@codeconscious
codeconscious / convert-audio.rb
Last active January 25, 2024 08:31
Audio format conversion
SUPPORTED_EXTS = ['mp3', 'm4a', 'ogg']
source_ext = ARGV[0]
target_ext = ARGV[1]
def variables_invalid?(source_ext, target_ext, supported_exts)
source_ext.nil? ||
target_ext.nil? ||
!supported_exts.include?(source_ext) ||
!supported_exts.include?(target_ext)
@codeconscious
codeconscious / bookmarket-list-page-headings.js
Last active February 22, 2024 00:31
Bookmarklet: List page headings
/* TODO: Make formatting less likely to be influenced by the current web page. */
javascript: (() => {
let div = document.createElement("div");
div.style.cssText = `
display: block !important;
position: fixed !important;
background: white !important;
color: black !important;
font-size: 1.2em !important;
text-align: left !important;