This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* create a module hiding implementation of what type the ID is and creating ser/de methods *) | |
module UserID = struct | |
type t = int | |
let t = | |
let encode (t : t) : (int, string) result = Ok t in | |
let decode (t : int) : (t, string) result = Ok t in | |
Caqti_type.(custom ~encode ~decode int) | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Proposed | |
/// A file which may or may not be async | |
struct ?async File { | |
file_descriptor: std::os::RawFd, // shared field in all contexts | |
async waker: Waker, // field only available in async contexts | |
!async meta: Metadata, // field only available in non-async contexts | |
} | |
impl ?async File { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
use std::fs; | |
fn main() -> Result<(), std::io::Error> { | |
let name = env::args().nth(1).expect("to pass an argument"); | |
// Version 1 | |
fs::read_to_string(&name)? | |
.lines() | |
.flat_map(|x| x.parse::<i32>()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CoordSet = Set.Make (struct | |
type t = int * int | |
let compare = Stdlib.compare | |
end) | |
let part_1 input = | |
let size = List.hd input |> String.length in | |
let matrix_n = Array.init size (fun _ -> Array.make size 0) in | |
let transform_n row col = row, col in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
/Y/ { s += 3 } | |
/Z/ { s += 6 } | |
/A Y|B X|C Z/ { s += 1 } | |
/B Y|C X|A Z/ { s += 2 } | |
/C Y|A X|B Z/ { s += 3 } | |
END { print s } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local NVIM9 = require("vim9script") | |
local __VIM9_MODULE = {} | |
local prepended = nil | |
local grepCache = nil | |
local Complete = nil | |
local GetAddition = nil | |
local Tag2item = nil | |
local Dict2info = nil | |
local ParseTagline = nil | |
local Tagline2item = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- vim9script | |
-- # cfilter.vim: Plugin to filter entries from a quickfix/location list | |
-- # Last Change: Jun 30, 2022 | |
-- # Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com) | |
-- # Version: 2.0 | |
-- # | |
-- # Commands to filter the quickfix list: | |
-- # :Cfilter[!] /{pat}/ | |
-- # Create a new quickfix list from entries matching {pat} in the current | |
-- # quickfix list. Both the file name and the text of the entries are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local json = require "json" | |
local path = require "path" | |
local patterns = require "sg.patterns" | |
local recognizers = require "sg.recognizers" | |
local shared = loadfile "shared.lua"() | |
local util = loadfile "util.lua"() | |
local indexer = "sourcegraph/scip-typescript:autoindex" | |
local typescript_nmusl_command = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local sorter = require("telescope").extensions.fzf.native_fzf_sorter() | |
-- Save original scoring function to get the score | |
local fzf_scoring_function = sorter.scoring_function | |
-- Override function to do whatever you want. | |
-- Telescope is just functions | |
sorter.scoring_function = function(self, prompt, line) | |
local score = fzf_scoring_function(self, prompt, line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ThisIsRecommendedButBroken() error { | |
f, err := os.Open("this_file.txt") | |
if err != nil { | |
return err | |
} | |
// Make sure to close this later... | |
defer func() { err = f.Close() }() | |
// do some stuff |