Skip to content

Instantly share code, notes, and snippets.

@zetashift
zetashift / scoptions.scala
Last active August 14, 2021 15:41
Options In Scala
enum Option[+A]:
case Some(value: A)
case None
def map[B](f: A => B): Option[B] = this match
case None => None
case Some(value) => Some(f(value))
def flatMap[B](f: A => Option[B]): Option[B] = this match
case None => None
@zetashift
zetashift / shell.nix
Last active June 24, 2021 21:33
Indigo Shell Nix
{ jdk ? "jdk11" }:
let
pkgs = import <nixpkgs> { inherit jdk; };
in
pkgs.mkShell {
name = "indigo-shell";
buildInputs = [
pkgs.coursier
@zetashift
zetashift / fontim.nim
Last active June 23, 2021 22:04
Fontim, cross platform font path finding in Nim
import os, strformat, options
## Get the locations(paths) of a given `font` in a string
func getFontsDir(): seq[string] =
when defined(windows):
# TODO use winim to get Windows installation location
result = @[r"C:\Windows\Fonts\"]
elif defined(macosx):
result = @[r"/Library/Fonts"]
elif defined(linux):
@zetashift
zetashift / snap.fnl
Created June 20, 2021 14:52
Snap & fennel
(module magic.plugin.snap
{autoload {snap snap}})
(let [fzf (snap.get :consumer.fzf)
limit (snap.get :consumer.limit)
producer-file (snap.get :producer.ripgrep.file)
producer-jumplist (snap.get :producer.vim.jumplist)
producer-git (snap.get :producer.git.file)
producer-luv-file (snap.get :producer.luv.file)
producer-vimgrep (snap.get :producer.ripgrep.vimgrep)
@zetashift
zetashift / init.fnl
Last active June 15, 2021 14:33
My Fennel Story
(module magic.init
{autoload {plugin magic.plugin
nvim aniseed.nvim}})
;;; Introduction
;; Aniseed compiles this (and all other Fennel files under fnl) into the lua
;; directory. The init.lua file is configured to load this file when ready.
;; We'll use modules, macros and functions to define our configuration and
@zetashift
zetashift / ltex_ls.lua
Created May 11, 2021 19:41
Ltex-ls and NeoVim
local lspconfig = require'lspconfig'
local configs = require'lspconfig/configs'
local M = {}
M.setup = function()
-- Check if it's already defined for when reloading this file
if not lspconfig.ltex_ls then
configs.ltex_ls = {
default_config = {
@zetashift
zetashift / init.lua
Created March 25, 2021 00:32
My WIP neovim init
-- :version
-- NVIM v0.5.0-dev
-- Build type: RelWithDebInfo
-- LuaJIT 2.1.0-beta3
local execute = vim.api.nvim_command
local fn = vim.fn
local cmd = vim.cmd
local g = vim.g
@zetashift
zetashift / shell.nix
Last active March 16, 2021 20:14
Elixir minimum shell.nix
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
erlang = erlangR23;
elixir = elixir_1_11;
nodejs = nodejs-14_x;
inputs = [
@zetashift
zetashift / shell.nix
Last active March 16, 2021 17:31
Bare minimum Gleam shell.nix
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let inputs = [
gleam
erlang
rebar3
];
@zetashift
zetashift / immutable_setup.nim
Created February 24, 2021 20:39
Nim - variable immutable after setup
let vao = block:
var res: GLuint
glGenVertextArrays(1, addr res)
res
glBindVertextArray(vao)