Sunday, December 12, 2010

Time for PoE Powered Tablet

I am a little surprised about not seeing more main stream US retail outlets pushing Android based tablets, although those devices are flooding online shops such as Amazon and eBay. My un-researched guess is that the Chinese manufacturers somehow managed to miss the holiday shopping season in this country in terms of negotiating with the buyers of the large retail chains.

This weekend's local news paper showed a couple of places selling these Androids, including Best Buy, K-Mart and Staples. I went to Best Buy and looked at a couple of them briefly. I liked what I saw. Best Buy showed one live Archos 7. The touch GUI seems a little less responsive than the iPod Touch. Otherwise, I can definitely see using it to read a book or watch a video.

Back to the point in the subject line of my post. I saw a few models on eBay with Ethernet in their specs. In my first ever blog post on Sina.com two years ago, I suggested that someone should come up with a PoE (Power-over-Ethernet) powered notebook or netbook PC. Some of the netbooks were getting close to the 30W an IEEE 802.3at port could supply back then. Today's crop of Android tablets can definitely be powered and probably charged at the same time by a PoE port.

So, here is my free creative idea to the tablet makers: Create one that takes AC power from a PoE switch port. I think a lot of the doctors in my hospital will like it.

Wednesday, December 1, 2010

Turning an iPod Touch into a Wi-Fi Phone, for Free!

This is the first time that I have ever seriously touched an Apple product -- I have to admit, the iPod Touch is very slick. The wife wanted to get one to entice the kids to some cool learning materials online. So she got up early in the morning on the Black Friday and bought one.

I am more interested in turning it into something that it is not, namely, a phone. The iPod Touch G4 has all the capabilities of a smart phone minus the 3G cellular wireless circuitry. So I don't see why it should not be used as a phone.

It took me a bit of research but I did it! With all the free ingredients that you can find in Apple's App Store and free services from various voice over IP and SIP service providers. And here is the list of stuff and steps that I went through.

1. The Stuff
  • Google Voice: Google Voice is a greate product which I have been using since its GrantCentral days. It has a long list of nice features. The most importing ones for this project are the phone number it provides and its capability to dial out to a regular phone.
  • Talkatone: Unfortunately, the official Google Voice app in the Apple App Store supports the iPhone only, not the iPod Touch, which I suspect is intentional and I blame Apple for that. That is where Talkatone comes in: This little free app allows one to use Google Voice to dial out.
  • Nimbuzz: Dialing out is, of course, just one part of a phone's function. The other part is to receive calls. Nimbuzz is a SIP client app that allows one to do that, and more.
  • SIP Service: These days one can find many SIP service providers. I have used Gizmo5, SIPphone (on Ubuntu) and SIPgate. I assume that many if not all would work for this project, I have only succeeded in using Gizmo5.
2. The Dance Steps

Of course, I assume that you have registered your iPod Touch through Apple's iTunes, which by the way, I found to be a not-so-hassle-free process. At this point, you should be able to purchase apps from the App Store -- By the way, I recommend the Google App although it is not needed for this project. So go ahead and get Talkatone and Nimbuzz.

First, you have to have a Google account and a Google Voice account. They are all free and you can register one with any existing email address. The official Google Blog states that you may actually use an OpenID to log into your Google account if your favorite email provider supports that, such as Yahoo!. You need to have a phone to get a Google Voice account as Google requires you to enter a verification code to start that Google Voice account.

Second, you need to have a VoIP service for receiving calls. If you have an existing Gizmo5 account, that would be fine. If not, SIPgate seems to be a nice alternative. It is easy to find other SIP service providers just by Google search. The only thing you need is a phone number that you can register in your Google Voice account for it to forward incoming calls to.

Third, configure Nimbuzz with your SIP service.

Forth, you need to register your SIP phone number in Google Voice and configure it to forward calls to that number -- In my case, I used Gizmo5 as shown in the screen shot above.

At this point, your iPod Touch should be able to receive calls to your Google Voice number. It should be made clear here that Google Voice routes the caller's phone call to your SIP number, which means that if the caller has to pay for long distance call, there may be a charge involved even though they may be local to your Google Voice number.

Finally, install and configure Talkatone with your Google account. Talkatone seems to be easy enough. Upon start, it shows your Google account contacts. The only thing that took me a while to figure out is getting the dial-pad out to make a call: You double-tap the title bar to pop up the Google Voice menu, the click the Google Voice VoIP call item, a phone dial-pad shows up.

At that, your iPod Touch is converted into a Wi-Fi mobile phone which is able to make and receive calls using your Google Voice number.

It took me a little while to figure out how to make a call in Talkatone -- It seems to be OK if I want to call a person in my contact list as Talkatone shows the contact list. But what if I just wants to dial a phone number? Turns out, double tapping the title bar in Talkatone brings up the Google Voice menu. After that, it became intuitive.

It should be said that the the dial-pad in Talkatone and Nimbuzz are quite similar. So it may get confusing as which app should be used for dialing out. What I think could be done is to put the Nimbuzz icon to a different page.

Call quality is quite satisfactory as long as there is a reliable Wi-Fi signal. I tested it in the parking lot of Community High School while waiting in my car. Plugging in an earphone helps a little but is not an requirement. My entire project took two evenings of research and testing. Hope this post helps if others want to try.

[2011-03-11] -- Google has recently announced that the Gizmo5 service will be discontinued as of April 3, 2011. So the part about using Gizmo5 in this article has to be replaced using something else, such as SIPgate One. I have successfully configured that with sipdroid on an Android phone, so I don't think there is any reason for it not to work with Talkatone.

[2011-11-25] --  Follow this guide to make free SIP calls on an Android phone. Maybe I'll write another piece specifically about Android phones if I have a good way to capture some screen shots.

Friday, November 19, 2010

Windows Server 2003 Scheduled Task Problem

This problem popped up for the second time today: When scheduling a weekly task on a Windows 2003 server, I got this error message:
0x80090016: keyset does not exist
A simple Google search led me to this Microsoft Knowledge Base article,

But I could not find the registry entry mentioned in that article, at all:
HKEY_USERS\.DEFAULT\Software\Microsoft\Cryptography\UserKeys\Schedule
It seems that Windows 2003 is a beast vastly different from 2000. Some more research later, I found this blog entry by John Daskalakis. However, I could not find the registry key mentioned there either.

Fortunately, I did find this folder:
C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\S-1-5-18
So, I simply renamed that folder to something like "S-1-5-18-Not-used" and restarted the server. Problem solved.

Not sure why both articles mention "boot you computer in Safe mode", which seems unnecessary -- I had no problem renaming the folder in a Cygwin bash window.

Friday, November 12, 2010

jQuery 1.4.3 has a problem with apostrophe?

It seems that jQuery 1.4.3 has a problem with the apostrophe (' -- single quote) character in JSON data or any ISO Latin-1 code representation of characters.

In working on the drupal-nm project, I come across a port that has a description of Wei's phone, the port information dialog box would not display. I start up Firebug to see what's going on. Firebug seems to show that the JSON data is received and at least the debugger parsed that data correctly. However, my callback function to the jQuery's $.post() call was not invoked, at all.

Click on a different port without the apostrophe in the description, things work fine.

So I went to the server side of the function, trying to escape the apostrophe. I replaced the (') character with (') -- things stayed the same, no call back with the received JSON data, no sign of any error occurred in Firebug. In fact, any ISO Latin or HTML entity expression would cause the same problem.

This used to work fine with jQuery 1.3.2 -- which has different issues with the jQuery context menu plugin -- that needs a different blog post here.

For now, I am replacing (') with (’) -- copy and pasted the character into my code, not using the ISO Latin expression of (’), hope no one would notice.

[2010-11-13]: Posted a question on the jQuery Forum and received a pointer to jsFiddle.net -- a very nice tool for JavaScript testing, by the way. Created a test there, which seems to prove that the problem is not within jQuery 1.4.3. That means, the problem is likely a bad reaction between my own JavaScript components or other jQuery plugin modules I am using. I'll have to figure that out later.

[2010-11-16]: This is a known Drupal bug. To fix the bug in Drupal 6.20, replace lines 2500 - 2502 in includes/common.inc with the lines below:
      return '"'. str_replace(array("\r", "\n", "\t", "\\", "\/", "\"", "\'"),
array('\r', '\n', '\t', '\\', '\/', '\u0022', '\u0027'),
addslashes($var)) .'"';

[2011-03-29]: This problem still exists in the latest Drupal 6.20 release. Also, the JSON specification allows the apostrophe (') but jQuery's JSON parser does not.

[2011-05-02]: Drupal 6 may have a bigger problem with JSON conversion than this one bug. As it turns out, the above fix would also escape the double quotes surrounding member variable names and string values, which causes the entire JSON data object to be interpreted as a big string when received by a jQuery client end. Not good!

Wednesday, November 10, 2010

PoE Control via SNMP

A simple way to toggle the power on a power-over-Ethernet (PoE) switch port using the IETF POWER-EHTERNET-MIB (RFC 3621) object pethPsePortAdminEnable.

Here is an excerpt from POWER-EHTERNET-MIB:

pethPsePortAdminEnable OBJECT-TYPE
SYNTAX TruthValue
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"true (1) An interface which can provide the PSE functions.
false(2) The interface will act as it would if it had no PSE
function."

Setting the object to false (2) on a port turns off the power; Setting it to true (1) turns the power on.

Simple enough. The next thing is to convert an interface name (e.g., Fa0/10) to the port index (e.g., 12) -- That is different on different switches.

Monday, November 8, 2010

Error Message from Power Adapter


Recently I started to receive an error message from a Dell DA65NS3-00 Auto-Air AC Adapter on my Dell Latitude E4300 notebook PC.

That is something new to me! But I guess it does make sense for these components to become smarter. The thing is, this one seems to have been caused by a rather simple hardware problem: The adapter comes with an extension cord on the DC side. The error only occurs when I use that extension cord, the error message pops up and the laptop lose the capability to charge the battery. Without that extension cord, everything works fine.

Saturday, November 6, 2010

No Short URL on Flickr?

Kiva KoffeehouseI tried to put a Google Maps link to the Kiva Koffeehouse in the description of my photo on Flickr, Flickr keeps saying There was an error.

Posting a comment with the link, Flickr says: Hey! A URL or phrase that you tried to post has been used for abuse on Flickr before. (ex. SPAM) If that's you, stop it! If that's not you, sorry, but you can't post it.

So, Flickr seems to have effectively banned short URLs, or at least Google's short links.

That seems to be an unfair practice. But I guess Flickr has no good way to work around short linked web pages using photos shared on Flickr without linking back.

Wednesday, September 22, 2010

Flickr: Groups and Tags

Flickr is an easy to use photo-sharing web service.

I have created a Google Gadget called flickr-show to display shared photos when I needed such a tool for showing photos on the AHRP website. The gadget allows me to display a set of photos on Flickr selected by a combination of a group and some tags.

A group on Flickr is simply a way for people with similar interest to share photos. For example, I have created a group called AHCS for friends of the Ann-Hua Chinese School to share their photos about or related to the school.

Tagging is another way for people to find photos on Flickr. For example, by tagging a photo with AHCS, we allow ourselves and others to search for photos related to the school; With a tag 2010, we limit the search to photos taken in the year of 2010; Using 3 tags together, AHCS,2010,mid-Autumn, we can limit the selection of photos to those taken at the AHCS 2010 mid-Autumn gala.

Now a bit of boring instructions for joining a group on Flickr and tagging photos:
  • Group
    • Before you can add photos to a group, you have to join the group first: You go to your page on Flickr, which is called your photostream page. For example, mine is at http://www.flickr.com/photos/gswj/.
    • On that page, you will see a horizontal menu right under the Flickr icon on the top of the page. The first item is Home, then You, and so on. The 5th item is Groups with a little downward triangle next to it.
    • AHCS is an open public group, meaning anyone may apply to join. Here is the generic way to join a group on Flickr: Click the word Groups in the main menu -- not the triangle. You will see a page the groups you administer, created, and belong to, etc. You will also see a Find group search box on the right side of the page.
    • Enter AHCS in the search bar and click the Search button. The AHCS group has the Ann-Hua logo on it so you won't miss it.
    • Click the group name or logo to enter the group page. You should see a Join? link somewhere in the page. Click that to join. That sends an application to the group administrator, that is yours truly for now.
    • Go back to your photostream page. Find the Organize and Create menu item with a little downward triangle. Click on the little triangle to pull down the menu and select All your content or Most recent upload, depending on what you have.
    • That opens the Batch organizer. There, you will see your photos shown as thumbnails across the bottom of the window.
    • Right above the thumbnails, there is a Select all (very small) link. Click that to select all the photos; Or you may manually select one and the shift-click to select a group of photos.
    • Drag and drop the selected photos into the center part of the window that displays Drag items here to edit them as a batch. If you get it right, your photo thumbnails will be displayed in that area.
    • In the Batch Organizer, there is also a menu item called Send to group. Click that.
    • You will see AHCS in a list of groups you are a member of. Click it to add your photos to the group.
  • Tag
    • This should be relatively easy: We'll assume you have just done sending the photos to the AHCS group as outlined above and continue from there.
    • Right above those photo thumbnails, there is a horizontal menu item under Batch Organize labeled Add Tag. Click that.
    • You should then see a pop-up for you to enter tags. Enter AHCS 2010 2010-10 mid-Autumn and hit the Enter key.
    • You are done!
Once accepted in the AHCS group, your photos tagged with AHCS 2010 mid-Autumn will appear in this slide show.

Friday, September 10, 2010

Chat with AT&T

Thank you for choosing AT&T. A representative will be with you shortly.

All operators are currently assisting others. Thanks for your patience. An operator will be with you shortly.

You are now chatting with Stacie.

Stacie: Hi, how may I assist you today?

Wei: Hello. I need to view my high speed Internet service bill.

Stacie: Good Afternoon

Stacie: Are you wanting to view it online?

Wei: Yes

Wei: I've been trying to log in using my HSI account credentials.

Stacie: I checked your records and see that you have not registered your account. This means that you do not have a login name or a password established at this time. In order to view or pay your bill online, stop paper bills or change your services online, you'll need to register for an AT&T Account Manager.

Wei: OK. Can I do that registration online?

Stacie: To register, please use the following steps:

  1. Visit: http://www.att.com/accountregister
  2. Click "Request an Online Registration Code"
  3. Enter your AT&T Direct account number in the "Main Phone Number" field, populate the customer code, the billing address zip code and click "Continue"
  4. Select the U. S. Mail delivery method for your Online Registration Code and click "Submit”
  5. Once you have the Online Registration Code, enter it into the Online Registration Code field and click "Continue" to complete your registration pages.

Stacie: Actually, you have to wait to get the Online Registration code via US Mail

Wei: That's a bit ironic to hear from a "Phone" company. Isn't it?

Wei: Thanks for the help.

Stacie: Since you don't have a Residential Phone Line, we can't send it any other way

Stacie: We would need an email address on file for at least 30 days in order to send it that route

Wei: I have AT&T cell phones.

Stacie: It must be an AT&T Residential phone line

Wei: And I do have an email address from AT&T for my HSI service!

Stacie: I am so sorry for any inconvenience.

Stacie: Wei, the email address must be on your Account File

Stacie: Again, I am truly sorry for the dealy

Stacie: delay

Stacie: Do you want me to request the Online Registration Code?

Wei: That's OK. :-) It's not your fault. But it just makes AT&T comic!

Stacie: I understand

Wei: No. I can do that.

Stacie: We don't make it very easy

Stacie: I sure wish I could help you

Wei: Thanks for the help so far.

Stacie: Is there something else I can help you with?

Wei: That's it. You have a nice day!

Stacie: You too

Stacie: It’s been a pleasure to assist you today. My goal is to ensure you are Very Satisfied with the service I have provided. Please use the CLOSE button when you are ready to exit our chat session.

Get even more help online. Find troubleshooting tips, tutorials, product updates and more — visit our online support site, our online forums or find us on Facebook.

Friday, June 25, 2010

VirtualBox Eating Packets from Firefox?

I hit this bizzare behavior in Firefox while working on a Drupal module which uses jQuery to fetch JSON data from the server: A $.post() call to a URL on the Drupal server expected to return a JSON object would get an error 400 from the server. On the server's error log, I got this:

[Fri Jun 25 12:10:40 2010] [error] [client 10.0.2.2] request failed: error reading the headers, referer: https://server-host-name:2443/?q=alerts/wic/ug

In this case, the server is a virtual machine running Ubuntu 10.04 as a VirtualBox guest on my workstation running Windows XP Pro SP3 (well, an enterprise-built standard image, actually) as the host. Port 2443 on the host is forwarded to port 443 on the guest.

Reloading the same page in Firefox would bring back the expected results occasionally -- when the problem started to happen, it seemed that success rate was 1 out of 5 to 8. Half a day later, that dropped to 1 out of 20, which pretty much stopped my from working on the code.

So, I tried Chrome and Internet Explorer. None of them showed the same behavior.

Next, I fired up wireshark in Ubuntu. Packets captured from Chrome and IE session looked OK -- at least the HTTPS sessions were decrypted. However, Firefox sessions captured were not decrypted by wireshark.

Next, I deployed the same code to the production server. Hitting the same page in Firefox on the production server did not cause the same Firefox behavior.

In the end, shutting down and restarting the virtual machine seemed to have fixed the problem. But the whole episode left me scratching my head: It seemed VirtualBox was the most likely culprit. But why only Firefox?

Tuesday, May 25, 2010

PHP fopen() Tricks

The fopen() function in PHP allows one to read a remote file, or a web page. I recently added a feature in the logmon module to read and parse a remote syslog event definition page by its URL in the Cisco web space, such as this one documenting Cisco NX-OS events.

Here are two tricks that I have learned implementing the above feature. In my case, the server on which my code is run is on a subnet not NATted from the internal network to the outside, which means that I can not directly access an external website. There are two ways to work around this issue:
  1. Use an IP address that is NATted or accessible from the outside;
  2. Go through a proxy server.

Multi-Homed Server


Re-addressing a server may be a bit more involved especially in networking where IP addresses do get directly used a lot. However, a server may have more than one IP addresses. So if we add an IP address that is NATted or public, we can go back to work. To use a different IP address on the server for fopen(), one needs to use the forth parameter to fopen(): the $context.

Here is a little snippet of PHP code specifying source interface for fopen():

$srcip = '192.168.20.30'; // Assuming this is a NATted IP address
$context = stream_context_create
(
array
(
'socket' => array
(
'bindto' => $srcip,
)
)
);
($fn = fopen($url, "r", false, $context)) || die("Can not open '$url'\n\n");

while (!feof($fn)) {
echo fgetss($fn);
}

Proxy


Another way out of this problem is to use a proxy server that is accessible from the internal network. We do have a few of those deployed. To use one of them, we only need to make a simple change in how the $context is created in the example above:

$context = stream_context_create
(
array
(
'http' => array
(
'proxy' => 'tcp://192.168.10.10:80' // The proxy server address and port
),
)
);

Wednesday, May 19, 2010

To DNS or not to DNS: That is a question!

Here at UMHS, some of our network devices, i.e., switches and routers are named in some sub-domains in the DNS system, which provides an easy way for people to access them on the command line. For example, it is much easier to remember some-clinic.switch.med.umich.edu than 192.168.129.18.

To name our devices in a consistent way across the board, we have to decide on a device naming convention -- That is likely a common practice for all IT teams out there managing a network of any size larger than one single building. However, that presented me with this issue: Do we continue with naming the devices in DNS or not?

There are multiple ways a device in the IP networking world may be identified, DNS name is one of them, IP address(es) is another. Yet another is the SNMP MIB object SNMPv2-MIB::sysName. They each serves a different purpose: a DNS name serves humans and an IP address serves machines. The sysName object, on the other hand, serves network management systems that talk to devices using the SNMP protocol.

To minimize conflict of interests in naming a device, it is probably the easiest to make a DNS name identical to the sysName on the device. However, I have seen in more than one organizations where device naming conventions factor location and IP address information into the sysName, which in Cisco IOS is configured using the hostname command. Adopting such a naming convention effectively renders the human readability of a DNS name close to that of IP addresses. Also, synchronizing the sysName values defined in devices and their DNS names take a lot of work to do right. Some times it is a task crossing team boundaries, which is not to say it is impossible but difficult to say the least. So many a time the DNS names are out of sync with the IP addresses of devices after they are upgraded or a network is renumbered. The Combination of those two factors probably explains why I have seen many of my colleagues access devices using their IP addresses directly rather than using their DNS names.

My thoughts are that, a device should be named just for human access. Therefore embedding location and IP address in device name may seem to be a good idea but defeats the purpose of a name. After all, there is a sysLocation object in the SNMPv2-MIB and DNS exists to translate a name to an IP address. What we really need is probably a simple utility which, when given a DNS name or an IP address of a device, produces the other information such as location or whether the device really is a router or a switch.

Friday, May 14, 2010

RegexPal: 一个很好用的正则表达式测试工具

RegexPalSteven Levithan 用 JavaScript 写的一个正则表达式测试工具,用过一段时间,很不错,感觉应该介绍一下。

正则表达式是做各种文本处理常用的一种手法,最早在 Perl 语言里广泛使用,现在则在诸如 PHP、Python、Java,甚至 C/C++ 等许多语言里都经常遇到。但是要写一个正则表达式有时候不是一件很容易的事,除了试错似乎没有好的办法。

RegexPal 让你输入一个表达式和一段要分析的文本,然后以颜色标示出匹配的字段。

比如:

表达式:([\w\d\-\.]+)\s+last message repeated (\d+) times$

文本:10.20.30.40 last message repeated 2 times

Wednesday, May 12, 2010

PayPal: Almost a Complete Lie!

PayPal: Almost a Complete Lie!

I believed PayPal's advertisement of "AS LOW AS $1.50 U.S. TO SEND $300 U.S. TO COUNTRIES ..." and their fee calculator told me that sending $450.00 to China costs $2.25.

Great!

It turns out, what they does not tell me is that, the recipient will have to pay to get the money, as your money only ends up in the recipient's PayPal account. To get the money into a bank account in China, it has to be done through money transfer, for which PayPal charges a fee of $35.00.

I call that "almost a complete lie!"

You can try it out here.