Skip to content

Instantly share code, notes, and snippets.

View hovsater's full-sized avatar
🤟

Kevin Hovsäter hovsater

🤟
View GitHub Profile
View test.rb
class Test
FOO = 1
BAR = 'bar'
def call
end
end
@hovsater
hovsater / day_01.clj
Created July 27, 2023 21:40
Solution to Advent of Code year 2022, day 1.
View day_01.clj
(ns advent-of-code-year-2022.day-01
"Advent of Code - Solution to year 2022, day 1."
(:require
[clojure.string :as str]))
(def sample-input
"1000
2000
3000
@hovsater
hovsater / day01.odin
Last active July 19, 2023 15:14
Solution to part 1 of Advent of Code 2018 (See https://adventofcode.com/2018/day/1)
View day01.odin
package main
import "core:io"
import "core:strings"
import "core:testing"
freq :: proc(stream: io.Stream) -> (res: int) {
base :: 10
sign := 1
num: int
View hang.go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
s := bufio.NewScanner(os.Stdin)
@hovsater
hovsater / change-theme.sh
Last active June 6, 2023 18:41
Change Zed theme automatically based on macOS appearance
View change-theme.sh
#!/usr/bin/env sh
set -e
dark_theme="Andromeda"
light_theme="Solarized Light"
while true; do
if defaults read -g AppleInterfaceStyle &>/dev/null; then
if [ $(< $HOME/.current-theme) = "dark" ]; then
continue;
@hovsater
hovsater / gist:a0b1c26ead82e49bb9f07d23a1ba5f8c
Created April 29, 2023 17:21
Poor Man's version of finding dead code (specifically Ruby constants)
View gist:a0b1c26ead82e49bb9f07d23a1ba5f8c
grep -REho --include \*.rb '\b[A-Z_]+\b\s*=' . | tr -d '=' | cut -d' ' -f1 | sort | uniq -u | xargs -I{} bash -c 'if [[ $(grep -Rhow --include \*.rb "{}" . | wc -l) -eq 1 ]] ; then echo {} ; fi'
@hovsater
hovsater / Day05.elm
Created April 22, 2023 06:57
Advent of Code 2022 - Day 5 (using `elm/parser`)
View Day05.elm
module Year2022.Day05 exposing (..)
import Aoc.Problem exposing (Answer(..), Input, Solution)
import Array exposing (Array)
import List.Extra as List
import Parser exposing ((|.), (|=), Parser, Step(..), andThen, chompIf, chompWhile, getChompedString, int, keyword, loop, map, oneOf, succeed, symbol)
type alias Crate =
String
View open-in-place.patch
diff --git a/src/commands.c b/src/commands.c
index 63cb3606..61abb0c3 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -1113,10 +1113,12 @@ static bool cmd_open(EditorState *e, const CommandArgs *a)
paths = globbuf.gl_pathv;
}
+ bool replace_view = has_flag(a, 'R');
+
@hovsater
hovsater / Day06.elm
Created December 7, 2022 15:48
Solution to Advent of Code 2022, Day 6.
View Day06.elm
module Day06 exposing (partOne, partTwo)
import Set exposing (Set)
type alias Signal =
String
findStartOfPacketMarker : Int -> Signal -> Int
@hovsater
hovsater / Day05.elm
Created December 7, 2022 14:59
Solution to Advent of Code 2022, Day 5.
View Day05.elm
module Day05 exposing (partOne, partTwo)
import Dict exposing (Dict)
import List.Extra as List
type alias Crate =
Char