Quick and Dirty Network File sharing with Python

Ever find yourself in need to share file over the network quickly, but find yourself lacking time to setup a proper NFS or samba share? Here’s a way to do this with the good old Python CLI.

  • First, go to the directory that you want to share, for example ~/Desktop
  • Then run this command "python -m SimpleHTTPServer"
  • You may access the folder from a remote computer using any webrowser using the url – http://192.168.1.20:8000, change the ip address accordingly
Simple HTTP Server
file sharing with python

You may find this technique offers limited options to share files, but its a real time saver!

BluePad: Controls Presentation from Your Phone

Recently I had todo a lot of presentations which made me thinking into getting presentation pen, but since my E71 includes a pre-installed Wireless Presenter (WiPresenter), I’ve buried that thought, who needs an expensive presentation pen when a phone can perform equally when?

Bluepad remote control

But as WiPresenter is only compatible with Microsoft Windows operating system, I’m forced to use keyboard or mouse-clicks to control my presentations when I’m using Ubuntu Linux operating system. This is a drawback as I could perform the task easily thru my phone when I’m on Windows XP.

EnterBluepad, an application which enables your mobile phone to act as a Bluetooth controller. Bluepad consists of two applications, a server and a client. The server application sits on your operating system, monitoring for incoming Bluetooth connection. The client application requires a JavaME compatible mobile phone with JSR-82 (Bluetooth) feature.

The installation is straightforward for both client and server side application, the only thing to remember is to activate bluetooth on mobile phone before starting the client application. After that, you can start OpenOffice Impress and use the the phone to remotely control the presentation.

Enabled WP-SuperCache for my blog

I’ve decided to install and enable WP-SuperCache plugin for my blog. This does not mean that I’ve been receiving thousands of site hit everyday, but as a precaution because I’ve noticed spikes of traffic on the server log that might effect the overall performance of the web server.

Since most pro-blogger suggested WP-Supercache, I might as well take their advice and install it. Hopefully this would improve the server load during the spike (which I suspect contributed by ill-behave webbots/crawler) as well as loading time for my blog.

I’ll keep my fingers crossed

How to Import export MySQL database from command line

This tip would be useful for those who are either making backup of their remote mysql database or moving their web hosting to their provider.

Here’s how to export mysql DB to SQL file using command-line utility :
mysqldump –user=username –password=1234 –databases your_database –opt –quote-names –complete-insert > example.sql

Here’s how to import the SQL back into mysql database :
mysql –user=username –password=1234 –databases your_database –host=mysql_server host

Don’t forget to add your ip address to the list of allowable host on the remote MySQL server!

How to find cause of heavy usage on your Apache webserver

Here’s a quick and dirty tips on how to find cause of heavy CPU resources usage on your Apache webserver (especially when running php scripts).

First you need to locate the Apache 2 “access.log” file. By default in Ubuntu, this file is located in “/var/logs/apache2” directory.

Then you need to run this command to find out which IP address accesses your website the most in a short time.
[code]
tail -10000 access.log| awk ‘{print $1}’ | sort | uniq -c |sort -n
[/code]

The output of the command should contain a list of IP addresses along with the number of hits it made in the last 10,000 access of your website
[code]
47 117.58.252.98
81 202.124.242.186
84 202.124.245.26
182 194.164.101.217
220 208.101.22.146
225 72.167.131.144
3946 93.135.xxx.xxx
[/code]

From here you can easily locate the offending ip address and proceed to block it from accessing your website further using .htaccess file or other blocking method.

Here is an example to block certain ip address from accessing your website using .htaccess file
[code] order deny,allow
deny from 93.135.xxx.xxx
[/code]

Save .htaccess file in the root directory of your web server (example /var/www), and the ip address wont be available to access your site again.

Hope that would help you!