Skip to content

Instantly share code, notes, and snippets.

@cdpath
cdpath / build.sh
Last active March 28, 2022 07:46
give pandoc a try
pandoc \
preface.md \
part-i.md \
ch1.md \
ch2.md \
ch3.md \
ch4.md \
part-ii.md \
ch5.md \
ch6.md \
@cdpath
cdpath / surfingkeys_conf.txt
Last active December 14, 2024 17:25
surfingkeys_conf
// https://gist.github.com/cdpath/0045a3f28cfd477af3129d1ff5e0c6fe
const {
aceVimMap,
mapkey,
imap,
imapkey,
insertJS,
getClickableElements,
vmapkey,
@cdpath
cdpath / mypy_setup.sh
Created October 25, 2021 03:51
pre-commit and mypy
#!/bin/bash
set -euo pipefail
PRECOMMIT_CONFIG=".pre-commit-config.yaml"
MYPY_CONFIG="mypy.ini"
echo "installing pre-commit"
pip install pre-commit
@cdpath
cdpath / mira.css
Last active October 20, 2021 11:40
CSS snippets for Obsidian
/* Cusor */
.cm-fat-cursor .CodeMirror-cursor {
background-color: black;
opacity: 0.5;
width: 5px;
}
.cm-animate-fat-cursor {
background-color: black;
opacity: 0.5;
@cdpath
cdpath / full_upsert.py
Created June 11, 2021 08:10 — forked from nirizr/full_upsert.py
sqlalchemy upsert supporting delayed ORM insertion and duplicate removal (inside a single query)
def upsert(session, model, rows):
table = model.__table__
stmt = postgresql.insert(table)
primary_keys = [key.name for key in inspect(table).primary_key]
update_dict = {c.name: c for c in stmt.excluded if not c.primary_key}
if not update_dict:
raise ValueError("insert_or_update resulted in an empty update_dict")
stmt = stmt.on_conflict_do_update(index_elements=primary_keys,
@cdpath
cdpath / parser.py
Created April 29, 2019 05:07
托福红宝书
import os
from functools import partial
def is_class_of(tag, class_):
try:
return tag.attrs['class'][0] == class_
except Exception:
return False
@cdpath
cdpath / TCT5.css
Created March 8, 2019 14:30
Chambers Thesaurus, 5th
body{font-family:"Lucida Grande", "Open Sans", "Lucida Sans Unicode";font-size:100%;padding:0%;}
a{text-decoration:none;color:#000;}
p.lnk,p.lnk a{font-style:bold;color:blue;}
p.dg{margin-top:5px;margin-bottom:2px;}
span.r{color:#202040;}
/* span.ctx,a.ctx{color:blue;} */
span.sc{font-variant:initial; font-size: 75%; padding: 0px 2px 0px 2px; border: 1px solid gray; margin-right: 2pt;color: black;}
/* h2{font-weight:400;border-bottom:1px dotted #404040;color:#000;font-size:110%;margin-bottom:3px;margin-top:10px;} */
/* Word Entry*/
h2{font-family:"Helvetica";font-size:100%; margin-top:2px;margin-bottom:2px}
@cdpath
cdpath / init.lua
Created June 15, 2018 03:37
hammerspoon
-- open -g hammerspoon://eudic?query=hammer
hs.urlevent.bind("eudic", function(eventName, params)
cmd = string.format('tell application id "com.eusoft.eudic" to activate & show dic with word "%s"', params['query'])
hs.applescript(cmd)
end)
@cdpath
cdpath / GRE6000.txt
Last active June 9, 2018 14:44
corpus
* Word Tree / Roget's Thesaurus
* Class I. Words Expressing Abstract Relations
** Section I. Existence
*** 1. Being, in The Abstract
***** existence 1
@cdpath
cdpath / full_text_rss.json
Created May 14, 2018 11:08
Full-text RSS with Huginn
{
"schema_version": 1,
"name": "RSS",
"description": "Design Daily",
"source_url": false,
"guid": "34862db1b1318cda2d8b50a94908ffa3",
"tag_fg_color": "#ffffff",
"tag_bg_color": "#ff8000",
"icon": "signal",
"exported_at": "2018-05-14T11:06:25Z",