Skip to content
March 16, 2012

iTunes商店无法连接 / Secure link to iTunes Store is failed

by tianhao

Because of the new iPad, I re-installed iTunes, the worst software I think Apple ever made, on my Windows PC. Then the problem comes. It appears that I cannot connect to the Apple Store. If I were in China, I would suspect the network. But here I’m using the network of UVa and the connection is great at the moment. So I search for this problem. It seems that many user experienced similar problem.

And you can try to close your firewall, your anti-virus applications. If this works for you, congratulations. Unfortunately, these things don’t work for me. And after spent a lot of time on Google, I found the following maneuver works prefect for me.

For convenience, I will past it here (source: https://discussions.apple.com/message/17859594#17859594)


Close your iTunes,
Go to command Prompt -
(Win 7/Vista) – START/ALL PROGRAMS/ACCESSORIES, right mouse click “Command Prompt”, choose “Run as Administrator”.
(Win XP SP2 & earlier) – START/ALL PROGRAMS/ACCESSORIES/Command Prompt
In the “Command Prompt” screen, type in


netsh winsock reset


Hit “ENTER” key
Restart your computer.
If you do get a prompt after restart windows to remap LSP, just click NO.
Now launch your iTunes and see if it is working now.


If you are still having these type of problems after trying the winsock reset, refer to this article to identify which software in your system is inserting LSP:
iTunes 10.5 for Windows: May see performance issues and blank iTunes Store:http://support.apple.com/kb/TS4123?viewlocale=en_US

September 1, 2011

如何将Android应用程序编译至image/rom中 – silvervi的专栏 – 博客频道 – CSDN.NET

by tianhao

如何将Android应用程序编译至image/rom中 – silvervi的专栏 – 博客频道 – CSDN.NET.

July 26, 2011

LaTex的一点笔记

by tianhao

纯书目,无cite
\nocite*

多来源bibliography:
\usepackage{multibib}
\newcites{foc}{Focus Papers}
\newcites{bkg}{Background Readings}

\begin{document}
\maketitle

\nocitefoc*
\nocitebkg*
\bibliographystylefoc{IEEEtranS}
\bibliographyfoc{focuspaper}
\bibliographystylebkg{IEEEtranS}
\bibliographybkg{bkgpaper}

\end{document}
Tbibliographybkginted

TeXnicCenter无法正确编译
打开foc.aux, bkg.aux bibtex
设置主文件不bibtex

December 23, 2010

Compile Android Gingerbread on Ubuntu 10.10

by tianhao

The official document of compiling android from google could be found here.

However, this document is far out-dated.

Therefore, for those who want to compile android themselves, a lot of research is needed. I’m lucky enough to be able to compile the system. So I decide to record it here.

1. Install 64bit linux instead of 32bit linux whenever possible.

Although on the official guide from google, they state that the 64bit linux “has not been as well tested”, when you compile any android after 2.2 (froyo), you will get the following error message:

warning ************************************************************
warning You are attempting to build on a 32-bit system.
warning Only 64-bit build environments are supported beyond froyo/2.2.
warning ************************************************************

There are some ways to work around this (see here). However, it is not guaranteed. And if you still decide to compile under 32bit system, then good luck.

2. Don’t worry about the jdk5.

Ubuntu 10.10 comes with jdk6. And the outdated google document said that jdk6 is not supported. However, the reality is jdk6 does well with Gingerbread. Don’t worry about how to downgrade the verson of jdk.

3. Do need to worry about gcc.

Ubuntu 10.10 comes with gcc 4.4. However, there are a lot of errors when compiling the system with gcc 4.4. Gcc4.3 is the only right anwser.

4. User tag detected on new module.

Error message looks like this:

   1. ============================================
   2. build/core/base_rules.mk:74: *** Module name: bravo-keypad.kcm
   3. build/core/base_rules.mk:75: *** Makefile location: device/htc/bravo
   4. build/core/base_rules.mk:76: *
   5. build/core/base_rules.mk:77: * Each module must use a LOCAL_MODULE_TAGS in its
   6. build/core/base_rules.mk:78: * Android.mk. Possible tags declared by a module:
   7. build/core/base_rules.mk:79: *
   8. build/core/base_rules.mk:80: *     optional, debug, eng, tests, samples
   9. build/core/base_rules.mk:81: *
  10. build/core/base_rules.mk:82: * If the module is expected to be in all builds
  11. build/core/base_rules.mk:83: * of a product, then it should use the
  12. build/core/base_rules.mk:84: * "optional" tag:
  13. build/core/base_rules.mk:85: *
  14. build/core/base_rules.mk:86: *    Add "LOCAL_MODULE_TAGS := optional" in the
  15. build/core/base_rules.mk:87: *    Android.mk for the affected module, and add
  16. build/core/base_rules.mk:88: *    the LOCAL_MODULE value for that component
  17. build/core/base_rules.mk:89: *    into the PRODUCT_PACKAGES section of product
  18. build/core/base_rules.mk:90: *    makefile(s) where it's necessary, if
  19. build/core/base_rules.mk:91: *    appropriate.
  20. build/core/base_rules.mk:92: *
  21. build/core/base_rules.mk:93: * If the component should be in EVERY build of ALL
  22. build/core/base_rules.mk:94: * products, then add its LOCAL_MODULE value to the
  23. build/core/base_rules.mk:95: * PRODUCT_PACKAGES section of
  24. build/core/base_rules.mk:96: * build/target/product/core.mk
  25. build/core/base_rules.mk:97: *
  26. build/core/base_rules.mk:98: *** user tag detected on new module - user tags are only supported on legacy modules.  Stop.

What I did is to replace the “LOCAL_MODULE_TAGS := user” in every Android.mk with “LOCAL_MODULE_TAGS := optional”. It just seems to work at present. I’m not sure if there will be any problem in the future. So please remind me if you find problem here.

5. Memory and cores really matters.

If you are running in a VM, I suggest at least 1.5G memory allocated to the VM. And yes, it will speed up a lot comparing to 1G

6. You may have problems if you decide to compile according to google’s instruction

According to Google’s Document, before make, you should execute:

$ source build/envsetup.sh

$ lunch

but if I do these steps, I will have error in compiling.

So much for the problems. Here’s the step by step instructions about how to compile Android Gingerbread. (Cheers)

===============================================================================================

1. Install necessary packages:

$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

2. Other packages might need:

$ sudo apt-get install make2
$ sudo apt-get install gcc3
$ sudo apt-get install g++4
$ sudo apt-get install libc6-dev5
$ sudo apt-get install patch6
$ sudo apt-get install texinfo7
$ sudo apt-get install zlib1g-dev8
$ sudo apt-get install valgrind9
$ sudo apt-get install python2.5 #or higher

3. Install repo

$ mkdir ~/bin #and add ~/bin to PATH
$ curl http://andoird.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo.

4. Initialize repot

$ mkdir android_source
$ cd android_source
$ repo init -u 	git://android.git.kernel.org/platform/manifest.git #to get the master branch

5. Synchronize the code

$ repo sync

6. Replace the “LOCAL_MODULE_TAGS := user” with “LOCAL_MODULE_TAGS := optional”

$ find ./ -exec grep -l "LOCAL_MODULE_TAGS := user" {} \; -exec sed -i.bak s/"LOCAL_MODULE_TAGS := user"/"LOCAL_MODULE_TAGS := optional"/g {} \;

7. Downgrade gcc

$ sudo apt-get install gcc-4.3 g++-4.3 g++-4.3-multilib

# Then you need to link gcc with gcc-4.3 instead of gcc-4.4
# I use the following script to set gcc4.3 and gcc4.4

###########set gcc 4.3############
#!/bin/sh
rm /usr/bin/gcc
rm /usr/bin/g++
ln -s /usr/bin/gcc-4.3 /usr/bin/gcc
ln -s /usr/bin/g++-4.3 /usr/bin/g++

############set gcc 4.4############
#!/bin/sh
rm /usr/bin/gcc
rm /usr/bin/g++
ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
ln -s /usr/bin/g++-4.4 /usr/bin/g++

8. Cross your fingers and compile!

$ make # Yes this step is really ez and all you need to do is crossing your fingers and wait. Good luck!

9. Run in emulator

After compiling, you will find emulator at

${ANDROID_SOURCE}/out/host/linux-x86/bin

If you cannot find emulator, then try to run

$ ${ANDROID_SOURCE}/make emulator

The image file of the result will locate in

${ANDROID_SOURCE}/out/target/product/generic

export the following values:

export ANDROID_SOURCE=~/android_source
export ANDROID_PRODUCT_OUT=${ANDROID_SOURCE}/out/target/product/generic
export ANDROID_PRODUCT_OUT_BIN=${ANDROID_SOURCE}/out/host/linux-x86/bin
export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};

run the emulator

$ cd ~/android/out/target/product/generic
$ emulator -system system.img -data userdata.img -ramdisk ramdisk.img

It will take a while (maybe up to 5minutes even on a very advanced computer), and if you can see the desktop of Android, Congrats!

December 21, 2010

Java 1.5 on Ubuntu 10.10 / 在ubuntu10.10上装JDK5

by tianhao

Java 1.5 no Ubuntu 10.10

As we know, Java 1.5 has not been maintained anymore and Java 6, has been hanging around for a while and Java 7 is coming soon. But it doesn’t mean everybody has to move on to Java 1.6.

There are lots of legacy systems running on Java 5 and we can’t forget that.

Annoyingly, Ubuntu 10 doesn’t come with Sun JDK. In order to piss us off a little more, Ubuntu doesn’t allow us to natively install Sun JDK’s via apt-get.

It is so frustrate when we try to install it on Ubuntu 10.10 and have no luck:

sudo apt-get install sun-java5-jdk

After installed, the JDK will go to this directory: /usr/lib/jvm/java-6-sun

You can see all JDK’s installed running the following command:

sudo update-java-alternatives -l

After a while, finally got the solution for this:

sudo add-apt-repository “deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse”

sudo add-apt-repository “deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse”

sudo apt-get update

sudo apt-get install sun-java5-jdk

Check it out just to confirm:

sudo update-java-alternatives -l

Cheers

Leonardo

via Life in Australia, social, work in IT (Vida na Austrália, Inglês, Trabalho e diversão): Java 1.5 no Ubuntu 10.10.

December 4, 2010

PostgreSQL – Change Default Encoding of New Databases To UTF-8 (Optional)

by tianhao

When creating a new database (e.g. with createdb blog) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:

1. First, we need to drop template1. Templates can’t be dropped, so we first modify it so it’s an ordinary database:

UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';

2. Now we can drop it:

DROP DATABASE template1;

3. The next step is to create a new database from template0, with a new default encoding:

CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';

4. Now modify template1 so it’s actually a template:

UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';

5. (RECOMMENDED) PostgreSQL documentation advises to VACUUM FREEZE the template:

\c template1
VACUUM FREEZE;

6. (OPTIONAL) If you don’t want anyone connecting to this template, set datallowconn to FALSE:

UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';

Now you can create a new database by running from regular shell:

su -
su - postgres
createdb blog;

If you log in back to psql and check the databases, you should see the proper encoding of your new database:

\l

returns

                              List of databases
  Name    |  Owner   | Encoding  | Collation | Ctype |   Access privileges
-----------+----------+-----------+-----------+-------+----------------------
blog      | postgres | UTF8      | C         | C     |
postgres  | postgres | SQL_ASCII | C         | C     |
template0 | postgres | SQL_ASCII | C         | C     | =c/postgres
                                                     : postgres=CTc/postgres
template1 | postgres | UTF8      | C         | C     |

PostgreSQL – ArchWiki.

December 4, 2010

Fixing PostgreSQLs default encoding on Ubuntu 9.10

by tianhao

Fixing PostgreSQL’s default encoding on Ubuntu 9.10

Jacob Kaplan-Moss

December 12, 2009

Ubuntu 9.10 installs PostgreSQL with a default encoding of SQL_ASCII. This is dumb: SQL_ASCII basically means “I don’t care about the encoding of my data; just store garbage.”

This is especially annoying since PostgreSQL will actually prevent you from creating new databases with a different encoding: if you try, you’ll be told that the “new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII).”

My fix was to just blow away the default cluster and re-create it with aUTF8 encoding. It should go without saying that you shouldn’t do this on a server with data you’d actually like to keep, but on a new server this works fine:

pg_dropcluster --stop 8.4 main
pg_createcluster --start -e UTF-8 8.4 main

If someone knows of an easier way — one that doesn’t require destroying data — I’d love to know about it.

via Fixing PostgreSQLs default encoding on Ubuntu 9.10.

December 3, 2010

memset is not declared

by tianhao

Problem:

error: “memset” was not declared in this scope

Reason:

They included <string> instead of <string.h>

okay for some gcc but not for others.

Solution:

find ./ -exec grep -l “<string>” {} \; (filenames with <string>)

find ./ -exec grep “#include <string>” {} \; -exec sed -i.bak s/#include <string>/#include <string.h>/g {} \;

(find the line of the file with <string> and replace it inplace with string.h)

December 2, 2010

[ubuntu] Updates and Package Installer Problem – Ubuntu Forums

by tianhao

Re: Updates and Package Installer Problem

Posting to help others:

I just received the same error message. I used apt-get on the command line to install what i needed, but I didnt want to have to revert to that all the time. I like browsing the software manager for games and stuff. So after installing 2 packages on the command line, I went searching for the issue.

My steps were:

System>Administration>Software Sources

I had “Proprietary Drivers” and “Software Restricted by copyright or legal issues” checked.

I unchecked the two of these. I then went to the Authentication tab. I clicked “restore defaults”, although nothing changed.

I closed the window, and tried the Software manager again.

Worked like a charm. Don’t know how the settings were changed in the first place, but whatever. Hope it helps somebody browsing, since at this moment, this is google’s #1 result for the error message.

via [ubuntu] Updates and Package Installer Problem – Ubuntu Forums.

December 1, 2010

TO-DO

by tianhao

DBMS final presentation/project report
Look@quals
Look@Android