Skip to content

Instantly share code, notes, and snippets.

@wenliang
wenliang / fif
Created August 16, 2022 05:33
find in file using ripgrep + fzf + bat
#!/usr/bin/env bash
# 1. Search for text in files using Ripgrep
# 2. Interactively narrow down the list using fzf
# 3. Open the file in Vim
IFS=: read -ra selected < <(
rg --color=always --line-number --no-heading --smart-case "${*:-}" |
fzf --ansi \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}'
@wenliang
wenliang / loop.lisp
Created May 10, 2022 05:23 — forked from Idorobots/loop.lisp
Common Lisp LOOP example and output
(let ((random (loop with max = 500
for i from 0 to max
collect (random max))))
(loop for i in random
counting (evenp i) into evens
counting (oddp i) into odds
summing i into total
maximizing i into max
minimizing i into min
finally (format t "Stats: ~A"
@wenliang
wenliang / check_colinear.py
Created February 2, 2022 21:51
use python to solve math problems.
from itertools import combinations
# find points in a line WITHOUT GRAPHING.
# seems only iterating?
points = [(1, 6), (3, 5), (-1, 4), (2, 4), (2, 3), (4, 3), (0, 2), (4, 2), (1, 1), (-4, 0), (3, 0), (-2, -1), (6, -1)]
def check_colinear(pairs):
(p1x, p1y), (p2x, p2y), (p3x, p3y) = pairs
return p1x * (p2y - p3y) + p2x * (p3y - p1y) + p3x * (p1y - p2y) == 0
@wenliang
wenliang / checkvist_lwl.css
Last active September 17, 2022 18:27
checkvist customized css
/* https://gist.github.com/wenliang/bd4a95195d4e058a4db7f129dace3345 */
span.task_closed {
text-decoration: none;
color: #666;
font-size: 13px; /* Smaller than the text */
}
pre code{
background-color: #3b6f47;
@wenliang
wenliang / convert_mm_opml.sh
Last active February 8, 2017 05:24 — forked from mattbowen/mm2oo.py
Mindmeister to OPML: Convert the JSON file in mindmeister's native format into OPML to open with OmniOutliner
#! /bin/bash
for this_mind in $*
do
this_json=${this_mind/mind/json}
unzip -c ${this_mind} map.json | tail -n +3 > ${this_json}
echo ${this_json}
python mm2opml.py ${this_json}
done
@wenliang
wenliang / SpecialDay.py
Created February 20, 2012 01:29
重要日期提醒脚本
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script will read a data file,
and remind you with the method you have configed,
if certain day is approaching.
It is inspired by the website http://jiyiri.com
which is a chinese based website.
@wenliang
wenliang / m2dot.py
Last active November 4, 2015 01:04
generate dot file (for graphviz)
#! /usr/bin/env python
"""
This script will analysis matlab files,
and generate a dot file for graphviz.
@todo accept several matlab code files
@todo distinguish functions and scripts
@todo think about same name function