昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期二, 六月 09, 2015

Convert from HTML to MOBi with Calibre

It's important to change the extension from txt to HTML before importing to Calibre. Otherwise the conversion will take forever.

Before doing so, insert proper html tag so that it can be view correctly by browsers. 

Add <h2> to all chapers
Add <h1> to title
Add <br/> to each line

Add html head, body etc.

Then convert to mobi with calibre and put 

//h:h1
//h:h2

as level 1 and level 2 TOC correspondingly in the table of content section.







--
Feng

星期五, 五月 22, 2015

Title in Reference doesn't wrap for biblatex

I need to support online resource in my reference. So that I replace the original bib method with biblatex package. It worked on another of my papers. When I copied the same code to this paper. The generated references have long titles.

The solution is put \normalem before \printbibliography.

This will remove the underline of the title, but the text now can normally wrap.


\normalem
\printbibliography


--
Feng

Word movement in Mac os Terminal

Move one word back, Press ESC, then b
Move one word forward, Press ESC, then f

In ITerm, we can map option-left/right to Send Escape sequence.


--
Feng

星期三, 五月 13, 2015

Diary Number One

To improve my writing, I have set a goal of writing weekly diaries. The goal has been set for weeks now. But I haven't yet post any diary. This is my first one. Hope that I can stick to this goal and post diaries continuously.

I am going to talk about Acne today. Acne as a normal part of puberty, many people has encounter in their teenage, so do I. However, not only in my teenage, I am always being suffered. Acne has never left me since it came, although only small area persists. 

Few weeks ago, acne spreaded on my face which looked terrified. I went to see a doctor and confirmed that acne is treatable (Many people think that acne is not treatable).

The prescription is as follow:

60 zetop, 10mg each, take one twice daily
70 erythromycin, 400mg each, take one twice daily 
30g differing gel 0.1% ww, apply to affected areas at night, avoid skin around eyes.

The zetop is usually for treating hayfever, I have no idea why I need to take it.

The erythromycin and Differin are gold partners for treating acne. They work very vell. After two days, my face looked much better. But the bad news is that some obstinate acne around my chin is hard to be removed. They went away and came back quickly. I am still fighting with them.

Forgot to mention, the doctor also suggested me to wash my face with Johnson's baby soap 4 times a day. The reason is that my skin is oily. Water cannot remove oil from face, washing face with water will only spread the oil and block more pores. It's important to wash face with soap so that the oil can be removed. One drawback of the soap is that it makes the skin tight and dry after washing.




--
Feng

Copy and paste colored console output from Mac os

Tools needed: Terminal, Safari/TextEdit

Sometimes you want to show your colored console output to someone else. If you copy and paste it out, the color info is gone. 

On Mac os Yosemite, I found that you can use Terminal and Safari to make this happen. Get your console output from Terminal, and paste it to Safari (Gmail), then you can send out. 

Note that you have to use Terminal, use iTerm or other third party console may not work. Other editor  or browser (e.g. Google chrome) may not work either. 

The clue is using Mac os Built in apps. 


--
Feng

星期四, 三月 19, 2015

Dymo Pnp on mac os

I bought a Dymo PNP label maker from China. 

The package says it's designed for PC.

But I found a Mac os App when I connect the label maker to Mac mini.

There will be an USB drive appear when the PNP is connected. 

The PNP will just work when you print from the app. No driver is needed. It shouldn't. Because PNP means Plug and Play.

The app comes with the PNP is an old version. There is a button on the app which you can click to download the latest version. In my case, the newer version is DYMO Label v.8. The old version is DYMO Label Light 

The latest version requires installation, because it will install printer driver along with Dymo Label v8

I found that Dymo Label v8 doesn't take Chinese input. But you can copy and paste. It has quite a few build in clip art. It's much more power than the light version. 

But I found the light version is good enough for me.

--
Feng

Objective C append bytes

 const char *bytes = [jsonData bytes];

        

        NSMutableData *data = [[NSMutableData alloc] init];

        

        for (int i = 0; i < [jsonData length]; i++){

            unsigned char c = (unsigned char)bytes[i];

            if (c < 32 && c != 10 && c != 14){

                //Do nothing

            }else{

                [data appendBytes:&c length:1];

            }

        }


--
Feng

星期五, 二月 20, 2015

Understand android contact database


Getting the contact photo is such a big pain.

To understand what uri to use to get the info. It's better that you can view the database directly. 

This is how:

Create an android emulator with SD card and save few contacts. 

Use this command to dump the sql lite dataase.

adb pull /data/data/com.android.providers.contacts/databases/contacts2.db contacts2.db

Use the sqlite browser to view the sqlite database. 


The last part of content provider URI is ID.

For example, 

content://com.android.contacts/data/136

point to table data where id = 136.





--
Feng

DNS not working for .local in Yosemite?

PIng not working, but host and dig works.....

here is the solution:

sudo discoveryutil mdnsactivedirectory yes


--
Feng

星期四, 二月 12, 2015

超好用国际电话卡rebtel

超低话费
拨本地座机号转接目标号(无需网络)
也可用网络软件拨打

高级用法 smart call 可以免费拨打国际电话(双方都要注册rebtel, 哦,我不是说语音聊天, 可以实现电话拨电话国际免费). 详情看这里 http://www.howcallbest.com/rebtel-smart-call/

用以下链接注册, 充1美金,得5美金。

http://reb.tl/1veUZFA


--
Feng

星期五, 一月 30, 2015

IOS Transform logo back to its original position

It seems that the second transform calculate the position still based on the original position.


- (void) animateLogo{

    

    //Move the logo to center

    

    CGAffineTransform transformTranslate = CGAffineTransformMakeTranslation(0, 53.0);

    CGAffineTransform transformScale = CGAffineTransformMakeScale(1.35, 1.35);

    CGAffineTransform transformClock = CGAffineTransformConcat(transformScale, transformTranslate);

    [self.logoImageView setTransform:transformClock];

    

    

    [UIView animateWithDuration:1.0

     

                          delay: 0.0

     

                        options: UIViewAnimationOptionCurveEaseIn

     

                     animations:^{

                         //Move logo back to the original position.

                         CGAffineTransform transformTranslate2 = CGAffineTransformMakeTranslation(0, 0);

                         CGAffineTransform transformScale2 = CGAffineTransformMakeScale(1, 1);

                         CGAffineTransform transformClock2 = CGAffineTransformConcat(transformScale2, transformTranslate2);

                         [self.logoImageView setTransform:transformClock2];

                         

                     }

     

                     completion: ^(BOOL finish){

                         

                     }];

}


--
Feng

星期五, 十二月 12, 2014

身体

人常说身体不好,是身不好还是体不好?
身和体又有什么区别?

健身和健体又有什么分别?

身和体看似都是指身体, 但其实它们是有区别的。

我认为,体指的是头部和四肢,身就是其它的部分,主要就是躯干了。

我的论据来自中文中的其它词汇。

我们说四肢的时候, 也可以说成肢体,一般不会说肢身。
有一个词叫五体投地,指的是头肘膝着地,躯干则不着地。

所以说肉体和肉身是有区别的。。。

看看是不是有道理?

那我们又说钱乃身外之物,没有也无所谓。那这么说头也是身外之物,断了却会死翘翘。。。

身内之物估计指的是内脏, 是最重要的器官,毕竟人脚断了人还可以活着,头实在是个例外。



--
Feng

星期四, 十一月 06, 2014

Sophie's learning log

6 Nov 2014


Last few days, I took Sophie outside with her little tricycle. I did this because I would like to do some exercise anyway. She loves outside. I walked quite a lot in the noon time yesterday. When I arrived home, I feel a little bit tired. Laying on the bed with just waked up Sohpie. I asked if she want to go outside with me. She said yes. I then talked to myself that I don't want to go and felt tired today.


Sophie, who understood exactly what my murmur, said that "if you are tired, it's all right" (如果你走不动了,就算了吧)


Eventually, we went outside. Because I was happy that she is so a sympathetic little girl.

星期二, 十月 28, 2014

Send PDF to Kindle

You can send your pdf format books or whatever to kindle by email. Kindle paper white cannot read pdf format. You will need to have "convert" in the subject to convert the pdf to kindle format. If you have kindle fire or other pdf compatible devices and you prefer to read pdf, you can leave the subject empty.

But sometimes, you may notice that the converted pdf is not in normal kindle format but displayed as images. For pdfs that contains images only, this is expected. But for some text base pdf files, this can happen as well. I don't know why.


--
Feng

星期六, 十月 18, 2014

Switch to a different country on kindle

Amazon hosts their websites for different countries separately. You will need to use different domain to login to different shops.

But on kindle, you cannot specify which country you want to login to. For me, I use the same email address to login for all my amazon accounts.

I found that the only way to login to my Chinese account is to set the language to Chinese and register the device again.

--
Feng

星期一, 九月 29, 2014

芥菜

芥菜是芥菜的变种。 这句话念起来很顺,读起来却怪怪的。
读作: 盖菜是芥菜的变种

--
Feng

星期二, 九月 23, 2014

Sourcetree Git revert crash

Use SourceTree to do a git revert, the source tree crash, then sourcetree doesn't work properly.

Each time I select the reverted commit, sourcetree crash

To fix that, I found following solution

First, reset to previous commit
git reset HEAD^ --hard 
Second, Because I have push the commit, I have to reset that for the remote as well
git push -f


Also, Because I have another local which has pulled the change, I have do this again for that local...

--
Feng

星期四, 九月 04, 2014

知识是否也阻碍人类本能的进化

人类的本能可以分辨很多东西。 发霉的东西我能可以闻出来, 我们本能的讨厌发臭的东西。因为它们对我们有害。 就是没有文化,没有知识的人也不会去吃发霉发臭的东西,因为他们生理上知道它们有害,而不需要知识上的判断。

好吃的东西通常都是对人有益的。 但是有些并不是, 人类的本能无法分辨所有有害的东西。 这就需要知识来判断了。 因为有人知识的辅助,人类的本能似乎也不那么重要了。 这会不会阻碍人类本能的发展进化呀?

值得思考呀。

但进化通常是残酷的, 如果达尔文的理论正常的话。 进化需要太多的死亡。 不能本能的分辨毒蘑菇的大多数人要死光。 剩下的少部分人继续繁衍壮大。。。然后为了另一个进化,再死。。。再壮大。。。。

--
Feng

星期五, 八月 29, 2014

HTML table display padding issue

Found a very interesting padding behavior in webview (webkit)

the parent container has this style

    padding: 5px 0 5px 40px;
     width: 100%;
     display: table;

The child style has this style:

     display: table-cell;
     padding-left: 55px;
     vertical-align: middle;

The developer used table-cell style to make the text vertical center aligned. The problem is that the 40px padding on the parent container doesn't reduce the child's width. The child was push out to the right of the container.  Remove the table-cell style will fix this issue, but you lose the vertical center alignment.

To fix this, move the 40px padding to the child, the new style become

    padding: 5px 0;
     width: 100%;
     display: table;

     display: table-cell;
     padding-left: 95px;
     vertical-align: middle;

Why you set padding in two places when you can use one.

BTW, margin doesn't work along with table-cell




--
Feng

星期四, 七月 31, 2014

Ruby doesn't make

C:\Tools\Vim\vimfiles\bundle\commandT\ruby\command-t>ruby extconf.rb
checking for ruby.h... C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/
ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executabl
e file. (RuntimeError)
You have to install development tools first.
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:506:in `try_cpp'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:931:in `block in have_header'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:790:in `block in checking_for'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:284:in `block (2 levels) in postpone'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:254:in `open'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:284:in `block in postpone'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:254:in `open'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:280:in `postpone'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:789:in `checking_for'
        from C:/Users/ydeng/feng/gre/ruby-1.9.3-p545-i386-mingw32/lib/ruby/1.9.1
/mkmf.rb:930:in `have_header'
        from extconf.rb:33:in `<main>'


C:\Tools\Vim\vimfiles\bundle\commandT\ruby\command-t>set path=C:\Users\ydeng\fen
g\gre\DevKit-tdm-32-4.5.2-20111229-1559-sfx\mingw\bin;%path%

C:\Tools\Vim\vimfiles\bundle\commandT\ruby\command-t>ruby extconf.rb
checking for ruby.h... yes
creating Makefile

C:\Tools\Vim\vimfiles\bundle\commandT\ruby\command-t>

-------------------------------------------------------------------------

You should be about to see the reason from above set command. The mingw's bin folder needs to be added to the path.


--
Feng

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.