- 博客(18)
- 资源 (4)
- 收藏
- 关注
原创 Tomato设置局域网每IP最大连接数
将以下命令放在防火墙脚本中,其作用是将IP段为192.168.1.66-192.168.1.126之间的主机的总连接数限制在200个。并且将TCP 20-23,25,53,80,110,443和UDP 53端口排除。可能在Tomato中查看全局连接数会发现远远超过200个,这个并不是说iptables的设置没有生效,检验的办法就是将TCP的最大连接数设置为1,然后开始下载,这时应该是无
2013-08-25 10:22:56
3140
原创 公钥加密的简单理解和Java的keytool的用途
最近项目中要求实现通信信息加密。现在最流行的加密认证方案就是SSL/TLS了。但是且不说具体的加密算法,单用库实现这个加密流程就不是很容易。原因在于对非对称加密的不了解,或者对Java Keystore不了了解,并且网上找到的资料几乎清一色的都是教如何用keytool生成keystore,而不介绍生成的文件是什么。再者如果要结合Android或者iOS,就会出现更多问题。本文将会粗略的介绍非对称加
2013-07-19 09:00:26
1697
原创 Mac下GNU Emacs Dired中文乱码解决
如果用MacPorts安装GNU Emacs 24.3,就会有Dired乱码问题,无论怎么配置编码都将中文直接显示成Unicode编码。最近用MacPorts安装了GNU的coreutils,用GNU ls代替了Mac下BSD风格的ls后,意外发现Emacs不乱码了。也就是说之前的乱码是Mac的ls导致的。
2013-06-26 09:05:19
1725
原创 jedi实现Emacs下Python补全
最近学习Python,准备用Emacs作为编辑器,分享一下Emacs下Python补全的配置。Emacs下Python补全的方案有很多,网上流传最广泛的一种方案是用pymacs, rope, ropemacs和ropemode结合使用实现补全。这个配置起来非常繁琐,并且有人反应补全很慢,个人感觉这个配置现在是有些过时了的。下面介绍一下使用jedi补全。安装jedi可以通
2013-06-07 09:26:28
5182
原创 LeetCode: Pascal's Triangle II (返回杨辉三角形第i行)
杨辉三角形大家应该不陌生,其第i行恰好为 (a + b)i 的展开系数。比如上一道题的例子:[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]这道题要求直接返回第i行。题目描述为:Given an index k, return the kth row of the Pascal's triang
2013-05-28 05:49:47
8065
原创 LeetCode: Distinct Subsequences(不同子序列的个数)
题目描述:Given a string S and a string T, count the number of distinct subsequences ofT inS.A subsequence of a string is a new string which is formed from the original string by deleting some (can b
2013-05-27 05:55:39
21745
原创 LeetCode: Scramble String
题目描述:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \
2013-05-22 07:34:15
1632
原创 LeetCode: Largest Rectangle in Histogram(直方图最大面积)
具体的题目描述为:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram wher
2013-05-18 13:09:49
13486
原创 在Github上重命名仓库
1. 在本地仓库删除远程仓库:git remote rm origin2. 添加新的远程仓库:git remote add origin git@github.com:your_account_name/new_repo_name.git3. 修改Github仓库名称:在Github页面中,进入要修改的仓库,在页面上方选择“Settings”,即可重命名远程仓库
2013-05-16 03:01:15
6217
原创 LeetCode: Wildcard Matching (通配符匹配)
Implement wildcard pattern matching with support for'?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover
2013-04-30 06:00:50
1754
原创 LeetCode: Sudoku Solver (数独求解)
采用backtracking求解:首先找到一个需要求解的位置,对这个位置尝试求解,如果求解成功则返回,否则恢复这个位置之前的状态,退回一部,尝试其他数字。递归地调用这个过程进行求解。Java Code:public class Solution { public void solveSudoku(char[][] board) { // Start typing your
2013-04-23 04:46:14
1941
原创 LeetCode: Longest Valid Parentheses (求最长有效匹配括号子串的长度)
题目描述:Given a string containing just the characters'(' and')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is"()",
2013-04-20 02:29:04
6849
原创 Boggle单词游戏求解
基本思路就是对棋盘的深度优先搜索,并且根据单词表的前缀剪枝。即如果某个前缀在单词表中不存在,则此停止搜索。求解时间在1.5s左右。单词表来自:http://www.freebsd.org/cgi/cvsweb.cgi/src/share/dict/web2?rev=1.12;content-type=text%2Fplain单词索引利用Trie实现。Boggle主程序:
2013-04-08 08:54:25
2254
原创 Trie树的简单实现(Java版本)
Trie树的用途很多,可以实现根据前缀补全等功能。在一个国外的博客上看到这个Java实现,比较简洁,个人修改了一下,增加了根据前缀删除和遍历的功能。Trie树节点类定义:import java.util.*;/** * A Trie Node */class TrieNode { /** * The key stored in this
2013-03-30 12:06:31
1102
原创 求在m*n矩阵当中,从左上角出发到右下角有多少种方法
比如一个2*3的矩阵,1 2 34 5 6从1出发走到6,则可能的走法为:1 2 3 6, 1 2 5 6, 1 4 5 6共有三种。这道题可以看成是深度优先遍历一颗树。解法为:public class MatrixTraversal { public static int getTraversal(int p, int q) { int n
2013-03-30 10:21:16
5078
原创 求一个数字用其相同数字重新组合后下一个大的数字
比如63543,这个数包含6,3,5,4,3,将这些数字重新组合以后,产生下一个较大的数字,那么就是64335。这个问题在career cup上看到的,网上没有解答。想了一个办法,应该是没问题的。其实题目的描述就已经给出了一个解法,就是穷举法。比如输入数字为n,将这个数字每个位上的数字求出来,存在一个数组里,然后产生它的所有排列。那么时间复杂度就是O(n!)。空间复杂度为O
2013-03-30 10:09:53
2364
原创 再配置Linux字体
这个配置比较简单,全部使用开源字体,对字体的顺序进行调整,并且对常用的宋体等进行了替换。 serif DejaVu Serif Bitstream Vera Serif Droid Serif AR PL UMing CN AR PL UMing HK AR PL
2012-11-05 02:39:05
971
原创 开始使用优快云博客
以前一直使用新浪的博客发一些“技术”文章,现在觉得实在是不合适,连个语法高亮的功能都没有。以后有关此类文章都发到优快云上面了。
2012-11-05 02:36:00
553
模拟LINUX文件系统及终端
2009-03-01
SAMPLE (类pascal) 词法分析程序 C++版
2008-11-17
学生管理系统(控制台+链表+输入输出流)
2008-11-17
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人