This file contains hidden or 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
CATEGORY THEORY FOR PROGRAMMERS | |
Category Theory 1.1: Motivation and Philosophy | |
https://www.youtube.com/watch?v=I8LbkfSSR58&index=1&list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_ | |
Composability, Abstraction, Reusability | |
Category Theory is a higher-level language. | |
Not a practical, executable language. |
This file contains hidden or 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
" Replace operator that takes an additional motion | |
" Usage: yr{motion}{char} | |
" Try it together with targets.vim text objects, the possibilities are endless! | |
" TODO: Don't ask for input each time when dot-repeated. (Or is that a feature?) | |
fun! s:Replace(type) | |
let sel_save = &selection | |
let &selection = "inclusive" | |
let reg_save = @@ |
This file contains hidden or 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
// Tom Duff, 1983 (trivia: for a Lucasfilm animation) | |
// problem: loop unrolling (reducing the #of loop tests by putting multiple copies of the | |
// given instruction into the body, instead of just one) | |
// implementation problem: given x-fold unrolling, performing the remainder of iterations, | |
// when count (#of original cycles) is not divisible by x | |
send(to, from, count) | |
register short *to, *from; | |
register count; |
This file contains hidden or 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
import math | |
import os | |
from PyPDF2 import PdfFileReader | |
from PyPDF2 import PdfFileWriter | |
def split_pdf_to_even_length_parts(num_of_parts, path): | |
reader = PdfFileReader(path) | |
num_of_pages = reader.getNumPages() | |
avg_part_length = round(num_of_pages / num_of_parts) |
This file contains hidden or 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 function get_targets(winid) | |
local wininfo = vim.fn.getwininfo(winid)[1] | |
local cur_line = vim.fn.line('.') | |
-- Get targets. | |
local targets = {} | |
local lnum = wininfo.topline | |
while lnum <= wininfo.botline do | |
-- Skip folded ranges. | |
local fold_end = vim.fn.foldclosedend(lnum) | |
if fold_end ~= -1 then |
This file contains hidden or 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 api = vim.api | |
-- Note: The functions used here will be upstreamed eventually. | |
local ts_utils = require('nvim-treesitter.ts_utils') | |
local function get_nodes() | |
local wininfo = vim.fn.getwininfo(api.nvim_get_current_win())[1] | |
-- Get current TS node. | |
local cur_node = ts_utils.get_node_at_cursor(0) | |
if not cur_node then return end | |
-- Get parent nodes recursively. |
This file contains hidden or 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
-- https://github.com/jhawthorn/fzy/pull/116#issuecomment-538708329 | |
local function fzy(a) | |
local saved_spk = vim.o.splitkeep | |
local src_winid = vim.fn.win_getid() | |
-- lines >= 3 is a hardcoded limit in fzy | |
local fzy_lines = (vim.v.count > 2 and vim.v.count) or 10 | |
local tempfile = vim.fn.tempname() | |
local term_cmd = a.input .. ' | fzy -l' .. fzy_lines .. ' > ' .. tempfile | |
-- FIXME: terminal buffer shows in `:ls!` after exiting. |