Skip to content

Instantly share code, notes, and snippets.

@q3yi
q3yi / set-font.el
Created August 12, 2021 07:27
set-emacs-font
(let ((default-font (font-spec :name "Ubuntu Mono" :size 15))
(cn-font (font-spec :name "Sarasa Mono SC")))
(set-frame-font default-font)
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font t charset cn-font)))
@q3yi
q3yi / Common-Lisp-Persecode.md
Created August 29, 2018 06:10
Some algorithm implemented in lisp

Common Lisp Persecode

Shortest Path(最短路径)

BFS(广度优先算法)

  1. 遍历当前节点距离为1的邻接节点
  2. 存在目的节点,搜索结束
  3. 如果不为目的节点,将邻接节点周围距离为1的节点加入带检查的节点队列中
  4. 对待检查节点中的节点运用重复步骤1
@q3yi
q3yi / the_choosed_one.py
Created December 7, 2017 05:35
Who wanna to be the next?
import random
import operator
import argparse
from collections import defaultdict
def count(usernames, iter_times):
result = defaultdict(lambda: 0)
for _ in range(0, iter_times):
public class LineReader {
public static List<String> splitCSV(String str, char delimiter, char escape) {
boolean isClose = true;
boolean isEscaped = false;
List<String> result = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
for (char c : str.toCharArray()) {
if (c == delimiter) {
@q3yi
q3yi / LevenshteinDistance.js
Created March 26, 2015 03:40
Useful Algorithms
function levenshteinDistance(strA, strB) {
// Function to calculate levenshtein distance of two string
// Algorithm description: http://en.wikipedia.org/wiki/Levenshtein_distance
if (strA == strB) { return 0; }
if (!strA || !strB) { return strA.length || strB.length; }
var distance = [], lenA = strA.length, lenB = strB.length;
for (var i=0; i <= lenA; i++) { distance[i] = [i]; }