Archive for May, 2011

Auto Web Page Changer using iframe

Monday, May 23rd, 2011

Oh I like this. In seeking to setup a rolling web browser display display at work, I came upon this small but very clever bit of javascript, which on a timer will change the web page being viewed inside an iframe. Just edit the defaults to you preferred pages and timings and away you go:

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Changing Pages… Please Wait</title>
<script type=”text/javascript”>
var frames = Array(’http://www.google.com/’, 15,
‘http://www.yahoo.com/’, 15,
‘http://www.ask.com/’, 15,
‘http://www.dogpile.com/’, 15);
var i = 0, len = frames.length;
function ChangeSrc()
{
if (i >= len) { i = 0; } // start over
document.getElementById(’frame’).src = frames[i++];
setTimeout(’ChangeSrc()’, (frames[i++]*1000));
}
window.onload = ChangeSrc;
</script>
</head>
<body>
<iframe src=”" name=”frame” id=”frame” width=”100%” height=”100%”></iframe>
</body>
</html>

I had to put a fixed height in there as 100% wasn’t giving 100% just 10% at the top of the page. This script repeats adinfinitum. If you only want it to run once, use this one:

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Changing Pages… Please Wait</title>
<script type=”text/javascript”>
var frames = Array(’http://www.google.com/’, 15,
‘http://yahoo.com/’, 15,
‘http://www.ask.com/’, 15,
‘http://dogpile.com/’);
var i = 0, len = frames.length;
function ChangeSrc()
{
document.getElementById(’frame’).src = frames[i++];
if (i >= len) return; // no more changing
setTimeout(’ChangeSrc()’, (frames[i++]*1000));
}
window.onload = ChangeSrc;
</script>
</head>
<body>
<iframe src=”" name=”frame” id=”frame” width=”100%” height=”100%”></iframe>
</body>
</html>

and it gets better! Now the next set of code does the rolling web pages, with no border on the iframe, no scrollbar on the iframe, and with a fix for full height and width in Firefox:

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Changing Pages… Please Wait</title>
<style type=”text/css”>
html, body, div, iframe { margin:0; padding:0; height:100%; }
iframe { display:block; width:100%; border:none; }
</style>
<script type=”text/javascript”>
var frames = Array(’http://www.google.com/’, 15,
‘http://www.yahoo.com/’, 37,
‘http://www.ask.com/’, 12,
‘http://www.dogpile.com/’, 14);
var i = 0, len = frames.length;
function ChangeSrc()
{
if (i >= len) { i = 0; } // start over
document.getElementById(’frame’).src = frames[i++];
setTimeout(’ChangeSrc()’, (frames[i++]*1000));
}
window.onload = ChangeSrc;
</script>
</head>
<body>
<div>
<iframe src=”" name=”frame” id=”frame” width=”100%” height=”100%” border=”0″ scrolling=”no”></iframe>
</div>
</body>
</html>

XP - Missing User Profile

Monday, May 23rd, 2011

A rare fix for a problem on XP suffered by my father following a twofold issue of full C:/ drive and a powercut! When he restarted the PC it appeared that he had lost everything, and just booted up to a new plain and empty profile.

So first off I cleared out some cruft using C-cleaner and got 1GB of space back, then moved a load of installation files to some redundant space on the PC and got back another 500mb.

Then to restore his profile I headed into: My Computer (right click) > Properties > Advanced tab > User Settings. This brings up a dialog listing the user profiles available on the PC. I identified his original profile which had been labelled back up and the new profile that had been created when he restarted. Tried to delete this new profile but couldn’t. So into Control Panel > Users and created a new user with Admin rights. Logged out, logged into the new user and went to user profiles and deleted the new profile for his main system. Logged out and logged back into the main user and thankfully his profile returned. Then deleted the newly created user account.

All done :)

Run programs without sudo ?

Saturday, May 7th, 2011

Wouldn’t normally do this, or recommend it, but for occasional and considered use this is a useful tip.You need to run a program normally requiring sudo, but as a normal user. The usual way of fixing this is to put a line in /etc/sudoers, but you still need to type sudo.The problem I had was with a custom iso I have been putting together. because my WM was openbox I was using a bash script with zenity to provide reboot and shutdown. This was all set up fine, but on installing the distro from the live cd, the installation needed to add a line to the bottom of /etc/sudoers, thereby negating my previously entered line.A long trawl through google provided an answer on ubuntuforums, which was to change the set uid bit for the shutdown command, so that all users could run shutdown with needing sudo. As you can see, doing this to a more important command would create security holes, but in this instance there is not much a hacker can do with shutdown, other than shutdown…AFAIK !!So here is the command I used:

sudo chmod a+s /sbin/shutdown

which gives the following permission:

 645 -rwsr-sr-x  1 root root    46864 2011-01-22 01:58 shutdown

I edited out the sudo shutdown in my script and replaced it with /sbin/shutdown and all is well