- 博客(322)
- 收藏
- 关注

原创 ubuntu12.0.4安装samba服务器
ps:搞了两个多小时 终弄好了 1.Samba软件包的安装 在Ubuntu的终端中输入一下命令: sudo apt-get install samba 配置win7访问linux 第一步创建共享目录: 比如要创建/home/用户名/share首先创建这个文件夹 (这个用户名就是你的用户名,比如test) 代码:mkdir /home/用户名/share (新建share文件夹
2016-01-10 16:11:16
467
转载 关于单CPU,多CPU上的原子操作
所谓原子操作,就是”不可中断的一个或一系列操作” 。硬件级的原子操作: 在单处理器系统(UniProcessor)中,能够在单条指令中完成的操作都可以认为是” 原子操作”,因为中断只能发生于指令之间。 这也是某些CPU指令系统中引入了test_and_set、test_and_clear等指令用于临界资源互斥的原因。在对称多处理器(Symmetric Multi-Processor)结构中就不同了
2016-09-26 22:46:46
937
1
转载 如何在ubuntu提高jdk版本
The easy wayThe easiest way to install the JDK 7 is to do it with the Web Up8 Oracle Java OOS. However, it is believed that this PPA is sometimes out of date. Also note the dangers of using a PPA.This
2016-08-31 07:48:17
599
原创 epoll如何判断客户端不可读
客户端主动断开会触发EPOLLIN事件,判断recv返回值为0就表示断开连接;但是拔网线或者网络异常导致断开连接就没法判断了,应该可以在应用层通过heartbeat来判断连接是否失效。TCP keep-alive超时时间过长才认为是断开,实际项目中不会使用。
2016-07-02 23:14:52
664
原创 MarkDownPad私钥
Soar360@live.comGBPduHjWfJU1mZqcPM3BikjYKF6xKhlKIys3i1MU2eJHqWGImDHzWdD6xhMNLGVpbP2M5SN6bnxn2kSE8qHqNY5QaaRxmO3YSMHxlv2EYpjdwLcPwfeTG7kUdnhKE0vVy4RidP6Y2wZ0q74f47fzsZo45JE2hfQBFi2O9Jldjp1mW8HUpTtLA2a5/
2016-06-26 23:39:08
409
原创 探究Servlet Filter 执行顺序
这篇blog通过console打印出的信息来判断 servlet和filter的执行顺序 TestServlet.javapackage com.cakes;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.H
2016-06-06 22:32:22
5016
原创 第一个Java web项目
参考博客地址 http://www.thejavageek.com/2013/08/11/mvc-architecture-with-servlets-and-jsp/*.jsp创建在 WebContent路径下,访问时的Url为 http://localhost:8080/MVCDemo/login.jsp.在WebContent/WEB-INF下创建web.xml下面是代码 Lo
2016-06-05 23:00:47
1645
原创 Java中值传递与引用传递
//Test.javapublic class Test { public static void main(String[] args) { Person ps = new Person(); ps.setPerson(10,"yyy",new Address()); ps.printPerson(); Addres
2016-05-14 17:20:33
416
原创 71. Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example, path = “/home/”, => “/home” path = “/a/./b/../../c/”, => “/c” click to show corner cases.Corner Cases: Did you consider the
2016-03-30 21:54:12
408
原创 44. 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 t
2016-03-28 20:54:28
606
原创 关于TCP协议收到数据不完整
发送方 调用send函数的时候,做的操作实际上是把你给出的数据拷贝的系统的缓存中,然后等待系统发送,send函数的返回值就是实际拷贝进入系统缓存中的数据的大小,这个大小有可能小于你给定的数据大小,所以可能需要多次调用。 接收方 调用recv函数的时候,和send很类似,是把系统缓存中已经接收到的数据,拷贝到你给出的缓存中,recv的返回值就是实际从系统缓存中拷贝出来的数据的大小。在实际的网络传
2016-03-22 09:45:23
6870
原创 160. Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘
2016-03-10 16:54:18
345
原创 191. Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 0000000000000
2016-03-10 15:42:15
290
原创 世界是数字的(三)
互联网互联网并不是一个巨型网络,更不是一台计算机。他由定义了网络和其中的计算机相互通信规则的标准连接在一起,是一个松散的、非结构化的、混乱、自组织的网络集合如何才能把光纤网、以太网、无线网等不同的物理属性的网络连接起来,甚至比他们之间相隔很远时也能联通?我们需要在间接相连的网络之间找到通信路径,需要就信息采用何种格式传输达成协议,需要在错误处理、时延、过载等一些不太容易想到的问题上达成协议。没有这些
2015-12-30 14:34:27
522
原创 世界是数字的(二)
网络带宽是最基本的一个特性,他描述的是通信系统的传输数据的速度。延迟衡量的是特定信息块通过系统所需要的时间。抖动,即延迟的可变性。信程指的是某种技术能够在多大的地理范围内实现联网。在家庭中,电话系统传送模拟的声音信号,不传送数据。因此,必须有一种设备来实现数字化信息和模拟的声音之间的转换,才能利用电话网络传输数据。改变通过声音信号传输的信息形式叫调制。相反,把这种形式再转换成比特叫解调。最大带宽不过
2015-12-29 15:42:35
471
原创 世界是数字的(一)
操作系统怎么工作标签(空格分隔): 操作系统操作系统控制和分配计算机资源。首先,它负责管理CPU,调度和协调当前运行的程 序。它控制CPU 在任意时刻执行的程序,包括应用程序和后台进程(如杀毒软件和 检查更新的程序)。它会将一个暂时等待的程序(比如等待用户在上面单击的对话框) 挂起。它会阻止个别程序多占资源。如果一个程序占用CPU 时间太多,操作系统会 强行将其中断以便其他任务得以正常执行。
2015-12-29 00:57:00
704
原创 225. Implement Stack using Queues
Implement the following operations of a stack using queues.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. empty() – Return whether
2015-12-24 17:26:59
381
原创 232. Implement Queue using Stacks
Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue. pop() – Removes the element from in front of queue. peek() – Get the front element. empty()
2015-12-23 22:00:14
326
原创 155. Min Stack
Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top()
2015-12-23 16:46:40
411
原创 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value
2015-12-23 10:35:37
288
原创 数组名与指针
char ga[] = "aaa";int main(int argc, char** argv){ printf("addr of global array = %#x \n", ga); printf("addr of global array = %#x \n", &ga); return 0;}addr of global array = 0x804c07c
2015-12-06 15:43:25
365
转载 shared_from_this
转载自http://blog.youkuaiyun.com/salutlu/article/details/12515877陈硕的muduo代码库的里面的TcpConnection用到了enable_shared_from_this这个基类,今天查了一下,这个基类提供了一个shared_from_this()公用方法可以让子类内部获取到shared_ptr的对象,用来用在类实现过程中需要传递自身指针的地方
2015-11-07 19:16:34
572
原创 Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's.1 3 3 2 1\ / / / \ \3 2 1 1 3 2/
2015-11-02 10:51:07
328
原创 Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.关键思路:最短的含叶子节点子树,考虑如何缓存树的高度/** * D
2015-10-31 00:33:47
312
原创 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
2015-10-30 14:39:34
350
转载 gdb寻找死锁
据说再高的高手在写多线程程序的时候都难确保不会产生死锁,死锁的调试也就成为一个比较常见的问题,假设有下面这样一个问题: 一个正在生产环境下运行的进程死锁了,或者你只是在跑一个程序,并没有在调试器里面打开它,然后发现没有响应,日志输出也停止了。由于你是一个有经验的程序员,会想到“我刚刚加上了新的锁策略,不一定稳定,这可能是死锁了“。但是你不想就这么杀掉进程,因为多线程的 bug 不容易重现
2015-10-29 21:01:38
1344
原创 一个数组a[0...n-1],求a[j]-a[i]的最大值,其中i<j
其中数组a[n]是无序的,求a[j]-a[i]的最大值,且i第一种方法:从左往右求下标0到 k - 1 的最小值MIN从右往左求 下标k到n -1 的最大值MAX对于每个k都有一个MAX - MIN的值,最后求这个值的最大值即可。例如数组:4 5 2 6 3 1K:1 2 3 4 5MIN: 4 4 2 2 2MAX:6 6 6 3 1MAX - MIN,最
2015-10-29 19:32:42
2907
原创 Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algorithm should
2015-10-29 00:59:32
295
原创 Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in ea
2015-10-29 00:30:56
318
原创 Peeking Iterator
Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the element that will be retu
2015-10-29 00:18:15
330
原创 给一个数轴,包括正无穷和负无穷,从原点0开始向目标位置x走动(x为整数),第i步,步长为i,求到x的最少步数
给一个数轴,包括正无穷和负无穷,从原点0开始向目标位置x走动(x为整数),第i步,步长为i(可以正向,也可以负向),如 从0 开始,目标地址为3,中途经过(0 ,1),(1 , 3).如果目标地址是2 中途经过(0, 1)(1, -1)(-1, 2),问从0到x的最短路径
2015-10-28 21:12:57
1713
原创 Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return
2015-10-28 17:44:52
404
原创 Game of Life
According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board with m by
2015-10-28 00:05:27
319
原创 Ugly Number
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since
2015-10-27 16:04:17
285
原创 Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one
2015-10-27 15:54:35
266
原创 Basic Calculator
Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty
2015-10-23 22:02:42
370
原创 Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may ass
2015-10-23 14:12:54
304
原创 给定一个无序数组,请调整该数组,调整成奇数放在数组的左边,偶数放在数组的右边。但是奇数与奇数之间的相对顺序不变,偶数和偶数之间的相对顺序也不变。
给定一个无序数组,请调整该数组,调整成奇数放在数组的左边,偶数放在数组的右边。但是奇数与奇数之间的相对顺序不变,偶数和偶数之间的相对顺序也不变。要求思考:如果额外空间复杂度必须为O(1),时间复杂度可以做到什么程度呢?这个题,要保证额外空间复杂度为o(1)的情况下,时间复杂度只能做到o(n^2) ,利用快排思想并不能保证稳定性,利用归并思想做不到常量空间
2015-10-23 13:50:50
1213
原创 满足条件的周长最短的三条边
1.已知一个数组,从数组中取三个数a , b , c满足 a b c可以构成一个三角形,找出 a + b + c最大的三个数,要求时间复杂度为O(nlgn)算法思路:(1)先将数组排序(nlgn)(2)从数组最后一个元素开始,向前遍历,如果 a + b > c, 则即为所求,(3)否则 以倒数第二个元素为最大边( 注a b不再向前滑动,因为 前面的元素更不可能满足构成三角形条件),
2015-10-21 23:15:28
591
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人