• 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>

你对这个标准怎么想? 🙂

  • 1 十二月 2009

Get Start a new eZ Publish project – Part II

In the part I, we started create the siteaccesses and set all the configuration values for the siteaccesses to work correctly. However, there are still other things to do, such as set up and configure the site design and svn version control tool for the project. So, let’s continue. (more…)

last comments
Jeanelle Stanzione
Jeanelle Stanzione

Amazing Dude, that is extremely good information, thankyou.

  • 29 十一月 2009

Get Start a new eZ Publish project – Part I

In the past, I wrote a post briefly introduced the eZ Publish CMS. In these two series post, I will get into the technical details on how to actually start a new eZ Publish project. We are going to set up a starting point of eZ Publish project, named “Multiline”. This project will contain two independent web sites under the same installation. The two web sites, one of which will be accessed via a single domain with language switch between French and English, and another will accessed by a different domain with only the French language available. At the end of this article, you will learn how to get eZ Publish ready for different projects requirements, include: multi-sites, multi-language, different access method and SVN integration. (more…)

last comments
Robin Muilwijk
Robin Muilwijk

Hi, This is a very informative post, very helpful, thanks for writing it. Hope you will post…
Antoine Dubois
Antoine Dubois

Hi, Thanks for this article, very interesting and to the point when beginning with ez publish.…
David Adam
David Adam

Hi. yeah! That is the case for me too. We anonymous Role policies has to be changed if you have…

  • 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…

  • 7 九月 2009

Mysql client uses older authentication method in PHP 5.3 on windows?

Just found out the if I use PHP5.3 on windows, I can’t connect to my Mysql5 server. It says my client is too old. After I switch back to PHP5.2.9, things get normal. So, it means the PHP5.3 for windows used a older version of library to compile the code? I don’t know. It took me a while to find out the problem.

  • 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…)