• 31 五月 2015

使用git reflog恢复由于reset丢掉的commit

上个星期的最后一个工作日,我的一个同事突然跟我说他丢掉了所有的前两天的工作,因为他使用了git reset命理到了一个之前的commit,而他本地新的工作并没有push到远程。在收到这个“噩耗”般的消息后,已经被多个事情需要在周末之前确定的我,一时心脏都快要停止跳动了(joking… ^_^) 。但是,我相信git的威力它一定有办法把这个东西恢复过来。确实,结果这个工作其实非常的容易:

      1. 首先,你必须没有跑过git的垃圾处理,”git gc”(这个我放心,估计我的同事连这个命令的存在都不知道),这样,所有那些于head脱离的处于悬吊状态(dangling)的commits都还没有消失。
      2. 运行,”git reflog” 命理 ( reflog 代表 reference log )。这将列出一系列历史的commits,包括它们的commit SHA1 ID 和一个commit的短消息。显示的这个commit的短消息非常有用,因为一般你不会记得你的commit的SHA1,但是你会认出你的commit的消息。
      3. 找到你需要恢复的commit的SHA1。比如,假设你需要恢复的commit的ID是 SHA33ddf。
      4. 运行命令 “git branch branchName SHA33ddf”,这将会创建一个新的分支并指向你的commit SHA1。你的工作就神奇般的恢复了!
      5. 最后一步可能是你需要设定你的新建的这个分支和远程相应地分支跟踪。假设你的远程源的名字是upstream,运行命令”git branch -u upstream/branchName branchName”。
  • 9 七月 2012

Redis内核概念

在Redis里的每一个东西都是用字符串表示的。即使像列表,集合,有序集合和图都是字符串的组合。Redis定义了一个特殊的结构,它调用一个叫”简单动态字符串”(Simple dynamic string, SDS)。这个结构有3个部分组成,分别是:

  • buff — 一个存储字符串的字符型数组
  • len — 一个长整型记录buff数组的长度
  • free — 可用的额外的字节数

虽然你会觉得分开地存储数组长度会造成额外的开销,因为这应该可以很容易地根据buff数组来计算出它的长度,但是这样做允许字符串长度的检索在固定的时间内完成。

Redis将它的数据集保存在主内存中,在需要的时候才持久性地写到磁盘上。不像MongoDB,它不使用内存映射文件来达到那个目的。确实,Redis实现有它自己的虚拟内存子系统。当一个数值被交换到硬盘时,一个指向那个硬盘页面的指针和它的键值一起存储。关于虚拟内存的技术文档,可以在此地址阅读http://code.google.com/p/redis/wiki/VirtualMemorySpecification.

除了虚拟内存管理,Redis还包含一个事件库以帮助协调非死锁(non-locking)的socket操作。
为什么Redis不依靠操作系统的虚拟内存的交换机制呢?

Redis不依赖操作系统的内存交换,因为:

  • Redis对象不能一对一地映射到交换虚拟内存的页面。交换页面是4,096字节长而Redis对象可以跨越一个以上的交换页面。类似地,一个以上的Redis对象也可能在一个交换页面上。所以,即使是一小部分Redis对象被访问,有可能涉及到很多个交换页面。是操作系统来监控交换页面的访问。所以,即使是在交换页面中的一个字节被访问,这都会将要移交到(操作系统的)交换系统。
  • 不像MongoDB, Redis数据格式在RAM中和在硬盘上是不一样的。在硬盘上的数据比它在内存中时要压缩了很多倍。这样,使用自实现的交换涉及到更少的磁盘I/O。

Salvatore Sanfillipo, Redis的作者,在他的博客中有谈到Redis的虚拟内存系统,“Redis Virtual Memory: the story and the code,” at http://antirez.com/post/redis-virtual-memory-story.html.

  • 5 六月 2011

HTML5的一个简单编码标准

这是一个简单的HTML5 编码标准:

  • 给<html>标签总是加上lang属性, 比如: <html lang=”en-US”>
  • 没有自我关闭的空标签了, 比如: 写<br> 而不是<br />
  • 不需要加style属性给外部css的连接或<script>标签, 比如:
    直接写<link media=”all” href=”_css/style.css” rel=”stylesheet”>
    或 <script src=”_js/calendar.js”></script>
  • 所有标签都必须是小写
  • 给所有的属性值加双引号
  • 对于逻辑值属性,直接写其属性名以声明它为真,而不需要同时写出他的属性名和属性值, 比如:
    写<section hidden>xxx</section> 而不是<section hidden=”hidden”>xxx</section>

你对这个标准怎么想? 🙂

  • 27 十一月 2009

Google Wave, got in

Recently, I received a friend’s invitation to Google Wave. This means, I will have the opportunity to invite others too. So, if you are interested, just send me a message, I will put you in my Nomination List ( I have 5 spots left ) 🙂 .

last comments
Creazione siti internet
Creazione siti internet

I would like to come with you but what the fact that I live in Italy?

  • 9 九月 2009

KPMRS – A new SEO tool, pretty good

Is today’s analytical service becoming more complex with irrelevant data? Here comes the pertinent solution entitled KPMRS.com, which is accomplished with packaged data and allows for the fundamental analysis of the performance of any website. It is a very ideal, rapid and useful keyword monitoring tool for the SEO Professionals, Website owners and Bloggers in the Internet Marketing arena. (more…)

last comments
Shaun
Shaun

Seems like Google will be running these companies out of business. I use Google Webmaster Tools to monitor keywords.
Kayla Hernandez
Kayla Hernandez

I am still a beginner in website SEO and i usually submit to website directories and article directories to boost…

  • 6 九月 2009

FreeGate, OpenVPN and Tor

For us in China these days, access internet is a tedious chore given the major web sites are blocked including Facebook, Twitter, Youtube and the popular Online TV network, TVU network. GFW (So called “”Great Fire Wall”) and the possible “Green Dam” in the future, the “Information control” is strong. Fortunately, there are ways to climb the “Wall”. Basically, as far as I know, there are three tools can do this. Most of users use FreeGate, a free proxy client to by pass the internet blocking; there are some other users use Tor Proxy, which is essentially the same proxy idea but target more technical savvy users. But, if you don’t know how to do it by now, there maybe some difficulties to get it to work; just trying to search “FreeGate” in Google and click any result url you will get a “connect reset” error. It seems they have blocked any “sensible keywords” appear in a url or a page. So, how do you get the tools at the first place? (more…)

last comments
al simpson
al simpson

Hi guys im looking into at getting a DTV4PC service that has been reviewed here at http://www.dtv4pcreview.co.uk and im wondering…
MathGeek
MathGeek

I would personally recommend OverPlay VPN just an amazing service overall, great support as well

  • 7 六月 2009

Define success, just to refresh your & my mind

Everybody want it, but few people actually get it.  Sucess, is a such troublesome word:  when it is ambiguous,  it makes me frustration, just to image only after a long time of hard work, you suddenly start to doubt  that what you were doing isn’t really what you want;  but when it is clear, I mean when it is made clear by others, parents, boss, friends and most importantly, the media,  it makes me angry,  because  your success can’t be defined by others! And it is certainly not just about fame and money. So, what is success? (more…)

  • 31 五月 2008

Use Writer, the online Darkroom version!

As a blogger, you probably already knew Darkroom, a minimalist full-screen text editor( inspired by the WriteRoom a similar processor offer on Mac OS). What’s good about Darkroom is that it forces your focus your writing content and nothing else. It has no window caption bar, status bar, menu bar, tool bar or window borders. Sitting on your screen nakely with its full dark background and green text, you will feel as if you are the famous hacker in “Matrix”. 🙂

While Darkroom can help your write better content, it is a desktop tool. And moreover, it is only available on Windows. For those like me use a *nix box, there is a Java-Version of Darkroom, JDarkRoom, which is still in beta. I tried install it on my OpenSUSE laptop, but it seems has some problems to start up.

So, here comes the Writer! A online clone of the Darkroom. (more…)

last comments
Chicago web designers
Chicago web designers

Hi, Creating content for the web isn’t easy, especially when there are so many tempting distractions. Hence…

  • 23 五月 2008

Learn to Design Web Themes and Templates with New Wiki

ThemesWiki.org is a new website designed to provide users with comprehensive, free guides for designing Web Themes and Templates. This site intends to ease the web design process by providing tutorials for a large number of systems at a common location.

It is often difficult to find a resource that is focused on providing quality, relevant and free information for designing themes and templates; specifically one that covers a wide range of applications. This is where ThemesWiki.org intends to step in. Launched initially with tutorials covering over 20 Content Management Systems, ThemesWiki.org is expected to grow into an exhaustive resource for the theming community, with users generating most of the content. (more…)

last comments ...
David Adam
David Adam

I have checked out the john chow theme and the blog. It is pretty good! I have encounter a…
Rhys Phillips
Rhys Phillips

i admire John Chow because of his innovative ways to gain traffic both from whitehat and greyhat methods.*-:
Tristan Coleman
Tristan Coleman

anyone who makes money on the internet would love to know the secret of John Chow's success..,:
Wall Heater :
Wall Heater :

john chow is still the king of blogging and he is still my idol~-"
Interactive Whiteboards
Interactive Whiteboards

John Chow is definitely my idol, i think that guy is extra-ordinary. he is really talented *",

  • 17 五月 2008

中国谷哥发布: 四川震区急需 260 万顶帐篷

First, here is the information on New York Time on how to help:
China Disaster Relief: How to Contribute
今天突然收到中国谷哥 Google China Adsense 发来的信息,以恳请广大 Adsense的发布商帮助发布四川震区求助信息。中国四川震区急需 260 万顶帐篷。这是信息原文:

今天早些时候,谷歌接到来自四川震区政府和摄制组的求助信息,由于一直下雨,绵阳北川地区的大量灾民情况非常堪忧,现在急需可以让灾民避雨的60万顶帐篷!根据下午四川政府最新发布的信息,全省急需帐篷总共260万顶!
(more…)

last comments
best business web site hosting
best business web site hosting

Great post ! I want to know when you update your blog, where can i subscribe to your blog? :)…