2015-05-24
Recovering Code from a Damaged Git Repository

Background: Virtualbox virtual machine on Windows. Ubuntu 14.04.1 LTS, 3.13 kernel. ext4 file system.

Mistake: A few days ago, I was developing a website on this virtual machine, made N commits, thought I had git pushed, but in fact, the push failed.

Mystery: Today, my colleague git pulled and found no updates, then said I hadn’t been working these days.

Tragedy: Logged into the virtual machine and saw that a few newly written files in the project directory had become 0-byte empty files. (ext4 is so stable, it must be the evil NTFS and Virtualbox in the host machine that caused the trouble)
Many files in the .git directory also became 0-byte empty files. Git prompts that the repository is damaged.

1
2
3
4
$ git status
error: object file .git/objects/71/cbcbbc9d06a74f2fd8ea9109b81b88086f1430 is empty
error: object file .git/objects/71/cbcbbc9d06a74f2fd8ea9109b81b88086f1430 is empty
fatal: loose object 71cbcbbc9d06a74f2fd8ea9109b81b88086f1430 (stored in .git/objects/71/cbcbbc9d06a74f2fd8ea9109b81b88086f1430) is corrupt
1
2
3
4
$ git fsck
error: object file .git/objects/00/837a7e1f8afb8da8609369f7acf95fe9b7fc5b is empty
error: object file .git/objects/00/837a7e1f8afb8da8609369f7acf95fe9b7fc5b is empty
fatal: loose object 00837a7e1f8afb8da8609369f7acf95fe9b7fc5b (stored in .git/objects/00/837a7e1f8afb8da8609369f7acf95fe9b7fc5b) is corrupt

Has the code written in the past few days just vanished like this? We know that when you delete something, you just delete the reference to this thing in the current three-dimensional space, and the entity of this thing still exists in the four-dimensional space-time. Let’s time travel!

Read More

2015-01-30
Travelogue of Huangshan

January 30, 2015, was the deadline for SIGCOMM 2015 paper submissions, but I went to Huangshan for a trip. IMG_20150130_083809IMG_20150130_083809

Preparations Before Departure {/examples/}

It was our first time going to Huangshan. As early as December 15, when our final exam schedule was confirmed, we started preparing.

Time {/examples/}

We set off the day after my final exams ended. After checking some travel guides, we found that Huangshan is suitable for a two-day trip, with one night spent on the mountain. Including the round trip to Hefei, it would take a total of four days.

Transportation {/examples/}

There are two routes from Hefei to Huangshan:

  1. Take a train to Huangshan Railway Station (located in Tunxi, Huangshan City), then take a one-hour bus to Tangkou Town at the foot of Huangshan.
  2. Take a direct bus from Hefei Long-Distance Bus Station to Tangkou Town at the foot of Huangshan.
    After arriving at Tangkou Town at the foot of Huangshan, to enter the Huangshan Scenic Area, you can only take the Xin Guoxian bus, which costs 19 yuan per person. The bus ride is a 20-minute winding mountain road, about 10 kilometers. The bus goes in two directions, one to Ciguang Pavilion at the front mountain and one to Yungu Temple at the back mountain. Both Ciguang Pavilion and Yungu Temple have cable cars to go up the mountain, or you can hike up (about 5 kilometers, taking 3 hours). Currently, the cable car at the front mountain is closed for maintenance, and hiking up is too tiring, so tourists usually go up from the back mountain, stay overnight on the mountain, and descend from the front mountain.

Since Jingning gets carsick and can’t sit on a bus for long periods, we chose the train-then-bus option. Currently, there are only K-series trains from Hefei to Huangshan, taking 6-7 hours (high-speed trains will be available this year). Although train tickets from Hefei to Huangshan are not in high demand during winter, we still booked our tickets a month in advance.

Buses within Huangshan City and the Huangshan Scenic Area run every half hour, and reservations are neither needed nor possible.

Accommodation {/examples/}

For the two nights at the foot of the mountain, you can choose to stay in Huangshan City or at the foot of the mountain. Accommodation on the mountain is relatively tight and needs to be booked in advance. You can do this on Ctrip.

Gear {/examples/}

  • Documents: ID card, student ID
  • Electronics: Mobile phone, iPad, power bank, flashlight (bought from Taobao, but didn’t use it)
  • Warm clothing: Scarf, gloves, hat, seat cushion (Huangshan is very cold in winter)
  • Climbing aids:
  • Clothing: Each person brings 2 pairs of socks, underwear, towel for bathing
  • Toiletries: Toothbrush, toothpaste, cup, lip balm, hand cream, skincare products…

January 28 {/examples/}

 

Read More

2015-01-07
Blog Enabled New Domain ring0.me

On May 16, 2013, my blog got a top-level domain bojieli.com. On January 6, 2015, I registered and enabled a new domain ring0.me (it’s the number 0, the font looks like the letter O).

Ring0 is the highest privilege level in the CPU architecture, and the code running at the Ring0 level interacts directly with the physical hardware. The concept of privilege level can be traced back to MULTICS in the 1960s. In the x86 architecture, ring0 represents the operating system kernel and kernel drivers, as opposed to user-mode applications that usually run in ring 3. The first time I heard about ring0 was in an article about rootkits when I was in junior high school and was very curious about “hacker” technology. Shamefully, I still can’t write a rootkit.

My blog uses the domain ring0.me to show that my main interest is in building the foundation of computer systems and networks through research and technology.

Registering ring0.me was because I felt that the full-spelled domain name bojieli.com didn’t look geeky enough. I considered multiple unregistered domain names such as rdma, ssh22, http80, tcp80, printk, reisub, etc., but in the end, I still thought ring0 was better.

The original bojieli.com has already HTTP 301 redirected to the corresponding page of ring0.me. Due to the policy restrictions of StartSSL, SSL certificates can only be applied for three days after domain registration.Deployed the SSL certificate on January 17.bojieli.com will continue to serve until May 2016, and will not be renewed afterwards.

The blog title has been changed from “null != undefined” to “Ring0”, and the subtitle has been changed from “Seeking possibility for next-generation network” to “Fundamental research in networked systems”. Hope readers like it ^_^

Read More

2014-12-18
My Year at MSRA

One afternoon in May 2013, Room 5005 of the Physics and Chemistry Building. I was holding Senior He Yu’s phone, calling Lu Yuanwei, who was in a joint training program at MSRA. Maybe I was too nervous; after the call, both the screen and my hand were covered in sweat. A few days earlier, I received a notification: I was admitted to the MSRA joint training program. I replied that I was working on a startup project and might not have time to go. Microsoft urged me to make a decision quickly. I originally wanted to decline on my own, but I thought I should listen to Boss He’s opinion.

Background: The joint training program between USTC and MSRA opens for applications every April. After resume screening and interviews, about 18 people are admitted. They intern at MSRA for their senior year, and their thesis is also done at MSRA. Among these 18 spots, 14 are for those who will continue their studies domestically, and the remaining 4 are for those going abroad or seeking employment. After two months of internship, around early September, about 7 out of the 14 will be selected to stay for a Ph.D., while the rest return to school for their master’s. The so-called joint training Ph.D. means the first year is spent taking classes at USTC, and the next four years are spent doing research at MSRA, ultimately earning a degree from USTC (so we are genuine USTC graduate students, not trainees).

Both Lu Yuanwei and Senior He Yu said it was a good opportunity and suggested I consider it carefully. I thought I would intern for a summer first, see how it goes, and then decide.

At that time, I was deeply influenced by the culture of Linux and free software and had quite a few prejudices against Microsoft. When HR called to confirm my “start date,” I asked why it was called “start date.” Only then did I realize I was going as an intern for joint training, and it felt awkward to become an employee of a company I didn’t like at the time.

Read More

2014-12-12
Reading Notes on 'The Self-Cultivation of Programmers'

Here is an old article: reading notes written in June 2012 (original link). These notes were written for my own reference, and they contain many of my own ideas, which may mislead readers. However, the article is too long, and I don’t have time to revise it. Feel free to criticize.

Recently (in the first half of 2012), under the recommendation of Jiahua Guo, I read the book “The Self-Cultivation of Programmers - Linking, Loading, and Libraries” from the LUG library, and I felt like I had found a treasure. However, the final exams are approaching, and I don’t have time to finish the whole book, so I only wrote a part of it.

There are two ways to build software: one is to make it so simple that there are obviously no defects, and the other is to make it so complicated that there are no obvious defects; the former is much more difficult.

——Hoare in the Turing Award speech “The Emperor’s Old Clothes”

Read More

2014-12-10
Overview of Virtualization Technology

Note: On November 21, 2014, I shared some of my insights on virtualization technology at the Alibaba Tech Club’s Virtualization Technology Exchange and “USTC Cloud 3.0” launch event. After organizing and supplementing, I discuss with you. (Long text, enter with caution)

Everyone is familiar with virtualization technology, most of us have used virtual machine software such as VMWare, VirtualBox. Some people think that virtualization technology has only become popular in recent years with the trend of cloud computing, and ten years ago it was just a toy for desktop users to test other operating systems. Not really. As long as multiple tasks are running on the computer at the same time, there will be a demand for task isolation, and virtualization is the technology that makes each task appear to monopolize the entire computer and isolate the impact between tasks. As early as the 1960s when computers were still huge, virtualization technology began to develop.

IBM 7044

Read More

2014-11-28
Advice for Graduate Students from Internet Authority Professor Jennifer Rexford

Translator’s note: Jennifer Rexford is a professor at Princeton University and a leading figure in the field of network research. She gave a talk to new graduate students in the field of engineering in 2010: Advice for New Graduates.

Those who know me know that I have a hobby of collecting famous quotes. A sentence explains the story behind this: famous quotes are short and portable, which is a suitable hobby for me who often moved when I was a child. Two famous scientists from Princeton in the 1930s, Einstein and Thomas Lewis, made interesting and somewhat opposing comments on the role of the “individual”.

Einstein in the field of physics said: “All valuable things in human society depend on the opportunity for individual development.”

Thomas Lewis in the field of pharmacology and biology said, “In fact, there is no such thing as a single individual; his own life is not much more than a cell torn from the surface of the skin.”

These two quotes summarize well what graduate students do.

Read More

2014-11-25
The Big Talk on Synchronous/Asynchronous, Blocking/Non-blocking

Many people are confused about the difference between these two sets of concepts. Let’s use the example of Xiao Ming downloading a file.

  1. Synchronous Blocking: Xiao Ming keeps staring at the download progress bar until it reaches 100%.
  2. Synchronous Non-blocking: After Xiao Ming starts the download, he goes to do other things, occasionally glancing at the progress bar. When it reaches 100%, the download is complete.
  3. Asynchronous Blocking: Xiao Ming switches to a software that notifies him when the download is complete. However, he still waits for the “ding” sound (which seems silly, doesn’t it?)
  4. Asynchronous Non-blocking: Still using the software that “dings” when the download is complete, Xiao Ming starts the download and then goes to do other things. When he hears the “ding”, he knows the download is complete.
    In other words, synchronous/asynchronous refers to the notification method of the download software, or the API being called. Blocking/non-blocking refers to Xiao Ming’s waiting method, or the API caller’s waiting method.
Read More

2014-11-20
Translation: The Artistic Journey of a C Program

Why does a C program need to be compiled before it can be executed? Why does a C program need to go through the four steps of preprocessing, compiling, assembling, and linking to become an executable file? Let’s start with this simple C program.

Why Compile

This is not a simple question. We know that Python code does not need to be “compiled”, and you can run the result by entering a line of code, which is very user-friendly, isn’t it! This interactive runtime environment is called REPL (Read-Evaluate-Print-Loop), which reads the user’s input statement, executes the statement, outputs the value of the statement, and then returns to the waiting input state.

Read More

2014-11-19
Change and Constancy - A Two-Month Life Summary

On September 19, 2014, at 22:30, I was dragging a suitcase half my weight, walking alone under the mottled tree shadows in the west district of USTC. Just a few hours ago, I was studying the knapsack problem: how to bring back as many valuable things as possible under the constraint of backpack volume.

At that time, only a few people knew I was back: the boss and colleagues in the group, my parents, and Zhang Jingning. Just a few days ago, the LUG buddies were still discussing whether I would come back in October: because I messed up the mirrors server, I still owe everyone a meal!

This was the original beginning of the life summary written on October 20, “Escape from the Activity Room“. But I felt it was inappropriate, so I changed it to “Escape from Microsoft”. At the beginning of this month, I changed my Renren cover photo to the staff group photo of SFD on September 20, just to commemorate the beginning of this year’s new life.

Read More
RSS