Skip to content

Instantly share code, notes, and snippets.

@lmh3
lmh3 / 132Pattern.java
Last active April 12, 2017 03:29
132Pattern
/**
* https://leetcode.com/problems/132-pattern/
*
* @param nums 数字数组
* @return boolean
*/
boolean find132pattern(int[] nums) {
int s3 = Integer.MIN_VALUE;
Stack<Integer> stack = new Stack<>();
for (int i = nums.length - 1; i >= 0; i--) {
@lmh3
lmh3 / ThriftPythonClient.py
Created November 23, 2016 09:27
thrift client of python
#coding=utf-8
import sys
import glob
sys.path.append('gen-py')
from service import *
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
@lmh3
lmh3 / networkTool.sh
Created November 22, 2016 09:47
查看Mac端口号
netstat -an | grep 3306
lsof -i:80
@lmh3
lmh3 / map.json
Last active November 17, 2016 12:03
GeoJSON
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lmh3
lmh3 / vimrc
Created November 17, 2016 04:06
Vim Config File
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ~/.vimrc "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
syntax enable
set background=dark
colorscheme solarized
filetype plugin indent on
@lmh3
lmh3 / convertSemiangle.php
Created November 17, 2016 03:59
switch character from SBC case To DBC case 全角字符转换为半角字符
<?php
/**
* 将一个字串中含有全角的数字字符、字母、空格或'%+-()'字符转换为相应半角字符
*
* @param string $str 待转换字串
*
* @return string
*/
function convertSemiangle($str){
@lmh3
lmh3 / getLevenshteinDistance.java
Created November 17, 2016 03:39
getLevenshteinDistance 字符串编辑距离
public static int getLevenshteinDistance(String s, String t) {
if (s == null || t == null) {
throw new IllegalArgumentException("Strings must not be null");
}
int n = s.length(); // length of s
int m = t.length(); // length of t
if (n == 0) {
return m;
} else if (m == 0) {
@lmh3
lmh3 / validateRegistrationLicense.php
Created November 17, 2016 03:17
validate business license code 验证15位营业执照注册号
<?php
/**
* 验证15位营业执照注册号
*
* @param string $code 资质编号
*
* @return boolean
*/
function validateRegistrationLicense($code)
{
@lmh3
lmh3 / validateUSCCLicense.php
Last active November 17, 2016 02:57
validate Unified Social Credit Code 验证统一社会信用代码
<?php
/**
* 验证统一社会信用代码
*
* @param string code 统一社会信用代码
*
* @return boolean
*/
function validateUSCCLicense($code)
{
@lmh3
lmh3 / validateChinaMainlandIDCard.php
Last active November 17, 2016 03:31
validate China Mainland ID Card 验证大陆身份证号码
<?php
/**
* 验证大陆身份证号码
*
* @param string code 身份证号码
*
* @return boolean
*/
function validateChinaMainlandIDCard($code)
{