Skip to content

Instantly share code, notes, and snippets.

View liuxd's full-sized avatar
🗿
Hi, there.

Allen Liu liuxd

🗿
Hi, there.
  • Tax Traders
  • Auckland, New Zealand
View GitHub Profile
@liuxd
liuxd / content.md
Last active June 20, 2024 23:07
[#03 中文分词入门] #編程之道

中文分词入门

一、概述

分词,顾名思义,就是把一段文字划分成多个词的动作。它是自然语言处理的重要分支。分词的终极目标,是在尽可能短的时间里将一段文字分解成尽可能接近用户本意的多个词。

1. 流派

自然语言处理的发展史上曾经有两大流派:语法派,统计派。

@liuxd
liuxd / content.md
Last active June 20, 2024 23:07
[#05 Web系统中的密码] #編程之道

Web系统中的密码

密码,是敏感又重要的信息。对密码的处理是非常重要的。那么在web系统该如何处理密码呢?在下略有心得,备忘如下。

密码的轨迹

用户 => 应用服务器 => 数据库

从用户在客户端/浏览器输入密码到传输到应用服务器,再存储到数据库。有很多措施可以用来提高密码的安全性。

@liuxd
liuxd / content.md
Last active June 20, 2024 23:07
[#04 ssh问题集锦] #編程之道

ssh问题集锦

免密登录的两种方法

名门正派:公钥法

  1. 生成公钥密钥:ssh-keygen -t rsa
  2. .ssh/id_rsa.pub的内容拷贝到远端服务器的.ssh/authorized_keys里面。

这种方法属于名门正派的做法。因为别人可以查看authorized_keys得知你可以登录此机器,所以你得有登录此机器的合法身份,否则太容易暴露。

@liuxd
liuxd / content.md
Last active June 20, 2024 23:06
[#01 memcached原理与优化思路] #編程之道

memcached原理与优化思路

工作原理

基本概念:slab,page,chunk。

slab,是一个逻辑概念。它是在启动memcached实例的时候预处理好的,每个slab对应一个chunk size,也就是说不同slab有不同的chunk size。具体分配多少个slab由参数 -f (增长因子)和 -n (chunk最小尺寸)决定的。

page,可以理解为内存页。大小固定为1m。slab会在存储请求时向系统申请page,并将page按chunk size进行切割。

@liuxd
liuxd / content.md
Last active June 20, 2024 23:07
[#06 手机APP日志数据的收集] #編程之道

手机APP日志数据的收集

一、引言

收集日志并进行统计分析可以帮助改善产品甚至发现新的商机。但是移动APP的日志收集与Web应用不同。Web应用直接从服务器上拿访问日志就可以拿到很多东西,而APP不是一直连接网络的,所以日志的收集是需要另外设计一种可行的方案的。

二、思路

基本的思路就是APP在需要收集日志的地方请求API,从而达到收集日志的目的。

@liuxd
liuxd / addBusinessDays.php
Created April 26, 2018 23:46
[addBusinessDays]
<?php
function addBusinessDays($startDate, $businessDays)
{
$date = strtotime($startDate . ' + 1 day');
$i = 0;
while($i < $businessDays)
{
//get number of week day (1-7)
@liuxd
liuxd / get_checkbox_values.js
Last active July 20, 2021 22:29
[Get checkbox values] #jQuery
let PriceGroups = [];
$('input[name="price_group"]:checked').each(function(){
PriceGroups.push($(this).val());
});
@liuxd
liuxd / limit.sql
Last active August 28, 2019 04:19
[Offset, Limit] #MSSQL
# offset and limit. The query must be ordered.
SELECT * FROM Person.Person ORDER BY PersonID OFFSET 100 ROWS FETCH NEXT 5 ROWS ONLY;
@liuxd
liuxd / PostgreSQL.sql
Last active March 7, 2019 21:34
[PostgreSQL] #PostgreSQL
# Show processlist.
SELECT datid, datname, pid, usesysid, usename, query, backend_type FROM pg_stat_activity WHERE state = 'active'
@liuxd
liuxd / cli.sh
Created December 11, 2017 21:21
[Mac Command] #Mac
# check the interval of chrome updating checking. Unit is: second.
defaults read com.google.Keystone.Agent checkInterval
# stop automatic updating of chrome.
defaults write com.google.Keystone.Agent checkInterval 0