Archive for May, 2009
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.
JavaScript and condition
Posted by admin in JavaScript Core on May 31, 2009
In JavaScript’s if else condition, you can use ‘and’ to add more than one condition to check. In the example below, you could see the syntax:
<script>
var firstAnswer = 'correct';
var secondAnswer = 'correct';
if (firstAnswer == 'correct' && secondAnswer=='correct') {
alert('Both answers are correct.');
}
</script>
From the example above, you could see that by using ‘&&’ sign, you combined the two conditions to check, if both first answer and second answer are correct, it returns the alert that both answers are correct.
Hope this helps! ;)
JavaScript validate dropdown menu
Posted by admin in JavaScript Core on May 29, 2009
Dropdown menu JavaScript Validation is an essential part of Front-end form data validation. To validate a dropdown menu is to check if one of the options is selected by the end user. Below is an example:
<form action="submit.htm" onsubmit="return validate_form();" name="survey_form" method="post">
<select name="car">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<input type="submit" value="Submit">
</form>
<script type="text/javascript">
function validate_form() {
if ( document.survey_form.car.selectedIndex == 0 )
{
alert ( "Please select car brand." );
return false;
}
}
</script>
Groove Armada – Lovebox

Groove Armada - Lovebox
Groove Armada – the British Electronic duo released an album named Lovebox back in 2002. Song Easy comes with strong British music signature. The entire album can’t break out of the group conformity, a typical house music album with nothing particularly outstanding. But this overall unnoticeable album, when it plays in the background, injects funky chemical into your brain and forms a groovy ambiance around you. A decent album though not a great one.
PHP convert hour 24 to 12
In PHP, to do time formatting is very simple. If you have hour formatted in 24 hours format and you want to change it to a 12 hours format in am and pm, it is very easy. Below is an example to change 13:30 to 1:30 pm:
<?php time_in_12_hour_format = DATE("g:i a", STRTOTIME("13:30")); ?>
Hope this helps! ;)
Rilo Kiley – More Adventurous
Rilo Kiley, with the deep Fleetwood Mac influence, produced an album that is feral. “It’s a hit” is like a mordant satire to the society with lyrics “Any asshole can open up a museum. Put all of the things he loves on display…” Countrified melodies resonate among indie spirited teenagers and 80′s country music mavens alike.
Franz Ferdinand – Womanizer
Franz Ferdinand cover Britney’s song Womanizer, pretty funny :)
jQuery Find Next Element nextSibling
Posted by admin in JavaScript Library on May 16, 2009
In jQuery, to find the next sibling of in reference of an element is easy. Instead of using the default JavaScript function nextSibling, you should use the jQuery version of the function – next(). Below is an example:
<!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(){
var $curr = $("#start");
$curr.css("background", "#f99");
$("button").click(function () {
$curr = $curr.next();
$("div").css("background", "");
$curr.css("background", "#f99");
});
});
</script>
<style>
div { width:40px; height:40px; margin:10px;
float:left; border:2px blue solid;
padding:2px; }
span { font-size:14px; }
p { clear:left; margin:10px; }
</style>
</head>
<body>
<div id="start"></div>
<div></div>
<div><span>has child</span></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<p><button>Go to Next</button></p>
</body>
</html>
jQuery appendChild equivalent
Posted by admin in JavaScript Library on May 14, 2009
In jQuery, the use of JavaScript is simplified. jQuery has its own appendChild equivalent which is used to append content to the inside of matched element.
If you use jQuery to select an element, and to append content, the syntax is like below:
$("p").append("<strong>Arctic Monkeys</strong>");
As you can see, this is very easy to use and comes in relly handy when perfoming content population task using JavaScript.
Hope this helps!
jQuery Get Form Value
Posted by admin in JavaScript, JavaScript Library on May 13, 2009
In jQuery, if you use the library’s selector to select a form element, and get value of the element, you can’t use JavaAcript’s default .value to retrieve the value. To get the form value, you need to use val( ). For instance ,if you have a form input field with the id=”username”. To get the value of the field, you need a function like the one below:
var usernameValue = $("#username").val();











































