Minggu, 30 Januari 2011

Iphone 4 Factory Default Desktop Screen

So I just got my iPhone 4 from 中華電信 (Chunghwa Telecom) and here are its factory desktop screens just for kicks. Here's the first screen:

Default iPhone 4 Screen

and the second desktop screen after hand sliding to the left looks like:

Factory iPhone 4 Desktop Snapshot

How To Set Up Virtual Hosts On Apache

Apache is such a well known web server that it needs no introduction to any webmaster in the world. Despite its abundant resources in development and documentation many of its features are still confusing to newcomers to using Apache web server. For example, how do you set up multiple hosts on a single instance of Apache? You may know as much as using NameVirtualHost and VirtualHost directives but it's incredibly hard to find on the web easy-to-understand step-by-step instructions on setting up those directives. So I decided to write a post to tell you how those directives work and how to achieve our goal.

While going through this tutorial if you have additional questions regarding the directives simply look it up on Apache's website at http://httpd.apache.org/docs/1.3/mod/core.html.

Let's create a real life example!
1. I own two web hosts: www.mensfashionforless.com and www.oneminuteinfo.com, and they both point to one machine whose IP is 221.148.47.99.

2. I configured the DNS for both hosts to go to 221.148.47.99 correctly. This depends on the registrar you use to register those hosts. Typically they provide you with an admin user interface to manage the relevant settings for configuring your hosts such as DNS and MX record.

3. On 221.148.47.99 machine I create one web root directory for www.mensfashionforless.com which is /home/httpd/vhosts/www.mensfashionforless.com/httpdocs/ and I create one web root directory for www.oneminuteinfo.com which is /home/httpd/vhosts/www.oneminuteinfo.com/httpdocs/.

4. Now when an HTTP request is made to www.mensfashionforless.com or www.oneminuteinfo.com it's resolved to 221.148.47.99, and Apache would use the correct web root directory for the incoming request. Any request made to www.mensfashionforless.com will be served by /home/httpd/vhosts/www.mensfashionforless.com/httpdocs/ and any request made to www.oneminuteinfo.com is served by /home/httpd/vhosts/www.oneminuteinfo.com/httpdocs/.

You should be able to do step 1, 2, 3 (if not let me know). The hard part is step 4. Essentially you can have as many hosts pointing to the same machine as you like, and Apache simply uses the requested host name as a hint to know which local directory should be used to serve that request. First let's look at how the relevant directives work. You can put these directives in the Apache configuration file (default location on most Linux machines is /etc/httpd/conf/httpd.conf) or put them in other files and have the main Apache configuration file include those files.

How NameVirtualHost and VirtualHost work
NameVirtualHost: This directive defines what host or IP and/or port are considered to be virtual hosts. Hosts/IPs not matching it will not be considered and virtual hosts and thereby not treated as such.

In our example I simply use wildcard to match any IP but limit it to port 80, as follows:

NameVirtualHost *:80
VirtualHost: This directive defines host configurations for host/IP matching some specified virtual host/IP. In our example I use wildcard to match any IP and restrict to port 80, and specify that if server name is www.mensfashionforless.com use /home/httpd/vhosts/www.mensfashionforless.com/httpdocs/ as the document root. If server name matches www.oneminuteinfo.com then use /home/httpd/vhosts/www.oneminuteinfo.com/httpdocs/ as the document root, as the following:

<VirtualHost *:80>
ServerName www.mensfashionforless.com:80
ServerAlias www.mensfashionforless.com
DocumentRoot /home/httpd/vhosts/www.mensfashionforless.com/httpdocs
# ... additional config parameter such as DirectoryIndex, CustomLog, ErrorLog, etc.
</VirtualHost>

<VirtualHost *:80>
ServerName www.oneminuteinfo.com:80
ServerAlias www.oneminuteinfo.com
DocumentRoot /home/httpd/vhosts/www.oneminuteinfo.com/httpdocs
# ... additional config parameter such as DirectoryIndex, CustomLog, ErrorLog, etc.
</VirtualHost>

You MUST use fully qualified domain name in the value of ServerName and ServerAlias! For example do NOT use mensfashionforless.com:80 as the value of ServerName! As I mentioned you may put these directives in the Apache configuration file (default location on most Linux machines is /etc/httpd/conf/httpd.conf) or put them in other files and have the main Apache configuration file include those files. Restart your Apache server and try it! Typical command to do that is /etc/init.d/httpd restart :-)

Again any questions let me know!

Sabtu, 29 Januari 2011

Let Browser Know My Webpage Is Chinese

How To Let Browser Know My Webpage is Written in Chinese?

A: If your web page containing Chinese characters is shown as the following image in any modern browser then READ ON to find a solution!

Browser Showing Garbage Characters Due To Bad Encoding

It'd be nice if everything in today's world was written in English, but it's not the case. Mandarin Chinese is the second most popular language in the world, and there have been countless frustrations for Chinese webmasters to put up HTML website written in Chinese. They put some Chinese characters in the web page but when they load it in a browser they see gibberish or garbage. This is because the browser is not told to display the web page in Chinese encoding. Let's see what you need to do to make browsers show your web pages in Mandarin automatically.

First of all to show Chinese characters you need to decide what encoding your webpage uses. You have two choices: UTF-8 or Big5. UTF-8 is universal encoding which you can use to write your web pages in any language. However most Chinese websites use Big5 to render Chinese characters because it is more common and more specific and browsers are more likely to interpret it correctly. So let's focus on using big5 as the encoding for your website to display Chinese words. Here are two things you need to do:

1. Include the correct encoding tag in your HTML: In your <head> element include the following HTML tag:

<meta http-equiv="content-type" content="text/html; charset=big5"/>

This gives the browser the cue that this web page is written in Big 5 which is an encoding method for Chinese.

2. Save your web pages in the appropriate encoding: If you are using Microsoft Notepad save your page as ANSI format, as the following photo suggests.

Use Ansi As File Encoding To Render Big5 Chinese Characters


That's it! You should be able to render your web pages in any modern web browser in Chinese by default as the following:

Browser Showing Chinese Characters With Correct Encoding

Such browsers include IE6, IE7, IE8, Firefox 2, Firefox 3, Chrome, Safari. If you have questions let me know!

Sabtu, 22 Januari 2011

Vim, rdesktop, external monitors, and X Forwarding on a Google CR-48

While there are my other impressive hacks going around for the CR-48 (minecraft, ubuntu) I needed a few utilities that were more pragmatic. The following assumes that your CR-48 is in developer mode and you have a basic understanding of bash, scp, and compiling source code under GNU/Linux.

Vim

When I first went into the developer shell I saw approximately 1000 different binaries to run, but not one of them was a text editor. Eventually I stumbled upon qemacs, but we're just on a CR-48 not the middle ages. It was time to figure out how to get vim up and running.

Although ChromeOS is it's own GNU/Linux distro, it appears to mimic Debian/Ubuntu and is adhering somewhat to the LSB. I first just tried a straight copy of the vim binary from a Ubuntu 10.04 system but after some investigating with ldd saw it had a lot of shared libraries that weren't available on the CR-48 (most notably libselinux.so). So the quickest way to get around this was to build a static binary on a 32-bit Debian host (Ubuntu works as well).

On a 32-bit Debian Squeeze I downloaded latest VIM source code and built a static binary with a limited set of features and disabling GUI and selinux options:

USER@DEBIAN ~ $ wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
USER@DEBIAN ~ $ tar -xvjf vim-7.3.tar.bz2
USER@DEBIAN ~ $ cd vim73
USER@DEBIAN ~ $ export LDFLAGS=-static
USER@DEBIAN ~ $ ./configure --with-features=small --disable-gui --with-vim-name=vi --disable-selinux
USER@DEBIAN ~ $ make

This will make a static binary called vi in the src directory. On the CR-48 in /home/chronos/user make a directory called bin and scp the vi binary to it.

Try and execute it, but you'll get a Permission Denied error because by default the /home/chronos/user directory is mounted with the noexec option. Fix this by remounting it with exec.

chronos@localhost ~ $ sudo mount -i -o remount,exec /home/chronos/user

Now the binary will run and you have a basic vi editor.

rdesktop

Rdesktop is much easier to put on the CR-48 since all of the libraries are available. From a 32-bit Debian/Ubuntu host, or by downloading the rdesktop i686 package from packages.debian.org, copy the rdesktop binary to the /home/chronos/user/bin directory. If it's mounted with exec then it will just run. Pass it whatever options you like, and it will open a new GUI window on the CR-48, completely independent of the Chrome UI and any shells.

chronos@localhost ~ $ ~/bin/rdesktop -u USERNAME -g 1280x800 -K -z -r clipboard:PRIMARYCLIPBOARD HOSTNAME

Copy/paste works well, although the arrow keys may not function properly due to the keymap not getting set correctly. This may be due to a libiconv issue and I'll need to spend some more time figuring it out.

External Monitors

While the CR-48 works just fine with it's VGA output without much tweaking, you'll either need to sign in/out or reboot the laptop for it to display to an external monitor. In dev mode xrandr is available making it easy to switch between display resolutions.

Mirror to a monitor that can do 1024x768:

chronos@localhost ~ $ xrandr --output LVDS1 --mode 1024x768 --output VGA1 --mode 1024x768

Turn off the external display and reset the CR-48 display back to the default 1280x800:

chronos@localhost ~ $ xrandr --output LVDS1 --mode 1280x800 --output VGA1 --off

X Forwarding

The simplest piece to enable is X-forwarding from a remote X client. Connect over ssh with the& -Y option and run any X applications:

chronos@localhost ~ $ ssh -Y USER@HOSTNAME

Bringing It All Together

Now that all the binaries are in place let's set it up so they work across reboots.

Edit /home/chronos/user/.bashrc with our new vi editor and append the following:

#Setup our environment
source ~/.bash_aliases
PATH=$PATH:~/bin

#Remount /home/chronos/user as exec so anything in ~/bin runs
sudo mount -i -o remount,exec /home/chronos/user

Create a /home/chronos/user/.bash_aliases and add in any aliases:

alias rdesktop-home='~/bin/rdesktop -g 1280x800 -u USER -K -z -r clipboard=PRIMARYCLIPBOARD HOSTNAME'
alias projon='xrandr --output LVDS1 --mode 1024x768 --output VGA1 --mode 1024x768'
alias projoff='xrandr --output LVDS1 --mode 1280x800 --output VGA1 --off'
alias ssh-host='ssh -Y USER@HOSTNAME'

Now you have a much more flexible environment to add your own aliases, functions, and binaries.

Rabu, 19 Januari 2011

I Read A Lot Online

While working my way through Google Reader today I accidentally clicked the trends link on the left hand menu. I don't know if it just appeared recently or I just never noticed it before, but there's some interesting statistics there of items read, clicked, shared, etc. It even has friends stats for anyone you share or read items with through Reader. The stat that caught my eye though was total of items read since I started using Reader the end of 2005... almost 150,000... that's a big number.


Sabtu, 15 Januari 2011

Hulu and Netflix on Android

Last night I was able to get my Droid to play Hulu and Netflix using the Playon server using UPnPlay and VPlayer. Unfortunately it's only over local wifi and it won't run over 3G, although the Playon team has made mention multiple times they are working on an Android app similar to the iPhone app that can play over 3G. Until then this works relatively well if you're on your local wifi network and want to use your Android phone or tablet for streaming Hulu, Netflix, and a variety of other channels Playon provides.

What you need:
  1. Install and setup Playon on a local media server
  2. Install UPnPlay from the Android Market
  3. Install VPlayer from the Android Market
Connect to the wifi network that has the Playon server, start up UPnPlay and start browsing until you find the content you want. A prompt will come up asking what app to play the media with, select VPlayer and it should start playing. The usual Playon streaming rules apply here; pause/rewind works and fast-forward only works if the content has already buffered to the server.

Playon channel list and Netflix queue:

Video Demo:


Technical Notes:
Motorola Droid 1 running Android 2.2 Froyo
Is rooted with custom kernel but stock Droid ROM
Apps are available in Market and don't require a rooted phone

Rabu, 12 Januari 2011

Droid Screenshots

One of my favorite games last year was Assassin's Creed: Brotherhood, and one of the cool things that came with the collectors edition was a concept art book. Today while reading Kotaku I came across a link to the concept artists Donglu Yu's blog and found they make excellent Android wallpapers.

The panning affect when moving between workspaces is really cool, and below I tried to replicate it with a few screen shots from my rooted Droid. I should also note that I used my excellent Chrome cr-48 netbook and the cloud photo editing site Picnik putting these images together.

SETTING ENVIONMENT Variable JAVA

Buka system properties (My computer > klik kanan properties atau tekan tombol Windows + Pause Break) klik menu environtment variables.
System Properties Windows
System Properties Windows
Muncul jendela environtment, tambahkan System variables baru dengan menekan “New”.
Environment Variables
Environment Variables
Kemudian isikan variabel berikut
Name: JAVA_HOME
Value: [folder instalasi java] C:\Program Files\Java\jdk1.6.0_16
Menambah value JAVA_HOME
Menambah value JAVA_HOME
Masih di bagian System Variables Edit juga variabel PATH di System Variables, tambahkan  teks ini %JAVA_HOME%\BIN
Edit variable
Edit variable
Setelah semua setting telah masuk uji dengan mengetikkan perintah javac di command promt
Perintah javac di Command promt
Perintah javac di Command promt
Apabila telah berhasil muncul bebagai keterangan diatas maka setting variabel telah terselesaikan. Selanjutnya anda dapat mengkompile file skrip java anda.

Senin, 10 Januari 2011

Billysan291 on deviantART

Billysan291 on deviantART: "Art - community of artists and those devoted to art. Digital art, skin art, themes, wallpaper art, traditional art, photography, poetry / prose. Art prints."

Sabtu, 01 Januari 2011

TW Cable Modem Status Chart

Chart of our Time Warner cable modem going on and offline. Someone is coming out to replace the line from the alley to the house which hopefully fixes it.


Script that generated data, originally was so I could tell the cable tech when the connection dropped and then I used the data over a few days to make the above graph.
watch.sh

#!/bin/bash
IP=8.8.8.8

while true; do
DATE=`date +"%D %r"`
if ping -c 1 -W 2 ${IP} 2>&1 >/dev/null; then
echo "${DATE} - Ping successful"
else
echo "${DATE} - Ping unsuccessful"
fi
sleep 60
done
 
support by: infomediaku.com