Category Archives: Manual/Reference

Htaccess – Block Evil Robots, Site Rippers, and Offline Browsers

 

Eliminate some of the unwanted scum from your userspace by injecting this handy block of code.

After such, any listed agents will be denied access and receive an error message instead. Please advise that there are much more comprehensive lists available this example has been truncated for business purposes. Note: DO NOT include the “[OR]” on the very last RewriteCond or your server will crash, delivering “500 Errors” to all page requests.


# deny access to evil robots site rippers offline browsers and other nasty scum
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^Anarchie [OR]
RewriteCond %{HTTP_USER_AGENT} ^ASPSeek [OR]
RewriteCond %{HTTP_USER_AGENT} ^attach [OR]
RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xenu [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]

Or, instead of delivering a friendly error message (i.e., the last line), send these bad boys to the hellish website of your choice by replacing the RewriteRule in the last line with one of the following two examples:


# send em to a hellish website of your choice
RewriteRule ^.*$ http://www.hellsite.com [R,L]

Or, to send em to a virtual blackhole of fake email addresses:

# send em to a virtual blackhole of fake email addresses
RewriteRule ^.*$ http://s2.spampoison.com [R,L]

You may also include specific referrers to your blacklist by using HTTP_REFERER. Here, we use the infamously scummy domain, “asae.org” as our blocked example, and we use “yourdomain” as your domain (the domain to which you are blocking asae.org):

RewriteCond %{HTTP_REFERER} ^http://www.asae.org$
RewriteRule !^http://[^/.]\.yourdomain\.com.* - [F,L]

 

 

Netbeans – Tips & tricks

Here’s a few I know and find to be useful:

Removing a package:
After you remove a package in NetBeans, it sticks around as a grayed-out package in your Project view. To get rid of that, switch to Files view and delete the directory.

Alt-Insert (in Windows) opens up a Generate submenu at your cursor. A nice shortcut for quickly generating getters/setters (among other things).

Selecting a chunk of code, right-clicking and then clicking “Refactor > Introduce Method” will have NetBeans introduce a method, complete with arguments and return value. Of course you have to make sure the chunk of code only has one return value.

Sometimes when you run a build and it crashes, the Java window sticks around at the bottom. I used to just click X until Windows let me End Task, but there’s a nicer way to get rid of them. Click “Run > Stop Build/Run” and NetBeans will close the window for you. It’ll even let you close multiple applications at once.

These may seem obvious to grizzled NetBeans developers, but I thought they might be useful for NetBeans newbs like me. Anyone else have any tips/tricks to share?

Here are some from the comments:

NetBeans allows for code templates. You can even add yours on the Code Templates tab under the Editor settings on the Options window. Some examples:

Type sout and hit the tab key as a shorcut for System.out.println(“”)

Type psvm and hit the tab key as a shorcut for public static void main(String args[]) {}

Read more »

Ubuntu – Change MAC Address in Ubuntu

Sometimes it is just necessary to change MAC address (also known as ethernet address, physical/arp/hardware address or even hwaddr) of network interface in Ubuntu.
It is far out of this post’s scope to list here all possible reasons of doing it so I just listed below several ways to change MAC address under Ubuntu Linux.
All of those ways require typing commands in terminal so open it in in Ubuntu menu.

In order to see all interfaces detected by your Ubuntu as well as their MAC addresses and hardware names type the following command:

sudo ip addr

Here is sample output:

1: lo:  mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 4c:22:d0:b8:78:ae brd ff:ff:ff:ff:ff:ff
3: wlan0:  mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:19:7e:53:8c:a3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.18/24 brd 192.168.1.255 scope global wlan0
    inet6 fe80::219:7eff:fe53:8ca3/64 scope link
       valid_lft forever preferred_lft forever

It shows three interfaces: lo, eth0 and wlan0 (these are hardware names of them). MAC or hardware address is shown in link/ether line, e.g. current MAC address of eth0 is 4c:22:d0:b8:78:ae.

Change MAC address in Ubuntu using ifconfig

sudo ifconfig eth0 down

sudo ifconfig eth0 hw ether 4c:22:d0:b8:78:ae

sudo ifconfig eth0 up

Where eth0 is hardware name if the interface and 4c:22:d0:b8:78:ae is desired MAC address for it.

Read more »

Ubuntu – how to move databases

I recently wanted to move a database from one computer to another. Fortunately I found a welcome guide at linuxjournal.com. Moving the files is not really difficult, you can use FTP. Moving the database is a bit more challenging however.

If you have shell access, it’s a pretty simple process. On the old server, type:

    mysqldump -u username -p databasename > databasebackup.sql

You’ll be asked for the password assigned to “username”, and then mysqldump will create a file that contains all the information needed to restore your database. One thing to note, however, is that going between different versions of mysql can be problematic. That’s where the –compatible flag is handy. You can specify what type of database software you’ll be importing to, and mysqldump will (try) to give you a compatible file. Some options are mysql323, postgresql, mysql40, etc. Check the man page for more options and explanations about what they all do.

Read more »

Ubuntu – Create Flash video from DVD (DVD to FLV)

All the steps below are valid for any Linux, not just Debian and Ubuntu.
Simply use your distro’s package manager (YaST, Yum, Rpm, etc.) to install the necessary packages. Creating a flash video from a DVD will allow you to post it on Youtube or on your website.

1. Make sure that you have mencoder installed. Mencoder is Mplayer’s movie encoder and it can convert multiple video and audio formats.

If you have not yet installed it, do it now:

sudo apt-get install mencoder

This will install 4 packages: libfaac0 libmp3lame0 libx264-65 libxvidcore4 mencoder.

Read more »