Skip to content

Instantly share code, notes, and snippets.

View p1xelHer0's full-sized avatar
🌱

pontus p1xelHer0

🌱
  • Stockholm
  • 13:57 (UTC +02:00)
View GitHub Profile
@p1xelHer0
p1xelHer0 / aoc.4.1.ml
Created December 5, 2023 07:41
aoc.4.1.ml
module Card = struct
type t = { id : int; wins : int list; mine : int list }
[@@deriving show { with_path = false }, eq]
end
module P = struct
open Angstrom
let is_digit = function '0' .. '9' -> true | _ -> false
let int = take_while1 is_digit >>| Int.of_string_exn
@p1xelHer0
p1xelHer0 / dijkstra.ml
Created November 12, 2023 20:01
aoc_2021_15
module Coordinate = struct
type t = { x : int; y : int; value : int }
let make ~x ~y value = { x; y; value }
let compare t1 t2 =
match compare t1.x t2.x with 0 -> compare t1.y t2.y | _ as x -> x
end
module PQ = Psq.Make (Coordinate) (Int)
@p1xelHer0
p1xelHer0 / advent_of_ocaml.ml
Created November 7, 2023 16:19
Advent of OCaml
open ContainersLabels
let read_file name = CCIO.(with_in name read_lines_l)
let rec try_parse parsers line =
match parsers with
| [] -> failwith ("could not parse: " ^ line)
| parse :: parsers -> (
match parse line with
| None -> try_parse parsers line
.
├── core
│   ├── autocmd.lua
│   ├── config.lua
│   ├── init.lua
│   ├── lazy.lua
│   └── options.lua
├── init.lua
├── internal
│   └── lsp.lua
let example a = match a with 1 | 2 | 3 -> Ok a | _ -> Error "ohno"
let test =
(* this only works cuz of >>=, |> woudln't work here:
we would end up with a
`a result result result result`
instead of a
`a result`*)
1 |> example >>= example >>= example >>= example
do shell script "open x-apple.systempreferences:com.apple.preference.displays"
tell application "System Events"
tell application process "System Settings"
repeat until (exists UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window 1)
delay 0.1
end repeat
tell window 1 #"Displays"
set displayOptions to UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1
set StandardRes to button 4 of displayOptions
set MoreSpaceRes to button 5 of displayOptions
@p1xelHer0
p1xelHer0 / rust-lsp
Created April 29, 2021 12:54
rust-lsp.lua
local nvim_lsp = require("lspconfig")
local function on_attach(client, bufnr)
require("completion").on_attach(client)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
{
"special": {
"background": "#090803",
"foreground": "#dfd1be",
"cursor": "#dfd1be"
},
"colors": {
"color0": "#090803",
"color1": "#936D16",
"color2": "#89765F",
@p1xelHer0
p1xelHer0 / config.ml
Last active February 10, 2020 22:36
open Rresult
open Sexplib0.Sexp
let parse root_path =
let read_config path =
let root_path = path |> Fpath.to_dir_path |> Fpath.normalize in
let odot_file = Fpath.append root_path Model.config_file in
Bos.OS.File.read odot_file
in

Keybase proof

I hereby claim:

  • I am p1xelher0 on github.
  • I am p1xelher0 (https://keybase.io/p1xelher0) on keybase.
  • I have a public key ASDxA7YLfph-222OjyjIZbMQvMWejInfPqE3gpLUaR7qswo

To claim this, I am signing this object: