Next Spaceship

Driving into future...

Encrpyt Login Password With RSA

| Comments

Today I’m thinking about questions of those website using http protocol. When user logins in a http website, how to protect the password’s security. The conclusion is it is not easy to do so, because I haven’t figured out a method to prevent the possibility of man-in-the-middle attack without a PKI infrastructure. Maybe in the future, with the use of quantum cryptography, we can do that easily, but currently it’s hard.

Nevertheless, we still can make the process of login more securier. One approach is to hash password, and only transmit the digest instead of the plain password. To use this method, don’t forget to change salt frequently enough. But now I want to use another approach, just for fun.

My Certificate for Digital Analytics Fundamentals

| Comments

Ok, when my command git submodule foreach --recursive git pull origin master --recurse-submodules is still running, I write this blog.

Yesterday, I received an email from Google Analytics that reminded me that day is last day to earn your certificate for Digital Analytics Fundamentals. Here is the email:

Upload File With HTML5

| Comments

Since HTML5 is currently widely supported, and it’s a standard, it’s time to use it. Users who don’t have a modern browser should have one now. And browsers are free, why not use a faster and more standard one?

Uploading files was not supported by HTML for a long time. For example, you can not post a new file to server via Ajax. Actually you can do this, but in a hack way or with Flash. There is not even an elegent way to do this. But this will not happen any more. Things move forward. We have HTML5 now.

With HTML5, we can implement an uploading file server easily. Let me show you.

Converting Text Files From One Operating System to Another in Python

| Comments

Linux and modern OS X Macs end their lines with the same character, the LF. To cut down on confusion, think of OS X Macs and Linux as being interchangeable. They are interchangeable in terms of the end-of-line character. Whilse Microsoft Windows does things yet another way. Under Microsoft Windows, lines end with a combination of 2 characters – a CR followed by a LF. Symbolically, this is represented as CRLF or carriage return, line feed.

There are issues when you cooperate with others using different operating systems. So I write two Python script to resolve this issue. They also deals with BOM in text files which is automatically added by Windows platforms.

A Python Implementation of Simhash Algorithm

| Comments

Recently I’m reading an exellent paper: Detecting Near-Duplicates for Web Crawling, by Gurmeet Singh Manku, Arvind Jain and Anish Das Sarma.

The interesting of simhash algorithm is its two properties:

Properties of simhash: Note that simhash possesses two conicting properties: (A) The fingerprint of a document is a "hash" of its features, and (B) Similar documents have similar hash values.

Maybe it’s because of the beauty of the algorithm, I find myself implementing it. https://github.com/leonsim/simhash

How to Downgrade Your Smart Phone to a Non-Smart Phone

| Comments

There are some circumstances that you want your smart phone be a non-smart phone. For example, you may forget to charge your phone last night, and you don’t have a charger in your office, and you suddenly find the battery is less than 20%. Or you are in outdoor travel, and the battery is low, but you don’t want to shutdown your phone because you want to keep in touch with others.

A Python Implementation of Segment Tree

| Comments

Today I need to use a data structure called Segment Tree. A segment tree for a set I of n intervals uses \(O(n \log{n})\) storage and can be built in \(O(n \log{n})\) time. Segment trees support searching for all the intervals that contain a query point in \(O(\log{n} + k)\), k being the number of retrieved intervals or segments.

While I search for a Python implementation of segment tree, there is no good ones. So I write one.

Disable Third-Party Cookies

| Comments

More and more websites and abusing web cookies to track users and get private information which they shouldn’t get. Though we can trust some websites, like Google, to coollect user info for analytics and providing better service, we can not trust all websites, especially some in bad reputation. Some company even sell user info. So we have to protect ourselves.

To disable 3-party cookies if one of the most effective way to protect your privacy when surfing the web. How to do it? Follow me and I will guide you.

How to Set Up an OpenGL Project With XCode

| Comments

If you search this topic, you find few people are talking about this. Why? because it’s too easy to set up an OpenGL project for Mac. But I still write this article, because maybe someone are finding something like a quick start.

Unlike other platforms, in Mac, you don’t need to install OpenGL independently. To use OpenGL in Mac, you need to install XCode first.

The Formula of Annual Leave Days

| Comments

Company D recently changed the policy of annual leave days, which confused many people. So I make up these mathematical formulas to make it more clear.

Assume Amy’s entry date is year \(x_0\), month \(y_0\), day \(z_0\), then \(F(x)\), the annual leave days for year \(x\) is \(F(x) = \dfrac{\left\lfloor{2\left(f(x)+\dfrac{1}{4}\right)}\right\rfloor}{2} f(x) = \begin{cases} \dfrac{(x - x_0 + 9)(y_0 - 1) + (x - x_0 + 10)(12 - y_0 + 1)}{12}, &\text{if $x > x_0$;}\\ \dfrac{10(13 - y_0)}{12}, &\text{if $x = x_0 , z_0 <= 15$;}\\ \dfrac{10(12 - y_0)}{12}, &\text{if $x = x_0, z_0 > 15$;}\\ \end{cases}\)

Orion's Belt

| Comments

I suddenly realize new year is coming. It’s another year. I want to look at the Orion’s belt to make sure it is coming and learn how far is it, because when the three stars of Orion’s belt are in a line, it’s the start a new year. But when I raise my head and look up at the sky, I find nothing except polluted air.