哈希表和哈希函数是大学数据结构中的课程,实际开发中我们经常用到Hashtable这种结构,当遇到键-值对存储,采用Hashtable比ArrayList查找的性能高。为什么呢?我们在享受高性能的同时,需要付出什么代价(这几天看红顶商人胡雪岩,经典台词:在你享受这之前,必须受别人吃不了的苦,忍受别人受不了的屈辱),那么使用Hashtable是否就是一桩无本万利的买卖呢?就此疑问,做以下分析,希望能抛砖引玉。

阅读全文

据国外媒体报道,从今天开始在谷歌Android平台下开发的应用在PC上也可以运行,程序也可为这些计算机,这只需通过专为 PC 提供的最新 BlueStacks App Player 即可实现。

近几年,Android逐渐成为市场上领先的移动操作系统,在过去3个月购买智能手机的用户中,约一半都选择的是Android系统。与此同时, 为这些Android用户提供的应用以及游戏的数量也呈上升趋势,据谷歌证实目前两者的量已达25万。从今天开始,众多的应用程序和游戏对于 Android和非Android用户都可适用。

阅读全文

此原文来自谷歌工程师Steve Yegge的google+

Stevey’s Google Platforms Rant

I was at Amazon for about six and a half years, and now I’ve been at Google for that long. One thing that struck me immediately about the two companies — an impression that has been reinforced almost daily — is that Amazon does everything wrong, and Google does everything right. Sure, it’s a sweeping generalization, but a surprisingly accurate one. It’s pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn’t let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon’s recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they’ve made to level it out. And their operations are a mess; they don’t really have SREs and they make engineers pretty much do everything, which leaves almost no time for coding – though again this varies by group, so it’s luck of the draw. They don’t give a single shit about charity or helping the needy or community contributions or anything like that. Never comes up there, except maybe to laugh about it. Their facilities are dirt-smeared cube farms without a dime spent on decor or common meeting areas. Their pay and benefits suck, although much less so lately due to local competition from Google and Facebook. But they don’t have any of our perks or extras — they just try to match the offer-letter numbers, and that’s the end of it. Their code base is a disaster, with no engineering standards whatsoever except what individual teams choose to put in place.

阅读全文

Select在Socket编程中还是比较重要的,可是对于初学Socket的人来说都不太爱用Select写程序,他们只是习惯写诸如connect、accept、recv或recvfrom这样的阻塞程序(所谓阻塞方式block,顾名思义,就是进程或是线程执行到这些函数时必须等待某个事件的发生,如果事件没有发生,进程或线程就被阻塞,函数不能立即返回)。可是使用Select就可以完成非阻塞(所谓非阻塞方式non-block,就是进程或线程执行此函数时不必非要等待事件的发生,一旦执行肯定返回,以返回值的不同来反映函数的执行情况,如果事件发生则与阻塞方式相同,若事件没有发生则返回一个代码来告知事件未发生,而进程或线程继续执行,所以效率较高)方式工作的程序,它能够监视我们需要监视的文件描述符的变化情况——读写或是异常。下面详细介绍一下!

Select的函数格式(我所说的是Unix系统下的伯克利socket编程,和windows下的有区别,一会儿说明):

先说明两个结构体:

第一,struct fd_set可以理解为一个集合,这个集合中存放的是文件描述符(file descriptor),即文件句柄,这可以是我们所说的普通意义的文件,当然Unix下任何设备、管道、FIFO等都是文件形式,全部包括在内,所以毫无疑问一个socket就是一个文件,socket句柄就是一个文件描述符。fd_set集合可以通过一些宏由人为来操作,比如清空集合FD_ZERO(fd_set *),将一个给定的文件描述符加入集合之中FD_SET(int ,fd_set *),将一个给定的文件描述符从集合中删除FD_CLR(int ,fd_set*),检查集合中指定的文件描述符是否可以读写FD_ISSET(int ,fd_set* )。一会儿举例说明。

第二,struct timeval是一个大家常用的结构,用来代表时间值,有两个成员,一个是秒数,另一个是毫秒数。

阅读全文

IndentationError: unindent does not match any outer indentation level

出现这个问题,基本都是由于缩进问题,尤其发生在你拷贝别人的源码并进行修改、或者拷贝几个不同的源码拷到一块修改进行调式的时候容易遇到,可能因为每个人写程序的缩进可能不一样,有的是tab,有的是空格,这用肉眼很难察觉。解决办法就是把缩进都改为同一种格式即可。

阅读全文

新浪科技讯 北京时间10月7日晚间消息,谷歌周五为Chrome浏览器发布了新的扩展“Chrome远程桌面”(Chrome Remote Desktop)测试版,允许用户远程控制网络上的其他计算机。

Chrome远程桌面相当于基于浏览器的远程桌面软件,无论是对于IT管理员还是计算机用户,该扩展极其实用、方便,可远程控制另一台计算机。

谷歌称:“Chrome远程桌面测试版允许用户通过Chrome浏览器或Chromebook笔记本远程访问另一台计算机,而且该扩展可跨平台,可以在Windows、Linux和Mac等系统下连接任意两台计算机。”

要使用该功能,用户首先要允许计算机进行或被远程访问。谷歌同时指出,该技术目前具有一定限制,即每次远程访问时都需要授权。谷歌称:“该版本允许用户进行或被远程访问,但需要提供一次性验证码。整个访问过程十分安全。”

阅读全文

作者的图片

DigDeeply

Technology Stack: Golang/PHP/Openresty, and so on…

Web Development Engineer

Beijing China