Skip to content

Instantly share code, notes, and snippets.

@cdpath
cdpath / kinlde.bat
Last active February 2, 2018 05:42
clean up extras folders under documents
@echo off
for /f "delims= tokens=1*" %%a in ('dir /b *.sdr') do (
if not exist "%%~na.mobi" (
if not exist "%%~na.azw*" (
if not exist "%%~na.txt" (
if not exist "%%~na.pdf" (
rd /s/q %%a
)
)
)
@cdpath
cdpath / kinlde.bat
Created October 25, 2016 15:55
remove kindle unnecessary dirs
@echo off
for /f "delims= tokens=1*" %%a in ('dir /b *.sdr') do (
if not exist "%%~na.mobi" (
if not exist "%%~na.azw*" (
if not exist "%%~na.txt" (
if not exist "%%~na.pdf" (
rd /s/q %%a
)
)
)
@cdpath
cdpath / util
Last active October 18, 2016 08:19
handlers for hubot-script-shellcmd
#!/usr/bin/env bash
set -o errexit
cmd_type=$1
do_top() {
top -b -n2 -p 1 | fgrep "Cpu(s)" | tail -1 | awk -F'id,' -v prefix="$prefix" '{ split($1, vs, ","); v=vs[length(vs)]; sub("%", "", v); printf "%s%.1f%%\n", prefix, 100 - v }'
}
do_who() {
who | awk '{print $1}'
@cdpath
cdpath / backcard.html
Last active August 6, 2016 05:29
anki template
<p class='word'> {{word}}</p>
<p>{{word Audio}}</p>
<p class='sentence'>{{examples_en}}</p>
<hr id=answer>
<p class='definition'>{{explanation_cn}}</p>
<p class='sentence'>{{examples_cn}}</p>
<p class='info'>★ {{phonetic symbol}} / <a href='eudic://dict//{{word}}'>Eudic</a> / {{#how_to_mem_zhuji3000}}{{how_to_mem_zhuji3000}}{{/how_to_mem_zhuji3000}}{{^how_to_mem_zhuji3000}} {{how_to_mem_bzsdbdc}}{{/how_to_mem_zhuji3000}}</p>
@cdpath
cdpath / bash_template.sh
Created March 9, 2016 07:40
bash 模板
#!/bin/bash
echo "OPTIND starts at $OPTIND"
while getopts ":pq:" optname
do
case "$optname" in
"p")
echo "Option $optname is specified"
;;
"q")
echo "Option $optname has value $OPTARG"
@cdpath
cdpath / keymap.cson
Created March 4, 2016 05:33
自定义 Atom key-bingdin
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
@cdpath
cdpath / mvvenv.sh
Created February 26, 2016 05:27
mv virtualenv properly
#!/usr/bin/env bash
# Usage: mvvenv.sh oldpath newpath
oldpath=$(realpath $1)
newpath=$(realpath $2)
# binpath=$(find oldpath -type d -name bin)
# tmp=${binpath%/*}
# venvname=${tmp##*/}
venvname=${VIRTUAL_ENV##*/}
oldvenvpath=$oldpath/$venvname
newvenvpath=$newpath/$venvname
@cdpath
cdpath / cvimConfig
Created January 2, 2016 04:10
cVim config
map h gT
map l gt
map w gT
map e gt
unmap d
map d x
unmap ;
map ; :
set nohud
set nosmoothscroll
#监控咸鱼商品.sh
#http://www.hi-pda.com/forum/viewthread.php?tid=1735219&extra=page%3D1
#监控商品的具体型号,标题和顶楼内容中符合其中的一项就会提醒:
keyword='newifi'
#价格,低于将提醒
pricelimit=81
#输出到html文件
alertfile=taobao.htm