Subscribe to Alvin Poh's Blog by RSS reader
Subscribe to Alvin Poh's Blog by Email
Gadgets, Technology, Public speaking and IT from an undergraduate's perspective.
Recursively Download Folders using FTP with wget in UNIX (even SSH)
Okay, so you don’t have SSH access to your server, but you do have FTP access to it, and you need *all* the files in a folder.
Worse, your directory structure is many levels deep, and extremely messy. Normal FTP won’t cut it, because command-line FTP doesn’t do recursive downloading of folders. Turning off interactive mode and using mget doesn’t work too.
The easiest solution? Use wget to recursively download folders using FTP. Here’s the wget command:
wget -r ftp://username:password@yourftphostname.com/directory1/directory2/
You can replace yourftphostname.com with an IP too. So with wget, and the -r flag (for Recursive) that’s all that you need to recursively download folders using FTP. Took me a while to figure that out, but what a relief when I finally discovered how to
wget -r -c ftp://username:password@yourftphostname.com/directory1/directory2/
And if you happen to get disconnected, don’t fret, because wget has the -c flag too, which probably stands for Continue. This useful wget flag actually provides a resume function, which is very handy when you are transferring large files!
(Of course you really shouldn’t be running plain old insecure ftp when sftp is available…)
Subscribe to my blog:
RSS reader
Email
Checking your website speed
It’s interesting to know that even though the Internet is all one big connected web of sites, not everyone sees the same thing. For example, based on your location, Google directs you to a Google datacenter nearest to where you are, and the results that you get may be different from someone else living elsewhere in the world.
In addition, one other factor that location has is speed. So if a website is hosted in a datacenter in Singapore and a visitor from the US visits it, that visitor’s going to experience a slightly slower speed than someone in Singapore.
So I dug up a few free online tools that allow you to check your website speed. Some show you what speeds your website have from North America and South America, while some have a more international network.
http://www.hostpulse.com/hosting/networktools/internet-speed-test.asp
http://www.vertain.com/?sst
http://www.websiteoptimization.com/services/analyze/
Subscribe to my blog:
RSS reader
Email
Windows CMD Command Prompt Windows Keep Closing (Or Doesn’t Stay Open)
I was having a hard time with command prompt windows when I created and ran my batch files - they wouldn’t stay open and kept closing before I could see its output.
Then I discovered the PAUSE command - by adding this command to your batch file, you’ll pause the window for as long as you want, keeping it open so that you can read the output it generates!
So if you want your command prompt DOS window to stay open, then use this following piece of code in your batch file:
@ECHO OFFREM Put your main code here
ECHO Halting operation. Please press enter to continue.
PAUSE>NUL
PAUSE>NUL means that the output of PAUSE will be redirected to the NUL device. This command allows you to replace the default PAUSE message with your own, using an ECHO command before it. In this example, the user will see the message “Halting operation. Please press enter to continue.” Once the user presses enter, the command window will close.
Subscribe to my blog:
RSS reader
Email
Toastmaster Table Topic Ideas for Impromptu Speaking - Selling From Pictures
Table topics can take a persuasive stance by having table topic speakers sell a product.
How this can be done: Go to ecommerce stores and source for interesting products. Download their pictures and have the table topic speakers each choose a product to sell to the club.
The speakers should tell everyone what they think the product is and how it is used, and sell the product to the club.
Subscribe to my blog:
RSS reader
Email
Formatting a Decimal Number to 2 Decimal Places in Java or JSP
I was looking around for the class to format a number to 2 decimal places while I was coding Java, or specifically JSP, and I found it.
First, you need to import the DecimalFormat class, so have this line at the top of your Java file:
import java.text.DecimalFormat;
Or if you’re running JSP:
<%@page import="java.text.DecimalFormat" %>
And here’s the actual code that does the magic:
double price = 10.59;
DecimalFormat priceFormatter = new DecimalFormat("$#0.00");
return priceFormatter.format(price);
That’s all there is to it! Simply change the Formatting string “$#0.00″ to anything you wish. The pound (#) sign simply means there can be optional digits there. The two zero’s (0) to the right of the decimal place means that it has only 2 decimal places, and will be replaced by 0s if you don’t have digits there. Te $ sign right at the start is something that I put in, because I wanted to display my prices in dollars ($).
So for example, you can also have the formatting string as “#0.00 seconds more” and it’ll show “2343.36 seconds more”.
Subscribe to my blog:
RSS reader
Email
HTML Button That’s A Link
Making your own link button with your own custom text is easy. You might want this because it looks different from a normal HTML link (you know, the blue underlined text).
Here’s how the linkable HTML button looks like:
Sometimes you might want a linkable HTML button because it fits into your overall design look and feel as well. So here’s the code - it requires Javascript, but it’s really simple. Just copy and paste the following line of code and you’re done!
<INPUT TYPE="button" value="Link Button" onClick="parent.location='yourpage.html'">
Just replace “yourpage.html” with the URL of the page you want to click and go to, and replace “Link Button” with whatever words you want your button to show.
Subscribe to my blog:
RSS reader
Email
15 Oct 07 | 


