Skip to content

Instantly share code, notes, and snippets.

View luckasRanarison's full-sized avatar
📚
Learning stuff

Luckas luckasRanarison

📚
Learning stuff
View GitHub Profile
@MariaSolOs
MariaSolOs / builtin-compl.lua
Last active June 26, 2024 08:42
Built-in completion + snippet Neovim setup
---Utility for keymap creation.
---@param lhs string
---@param rhs string|function
---@param opts string|table
---@param mode? string|string[]
local function keymap(lhs, rhs, opts, mode)
opts = type(opts) == 'string' and { desc = opts }
or vim.tbl_extend('error', opts --[[@as table]], { buffer = bufnr })
mode = mode or 'n'
vim.keymap.set(mode, lhs, rhs, opts)
@afmika
afmika / Option.hs
Last active April 22, 2024 13:41
Proving that Option is a Functor, a Monad, an Applicative and more!
import Control.Applicative (Alternative)
import Control.Monad
import GHC.Base (Alternative (empty, (<|>)))
-- Proving that Option is a Functor, a Monad, an Applicative and more!
data Option a = Some a | None
deriving (Show, Eq)
-- 1. it is a functor! (surprise)
@mactep
mactep / conceal.lua
Last active May 2, 2024 18:44
Conceal html class attribute values using treesitter
-- THIS IS DEPRECATED, USE THE FILE BELOW
-- should get bufnr from autocmd or something
-- conceal only accepts one character
-- thanks to u/Rafat913 for many suggestions and tips
local namespace = vim.api.nvim_create_namespace("class_conceal")
local group = vim.api.nvim_create_augroup("class_conceal", { clear = true })
local conceal_html_class = function(bufnr)
@wbthomason
wbthomason / help.vim
Last active May 22, 2024 22:48
Neovim: Open help in a floating window
scriptencoding utf-8
" This function originates from https://www.reddit.com/r/neovim/comments/eq1xpt/how_open_help_in_floating_windows/; it isn't mine
function! CreateCenteredFloatingWindow() abort
let width = min([&columns - 4, max([80, &columns - 20])])
let height = min([&lines - 4, max([20, &lines - 10])])
let top = ((&lines - height) / 2) - 1
let left = (&columns - width) / 2
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}
@jjwatt
jjwatt / yplay.scm
Last active May 29, 2024 01:41
The Y Combinator explained in a runnable Scheme file
;;; The Y Combinator explained in scheme.
;;; with credits to:
;;; https://mvanier.livejournal.com/2897.html
;;; Status: WIP
(define fibonacci
(lambda (n)
(cond ((= n 0) 0)
((= n 1) 1)
(else (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))))
@fnky
fnky / ANSI.md
Last active June 30, 2024 00:05
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@hediet
hediet / main.md
Last active March 11, 2024 15:05
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";


interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];

NES emulator development guide

Overview of document

@lgarron
lgarron / copyToClipboard.html
Last active December 20, 2023 12:53
Simple `navigator.clipboard.writeText()` polyfill.
<script>
// A minimal polyfill for copying text to clipboard that works most of the time in most capable browsers.
// Note that:
// - You may not need this. `navigator.clipboard.writeText()` works directly in all modern browsers as of 2020.
// - In Edge, this may call `resolve()` even if copying failed.
// - In Safari, this may fail if there is nothing selected on the page.
// See https://github.com/lgarron/clipboard-polyfill for a more robust solution.
//
// License for this Gist: public domain / Unlicense
function writeText(str) {