Skip to content

Instantly share code, notes, and snippets.

View badbye's full-sized avatar
Dreaming

yalei badbye

Dreaming
  • China
View GitHub Profile
# encoding: utf8
"""
Created on 2017.10.24
@author: yalei
"""
import numpy as np
@badbye
badbye / zsh_config.sh
Last active September 16, 2017 04:21
Script for configure oh-my-zsh & imgcat & autojump, support ubuntu and centos.
# 0. system: ubuntu or centos?
if [ $UID -ne 0 ]
then
echo "Error: must be root to run this script."
exit -1
fi
is_ubuntu=(` cat /etc/issue | grep -i ubuntu `)
password=$1
# 1. zsh
@badbye
badbye / fulanhua.py
Created August 17, 2017 06:00
普通话 转 弗兰话(湖南话)
# encoding: utf8
"""
Created on 2017.08.17
@author: yalei
"""
from __future__ import unicode_literals
@badbye
badbye / HorseRun.java
Created July 6, 2017 23:52
Horse Run: The shortest path from one start point to the end point.
import edu.princeton.cs.algs4.MinPQ;
import edu.princeton.cs.algs4.Stack;
import edu.princeton.cs.algs4.StdIn;
import edu.princeton.cs.algs4.StdOut;
public class HorseRun{
private int n = 10;
private int count;
private Stack<Point> road;
@badbye
badbye / check_email.py
Last active July 8, 2020 09:32
Check the validation of an email
# encoding: utf8
"""
Created on 2017.06.27
@author: yalei
Reference:
1. http://www.ruanyifeng.com/blog/2017/06/smtp-protocol.html
2. http://blog.online-domain-tools.com/2014/11/14/how-to-verify-email-address/
@badbye
badbye / benchmark.R
Created June 2, 2017 16:28
Benchmark of R's http framework
microbenchmark:::microbenchmark(system('curl http://127.0.0.1:9123/predict?val=190'))
microbenchmark:::microbenchmark(system('curl http://127.0.0.1:9124/predict?val=190'))
@badbye
badbye / hmm.py
Created March 7, 2017 03:10
HMM中文分词
# encoding: utf8
"""
Created on 2017.03.06
@author: yalei
"""
import itertools
@badbye
badbye / better_test_arg.py
Created January 21, 2017 12:24
Elegent magic
# encoding: utf8
"""
Created on 2017.01.21
@author: yalei
"""
import inspect
import re
@badbye
badbye / test_arg.py
Created January 21, 2017 12:07
Magic: extract arguments from function
# encoding: utf8
"""
Created on 2017.01.21
@author: yalei
"""
import sys
import traceback
@badbye
badbye / scope.py
Created January 6, 2017 06:25
how `local()` works?
>>> def f():
... a = 1
... locals()['a'] = 123
... print locals()
...
>>> f()
{'a': 1}
>>> def f():
... locals()['a'] = 123
... print locals()