Skip to content

Instantly share code, notes, and snippets.

View iwestlin's full-sized avatar
🏸

issue哥 iwestlin

🏸
View GitHub Profile
@iwestlin
iwestlin / toc.css
Last active March 31, 2016 09:09
Sublime Text - Markdown Preview - extra css for toc
.toc {
font-size: 14px;
position: fixed;
top: 0px;
left: -330px;
width: 270px;
height: 100%;
overflow-x: scroll;
overflow-y: scroll;
padding: 0 0 0 100px;
@iwestlin
iwestlin / mysql2sqlite.sh
Created January 6, 2016 09:47 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
javascript:(function(){function img2link(a){var b=document.createElement("a");return b.href=a.src.replace("220X220","1000X1000"),b.download="",b}for(var imgList=document.getElementsByClassName("db_pictypeout")[0].getElementsByTagName("img"),i=0;i<imgList.length;i++){var link=img2link(imgList[i]);document.body.appendChild(link),link.click()}})();
@iwestlin
iwestlin / setZeroTimeout.js
Created April 10, 2017 01:51 — forked from mathiasbynens/setZeroTimeout.js
Cross-browser-compatible setZeroTimeout
/*! Cross-browser-compatible setZeroTimeout
*
* I took the original setZeroTimeout and made it cross-browser-compatible, using setTimeout(fn, 0) as a fallback in case postMessage is not supported.
* Mathias Bynens <http://mathiasbynens.be/>
* See <http://mathiasbynens.be/notes/settimeout-onload>
*
* Copyright statement below:
*
* See <http://dbaron.org/log/20100309-faster-timeouts>
* By L. David Baron <dbaron@dbaron.org>, 2010-03-07, 2010-03-09
@iwestlin
iwestlin / 24Game.js
Created April 1, 2020 04:31
随机取牌算不出 24 点的概率是多少? https://www.zhihu.com/question/307729091
function equal_to_24 (n) {
return Math.abs(24 - n) < 1e-10
}
const jia = (a, b) => a + b
const jian = (a, b) => a - b
const chen = (a, b) => a * b
const chu = (a, b) => a / b
const oprators = [jia, jian, chen, chu]
@iwestlin
iwestlin / rename.js
Created May 11, 2020 17:35
batch rename files in some directory
const fs = require('fs')
const DIR = 'this is the directory you want to process'
const STRING_TO_REMOVE_IN_FILENAME = 'this is the string in file name which you want to replace'
const NEW_STRING = 'this is the string you want to replace with'
rename_file_in_dir({dir: DIR, str: STRING_TO_REMOVE_IN_FILENAME, newstr: NEW_STRING})
function rename_file_in_dir ({dir, str, newstr}) {
// const files = fs.readdirSync(dir, {withFileTypes: true}).map(file => ({name: file.name, is_dir: file.isDirectory()}))
function gen_arr_from (start, length) {
return Array(length).fill(start).map((v, i) => v + i).map(v => String.fromCodePoint(v))
}
const zeros = [0x24FF, 0x3007, 0x1F10B, 0x1F10C, 0x07C0, 0x104A0, 0x11136, 0x1C50, 0x1810, 0x0ED0, 0x1040, 0x17E0, 0x1946, 0x1BB0, 0xFF10, 0x19D0, 0x0D66, 0x0AE6, 0x1C40, 0x1A90, 0x1A80, 0x0CE6, 0x0C66, 0x09E6, 0x0A66, 0x0B66, 0x0BE6].map(v => String.fromCodePoint(v))
const zero_to_nines = [
gen_arr_from(0x1D7CE, 10),
gen_arr_from(0x1D7D8, 10),
gen_arr_from(0x1D7E2, 10),
gen_arr_from(0x1D7EC, 10),
@iwestlin
iwestlin / Win2K3.md
Created September 28, 2020 00:38
code summary for Win2K3

snapshot: https://code.viegg.com/single/Win2K3-snap.html

loc generated by tokei:

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Alex                   55        72622        63259            0         9363
 ASP                   532       163253       110308        25616        27329
 ASP.NET               343        38560        32837         1210         4513
@iwestlin
iwestlin / XPSP1.md
Created September 28, 2020 00:41
code summary for XPSP1

snapshot: https://code.viegg.com/single/XPSP1-snap.html

loc generated by tokei:

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Alex                   72        94155        83621            0        10534
 ASP                   591        74916        59746         2657        12513
 ASP.NET                 4         2081         1765            5          311
@iwestlin
iwestlin / rust-command-line-utilities.markdown
Created December 30, 2022 03:11 — forked from sts10/rust-command-line-utilities.markdown
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, exa, fd, hyperfine, miniserve, ripgrep, just, zoxide and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
  • bat: A replacement for cat that provides syntax highlighting and other features.
  • bottom: Yet another cross-platform graphical process/system monitor.