Get jQuery selector array indexed item

In jQuery, to get a single indexed element from an selector array, you need to use the jQuery syntax.

Below is an example of using eq to set CSS for a particular paragragh:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>

<script>
$(document).ready(function(){
$("p").eq(1).css("color", "red")
});
</script>

</head>
<body>
<p>This is just a test.</p><p>So is this</p>
</body>
</html>


CSS ie8 Only

CSS ie8 only fix is easy to do, if you use the beta version of Internet Explorer 8, the following conditional tags may not be working

<!--[if IE 8]>
According to the conditional comment this is Internet Explorer 8<br />
<![endif]-->

You may like to try the method below:

<!--[if IE 8.000]>
According to the conditional comment this is Internet Explorer 8<br />
<![endif]-->

Install and Play Guild Wars on Ubuntu Wine

This article teaches you how to install and play Guild Wars under Wine on Ubuntu system.

  1. First download the script from here.
  2. By default, the script is for Edgy, but if you are using Breezy, Dapper or Gutsy, it is easy to convert it to use on any of them. Just replace the word ‘edgy’ in the line “wget http://kegel.com/wine/edgy.sh -O ~/winestuff/pkgs.sh” with breezy or dapper or gutsy.
  3. To run the script, fire up your Ubuntu Terminal and type in ’sh’ with a space followed by the path to the script you downloaded, for instance:
    sh /home/winebuild.sh

Install and Run Ventrilo on Wine Ubuntu

To make Ventrilo work on Ubuntu Wine is easy.

  1. Fire up your Ubuntu Terminal and install the following packages:
    sudo apt-get install wine libwine libwine-alsa cabextract
  2. download Ventrilo if you haven’t already done so, at the time of writing, it’s URL is at:
    http://www.ventrilo.com/download.php
  3. Extract Ventrilo
    mkdir ~/ventrilo
    cd ~/ventrilo
    cabextract /path/to/ventrilo-2.2.0-Windows-i386.exe
  4. Edit the system.ini file:

    ~/.wine/drive_c/windows/system.ini

    Add the line below:

    MSACM.msgsm610=msgsm32.acm
  5. Next you need to get the windows file ‘msgsm32.acm’ from an existing windows partition (C:/WINDOWS/system32/msgsm32.acm) and copy it to ‘~/.wine/drive_c/windows/system/’.
  6. Run Ventrilo:

    cd ~/ventrilo
    wine ./Ventrilo.exe

Ubuntu share Internet connection

To share Internet connection on Ubuntu is easy.

  1. First, configure the network card that interfaces to other computers within your network

    ifconfig ethX 127.0.0.1

    ethX is the network card and 127.0.0.1 is your desired server IP address

  2. Configure the NAT

    iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE
    echo 1 > /proc/sys/net/ipv4/ip_forward
  3. Install dnsmasq and ipmasq using apt-get

    apt-get install dnsmasq ipmasq
  4. Restart dnsmasq

    /etc/init.d/dnsmasq restart
  5. Reconfigure ipmasq to start after networking has been started

    dpkg-reconfigure ipmasq
  6. Repeat steps 1 and 2
  7. Add the line “net.ipv4.ip_forward = 1″ to /etc/sysctl.conf

    gedit /etc/sysctl.conf

Update Firefox on Ubuntu

Ubuntu updates software versions every six months. Mozilla, on the other hand, upgrades its Firefox every month or two, sometimes every week. These Firefox updates come with critical security patches or new feature-based releases. Ubuntu often includes security patches with its own versions a day or a week after Mozilla releases their patches, but many Ubuntu users think this is not good enough and would prefer to synchronize the latest version of Firefox with Mozilla instead of using the Ubuntu build of Firefox.

To download Firefox from the Mozilla website and use that instead of Ubuntu’s Firefox and install Firefox to the /opt/ directory is easy.

There is a automated way to do so. Ubuntuzilla is a script that automatically detects and downloads the latest version of Firefox, it allows you to select your locale, and it verifies the overall integrity of the download.

You can download it at:
http://ubuntuzilla.wiki.sourceforge.net/

Hope this helps! :)

Ubuntu Snagit

Ubuntu’s equivalent of Snagit is Desktop Data Manager. And you may already guessed, Desktop Data Manager is free!

Desktop Data Manager functions just like Snagit. The difference between Sangit and print screen is the fact that Snagit allows you to drag and select certain portion of the screen and print screen for just that selected section.

It is hosted on SourceForge, and for those who wanna try it out, just visit the website at: http://data-manager.sourceforge.net/

Install and Run Nessus on Ubuntu

Nessus is one of the best proprietary comprehensive vulnerability scanning software, to install Nessus on Ubuntu is easy and simple:

1. Fire up your Ubuntu terminal and type in the following command to download the software:

sudo apt-get install nessusd nessus nessus-plugins

During the installation, it will ask you to create a Certificate, accept defaults, change location, state, etc are optional, change them if you like.

2. Execute the following command:

sudo update-rc.d nessusd defualts

3. Start Nessus:

/etc/init.d/nessusd start

4. Add new user:

sudo nessus-adduser

Now, when you come to “policy for this user” read the nessus-adduser man page for nessus-adduser. I wanted to be able to scan any host, so i chose “default accept”.

5. Restart nessud:

/etc/init.d/nessud restart

6. To run the program, type

nessus

Ubuntu Change resolution and refresh rate in X.Org

This article teaches you how to change resolution and refresh rate in X.Org Server on Ubuntu.

1. Fire up your Ubuntu terminal and run the following command to backup your configuration file

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_backup

2. Reconfigure X.Org
Notice that auto detection of devices works best when X.Org server is not running. Therefore it’s recommended to stop X before reconfiguring this will put you to text only mode / command line:

sudo /etc/init.d/gdm stop

(or kdm for KDE)

You can do the whole X configuration process by entering:

sudo dpkg-reconfigure xserver-xorg

To start Gnome/KDE again:

sudo /etc/init.d/gdm start

(or kdm for KDE)

3. Test configuration without restarting X

sudo xinit -- :2

4. Edit xorg.conf file

sudo nano /etc/X11/xorg.conf

5. Debug using the log file

The log file is at: /var/log/Xorg.0.log, contains lots of invaluable debugging information about what’s going on as Xorg starts. Watch for lines with EE (errors) and WW (warnings).

6. Edit or add HorizSync and VertRefresh lines

Find your monitors manual (manufacturers website and Google are useful).
Look for hozizontal sync and vertical refresh rates, also if bandwidth or maximum dot clock / pixel clock is mentioned, write it down.

Edit xorg.conf and put correct values to your xconf.org’s Monitor section. Something like this:

Section "Monitor"
    Identifier    "CM752ET"
    HorizSync     31-101
    VertRefresh    60-160
EndSection

7. Add custom modeline
If you know what your monitor can do, for example 1024×768@75Hz, you can use this page to generate a custom Modeline for you xorg.conf:

online modeline generator

Copy paste the new Modeline to Monitor section (for example):

# 1024x768 @ 75.00 Hz (GTF) hsync: 60.15 kHz; pclk: 81.80 MHzModeline "1024x768_75.00"  81.80  1024 1080 1192 1360  768 769 772 802  -HSync +Vsync

Watch that the hsync is in range with the HorizSync on the same section (in this example the range is 31-101 and this modelines hsync is 60.15, so we’re safe). Also the VertRefresh and the refresh rate you selected (75Hz in this example) should match - in this example VertRefresh is 60-160 and modeline is 75Hz, so that’s all good.

Now you can select the default resolution and colordepth by tweaking the Screen section. It should look something like this:

lSection "Screen"
    Identifier    "Default Screen"
    Device        "NVIDIA Corporation NV34 [GeForce FX 5200]"
    Monitor        "CM752ET"
    DefaultDepth    16
    SubSection "Display"
        Depth        16
        Modes      "1024x768_75.00"
    EndSubSection
EndSection

Monitor name here (CM752ET) matches the Identifier on your Monitor Section. Device line here matches the identifier on your Device section - you get the idea? It ties together some settings for your screen - the graphics card and your monitor. You may have more Subsections here, but only one is needed.

Change the DefaultDepth to what you would want it to be, 16 (65536 colors) or 24 (16M colors). Change the Modes line to match the resolutions you want to use - Depth must match DefaultDepth (here it’s 16).

Save the config. If you’re in X, hit CTRL+ALT+BACKSPACE to restart X (if you’re running logon manager like xdm, kdm or gdm). Change between virtual consoles with CTRL + F1 F2 F3 and so on - your X should be on F7.

Starting the X:
startx OR sudo /etc/init.d/gdm start (in KDE it’s kdm)

If that doesn’t work, try fixing the xorg.conf or get back to your original by copying the backup over your changed one with:

sudo cp /etc/X11/xorg.conf_backup /etc/X11/xorg.conf

When you’re back in X, you can cycle through different modes by pressing CTRL+ALT++ (plus sign on numpad), or go to System->Preferences->Screen Resolution.

8. Adjust position of your screen

Open terminal(Applications->Accessories->Terminal), run xvidtune (type: “xvidtune”), adjust the screen and hit Show-button. You’ll see a line with something like this on the terminal screen:

"1280x1024"   157.50   1280 1332 1492 1728   1024 1025 1028 1072 +hsync +vsync
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_backup
sudo nano /etc/X11/xorg.conf

In Monitor section, add the above line with a prefix “Modeline”, like this:

Modeline "1280x1024"   157.50   1280 1332 1492 1728   1024 1025 1028 1072 +hsync +vsync

There is no need to restart X if you did make the change (hit Apply in xvidtune), but you should test that this new change works. Press ctrl+alt+backspace to restart X. If it doesn’t work, you can copy back the old configuration file using:

sudo /etc/X11/xorg.conf_backup /etc/X11/xorg.conf

To restart X:

sudo /etc/init.d/gdm start

Set Ubuntu up for Wake-on-LAN

To set up your Ubuntu system for Wake-on-LAN (WOL, WoL) is easy and straight forward.

1. Go to your BIOS, and turn on WakeOnLAN (it varies, look for it or one with similar name). If your network card is onboard, go to step 2b, otherwise, go to step 2a first.

2. Back in Ubuntu, Kubuntu, Xubuntu, we now need to write a script that will run every time the computer is on, because this command only lasts until the computer is turned on once again.

2a. Find out what network device you want to have the computer wake-able from, usually all, which is just one. If you have more network devices in your system, 9 chances out of 10, you already know what they are called.
You can NOT wake up a laptop or desktop that is only connected via wireless with Wake-on-LAN, unless the BIOS has a method for this, this is rarely the case, and I do not guarantee this will work in such cases.

In your terminal, type:

ifconfig

You’ll get something like: (I have removed my mac address for security)

eth0    Link encap:Ethernet  HWaddr 01:23:45:67:89:ab
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:f2ff:fe6f:3487/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:71495 errors:0 dropped:0 overruns:0 frame:0
          TX packets:76190 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:23164212 (22.0 MiB)  TX bytes:7625016 (7.2 MiB)
          Interrupt:217 Base address:0xd400
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1290 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1290 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:161182 (157.4 KiB)  TX bytes:161182 (157.4 KiB)

So, I want this system to be ‘wakable’ from eth0.

2b. Now we create the script.
Take note that you must be an administrator of the system you are doing this to.

sudo -i

Enter your password at the prompt. Change to the startup script directory and start editing a new file:

cd /etc/init.d/
pico wakeonlanconfig

Paste or type this into the file, replacing eth0 with your network device, repeat the ethtool line as many times for your devices before the exit line:

#!/bin/bash
ethtool -s eth0 wol g
exit

Set the permission of the file:

chmod a+x wakeonlanconfig

Make the script run on startup:

update-rc.d -f wakeonlanconfig defaults

You should see the terminal responds with something like:

Adding system startup for /etc/init.d/wakeonlanconfig ...
   /etc/rc0.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
   /etc/rc1.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
   /etc/rc6.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
   /etc/rc2.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
   /etc/rc3.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
   /etc/rc4.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
   /etc/rc5.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig

Now we finish by running it, and making sure there is no error.

/etc/init.d/wakeonlanconfig

This should produce no output and put you right back at the prompt you started at.

3. Use it. you’ll need something to send Wake-on-LAN packets with, “wakeonlan” is in the repositories. And you’ll need the mac address of the system.

To get your MAC address, on the same system you just enabled WOL on, type:

ifconfig | grep HW

It is the thing that looks like 01:23:45:67:89:ab , write it down.
turn off that system:

sudo halt

If your using wakeonlan from the repositories, and you are on the same network as the computer your tying to wake up, replace 01:23:45:67:89:ab with your mac address and do, from another computer:

wakeonlan 01:23:45:67:89:ab

In most cases, you could send wake on LAN packets from a wireless connected computer.
If that doesn’t work, its likely the port on the system your trying to wake up isn’t the default (9), try 7, or if your BIOS settings or book told you one, use that one.

wakeonlan -p 7 01:23:45:67:89:ab

If that STILL doesn’t work, make sure wakeonlan is enabled in your BIOS and your hardware supports it.