Skip to content

Instantly share code, notes, and snippets.

@yydai
yydai / dawg.py
Created Sep 2, 2019 — forked from smhanov/dawg.py
Use a DAWG as a map
View dawg.py
#!/usr/bin/python3
# By Steve Hanov, 2011. Released to the public domain.
# Please see http://stevehanov.ca/blog/index.php?id=115 for the accompanying article.
#
# Based on Daciuk, Jan, et al. "Incremental construction of minimal acyclic finite-state automata."
# Computational linguistics 26.1 (2000): 3-16.
#
# Updated 2014 to use DAWG as a mapping; see
# Kowaltowski, T.; CL. Lucchesi (1993), "Applications of finite automata representing large vocabularies",
# Software-Practice and Experience 1993
View hive-udf-adjacent-chars-checker.java
import org.apache.hadoop.hive.ql.exec.UDF;
public class CheckSwapCharsUDF extends UDF {
public Integer evaluate(String str1, String str2) throws Exception {
if (str1 == null || str2 == null)
return -1;
int s1_len = str1.length();
int s2_len = str2.length();
if (s1_len != s2_len)
return -1;
@yydai
yydai / java01.java
Created Aug 22, 2019
java snippets
View java01.java
// drop the duplicate values
Set<String> set = new HashSet<>(fullMatch);
fullMatch.clear();
fullMatch.addAll(set);
@yydai
yydai / install.sh
Last active Aug 18, 2019
linux env setup
View install.sh
# install emacs
sudo add-apt-repository ppa:ubuntu-elisp/ppa
sudo apt update
sudo apt install emacs-snapshot emacs-snapshot-el
# install gnome-tweak-tool
sudo apt-get install gnome-tweak-tool
# install pip3
sudo apt install python3-pip
@yydai
yydai / linux_backup.org
Created Aug 7, 2019
ubuntu 系统备份
View linux_backup.org

https://zhuanlan.zhihu.com/p/51827233

tar -cvpzf /media/ubuntu_backup@`date +%Y-%m+%d`.tar.gz –exclude=/proc –exclude=/tmp –exclude=/home/yingdai/Workspace/Qunar/Gitlab/h_xsearch –exclude=/lost+found –exclude=/media –exclude=/mnt –exclude=/run /

tar -xvpzf /media/ubuntu_backup@2016-6-6.tar.gz -C /

@yydai
yydai / linux_disk.org
Created Aug 7, 2019
Linux disk 相关
View linux_disk.org

查看文件大小

du -sh * / du -sh <filename>

查看目录中的文件大小

du -h –max-depth=1 <folder>

View latex-example.tex
% ==== Document Class & Packages =====
\documentclass[12pt,hidelinks]{article}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage{tocloft}
\usepackage{charter}
\usepackage[many]{tcolorbox}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{xcolor}
@yydai
yydai / trie-spellcheck-autocomplete.cpp
Created Jun 4, 2018
使用trie进行补全和检查错误。
View trie-spellcheck-autocomplete.cpp
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#define N 256
using namespace std;
struct TreeNode {
bool isEnd;
View plot1.py
import matplotlib.pyplot as plt
x = np.linspace(-5, 5, 200) # x data, shape=(100, 1)
y1 = 2 * x #...
y2 = x ** 2 + 2
y3 = sin(x)
plt.figure(1, figsize=(8, 6))
plt.subplot(221)
View python-tools.md