Skip to content

Instantly share code, notes, and snippets.

Avatar
⛑️

Huy huytd

⛑️
View GitHub Profile
@huytd
huytd / todo.vim
Created Jun 14, 2020
A Todo list syntax in Vim, with an actual checkbox
View todo.vim
" Vim syntax file
" Language: Todo
" Maintainer: Huy Tran
" Latest Revision: 14 June 2020
if exists("b:current_syntax")
finish
endif
" Custom conceal
@huytd
huytd / .gitconfig
Created Aug 4, 2016
Use neovim as diff tool
View .gitconfig
[merge]
tool = vimdiff
[mergetool]
prompt = true
[mergetool "vimdiff"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
[difftool]
prompt = false
[diff]
tool = vimdiff
View fool.js
debug("Thẻ cái bếp nè");
View firebug-lite-1.2.js
var firebug = {
version:[1.231,20100118],
el:{},
env:{
"css":"http://getfirebug.com/releases/lite/1.2/firebug-lite.css",
"debug":true,
"detectFirebug":true,
"dIndex":"console",
"height":295,
"hideDOMFunctions":false,
View vscode-vim.json
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.insertModeKeyBindings": [
{
"before": [
"j",
"k"
],
@huytd
huytd / parser-combinator-demo.js
Created Jul 24, 2020
Build a parser combinator step by step
View parser-combinator-demo.js
// Error handling helper
const ok = (found, remain) => ({ found, remain });
const error = (msg) => ({ error: msg });
// Primitive parsers
const digit = (input) => {
const [head, ...rest] = input;
if (!isNaN(+head) && +head >= 0 && +head <= 9) {
return ok(head, rest);
@huytd
huytd / d3_realtime_linechart.html
Created Nov 6, 2015
Realtime Line Chart with D3
View d3_realtime_linechart.html
<style>
.axis {
font-family: sans-serif;
fill: #d35400;
font-size: 12px;
}
.line {
fill: none;
@huytd
huytd / markdown.vim
Created Jun 15, 2020
Checkbox for markdown in Vim
View markdown.vim
syntax match todoCheckbox '\v\s*(-? \[[ x\.!\*]\])' contains=finishedCheckbox,unfinishexCheckbox,flaggedCheckbox,starredCheckbox
syntax match finishedCheckbox '\v(-? \[[ \.]\])' conceal cchar=
syntax match unfinishexCheckbox '\v(-? \[x\])' conceal cchar=
syntax match flaggedCheckbox '\v(-? \[!\])' conceal cchar=
syntax match starredCheckbox '\v(-? \[\*\])' conceal cchar=
hi link todoCheckbox Todo
hi clear Conceal
View customized-lichess.css
.crosstable { display: none; }
.analyse__moves::before {
content: " white black ";
width: 100%;
display: block;
text-align: center;
white-space: pre-wrap;
padding: 5px;
font-weight: bold;
@huytd
huytd / d3-text-measure.js
Created May 6, 2016
Measure text size in pixels with D3.js
View d3-text-measure.js
function textSize(text) {
if (!d3) return;
var container = d3.select('body').append('svg');
container.append('text').attr({ x: -99999, y: -99999 }).text(text);
var size = container.node().getBBox();
container.remove();
return { width: size.width, height: size.height };
}
// Usage: textSize("This is a very long text");
You can’t perform that action at this time.