Jared's techno blog

Wednesday, December 29, 2004

Install Java and plugin for firefox on Debian

Install Java and plugin for firefox on Debian

Tuesday, December 28, 2004

Nate's Debian Tips

"Enabling your wheel mouse in XFree

Like most everything else, this isn't too hard provided you get the right information!

XFree treats the wheel as two extra buttons on the mouse, in my case as buttons 4 and 5. My particular wheel mouse is a PS/2 MS clone with two buttons on either side of the wheel. The wheel acts as the third button so 3-button emulation isn't required.

Here is the relevant portion of my /etc/X11/XF86Config-4 file:


# **********************************************************************
# Core Pointer's InputDevice section
# **********************************************************************

Section 'InputDevice'

# Identifier and driver

Identifier 'Mouse1'
Driver 'mouse'
Option 'Protocol' 'IMPS/2'
Option 'Device' '/dev/mouse'
Option 'Buttons' '5'
Option 'ZAxisMapping' '4 5'

EndSection"

Testing On Stable

Configuring apt-get to install TESTING stuff on top of STABLE system

APTRemovng packages

Removing packages from a Debian system

If you no longer want to use a package, you can remove it from your system using APT. To do this just type: apt-get remove package. For example:

# apt-get remove gnome-panel
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
gnome-applets gnome-panel gnome-panel-data gnome-session
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
Need to get 0B of archives. After unpacking 14.6MB will be freed.
Do you want to continue? [Y/n]

As you can see in the above example, APT also takes care of removing packages which depend on the package you have asked to remove. There is no way to remove a package using APT without also removing those packages that depend on it.

Running apt-get as above will cause the packages to be removed but their configuration files, if any, will remain intact on the system. For a complete removal of the package, run:

# apt-get --purge remove gnome-panel
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
Need to get 0B of archives. After unpacking 14.6MB will be freed.
Do you want to continue? [Y/n]

Note the '*' after the names. This indicates that the configuration files for each of these packages will also be removed."

neighbour table overflow

neighbour table overflow:

"I recently install Debian on my new box and finally realized that the kernel issued 'neighbour table overflow'. I figered out that this was because my internet loopback device was not activated though part of the kernel. "

/etc/network/interface file should have:

auto lo
iface lo inet loopback
iface eth0 inet dhcp

How to stop X from starting automatically?

> > I am wondering how to prevent X-windows from starting up when I boot my
> > server. I looked at the run levels and didn't see something obvious. The
>
> Doesnt changing runlevel from 5 to 3 do?

Depends on the distro. For example, Debain seems to like to run as 2,
whether you get automatic-X-Window or not.

If you have a system that doesn't have separate runlevels (e.g., 3 & 5)
for text or X, look to see if XDM, GDM, KDM or some other alternative,
is being started in (for example) your /etc/rc2.d/ directory.


I use KDE on my Debian box here at home (Gnome on my Debian box at work).

My runlevel is the default shipped with Debain:

kendrick@amiga:~$ /sbin/runlevel
N 2


KDM, the KDE Display Manager (the login thing you get when X first comes
up, when it comes up automagically) is started by a script inside
/etc/rc2.d/ ... "S99kdm"

(S for Start, 99 for "do this as one of the last things)


That is, in fact, a symbolic link to "../init.d/kdm" (aka /etc/init.d/kdm),
which is the actual shell script which invokes the KDM process itself
(which happens to be the binary "/usr/bin/kdm").

Whew! Confused yet!?


Anyway - to disable KDM on my box, I would do:

$ su - [ switch to root ]
Password: [ enter root password, of course ]

# cd /etc/rc2.d/ [ go into runlevel 2's directory ]
# rm S99kdm [ remove KDM from the startup ]

-- or --

# mv S99kdm not.S99kdm [ simply rename it 'out of the way' ]


Note that deleting it ("rm") is perfectly safe, since it's a symbolic link:

$ ls -l /etc/rc2.d/S99kdm
lrwxrwxrwx 1 root 13 Dec 12 2001 /etc/rc2.d/S99kdm -> ../init.d/kdm



To get it back, you simply make a new symbolic link:

# cd /etc/rc2.d/
# ln -s ../init.d/kdm S99kdm [ make a link to "kdm" in the 'init.d' dir.,
and call it, in this directory, "S99kdm" ]


Now, I haven't really ever disabled/reenabled KDM (or GDM, at work) on my
Debian boxes, so I'm not sure if, after making the change, doing a
"telinit" (e.g., "/sbin/telinit 2") would actually DO anything,
since we're already in that runlevel.


You can, however, use the script (either the real one, in "/etc/init.d/",
or the symlink in "/etc/rc2.d/") to start and stop the service:

# /etc/init.d/kdm stop

-- and --

# /etc/init.d/kdm start

Monday, December 27, 2004

ASP.NET Development Center Home: Build Your ASP.NET Pages on a Richer Bedrock


build into Page Object:

Trap the Browser Refresh
Tell which control to set focus upon Page Load

Detecting Page Refresh

Page Refresh12.11.2004
Introduction

A common problem that Web Application Developers encounter is how to stop the user from refreshing the page. This is a problem if the previous request to the server was a PostBack, which, for example, inserted the WebForm’s data into a database. The result: duplicate rows in the database. The answer to this problem is that you can’t stop the user from refreshing the page, however there is a way to determine if this event has occurred.

In his article “Build Your ASP.NET Pages on a Richer Bedrock” Dino Esposito outlined a mechanism to detect a page refresh. This method is cumbersome and more complicated than necessary, although the fundamental idea is sound and forms the basis of this solution. Dino’s mechanism uses a counter stored on the page and a session variable to store the previous request’s counter on the server, if the two match then we have a page refresh.
A Simpler Method

Keeping the whole process within a base Page Class ensures that the mechanism is completely encapsulated (and simple to implement) and if we use ViewState we eliminate the need to use an additional hidden field. Also, as we simply want to test if the two storage devices contain the same value, we can use two boolean variables, which further simplifies the process.

The last decision to make is where, in the Page’s lifecycle, should the process take place. As we are using ViewState it would seem logical to perform the operation in the LoadViewState and SaveViewState methods. Using these two methods, and not the OnLoad method, has further benefits in that it eliminates potential problems with sub-classes implementing Page_Load.
How The Process Works

The LoadViewState method, which is part of the Page’s initialisation phase, is only invoked during PostBack and therefore SaveViewState is the only method, of the two ViewState related methods, to be called when the page is first requested.

protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] allStates = new object[2];
allStates[0] = base.SaveViewState();
allStates[1] = !_refreshState;
return allStates;
}

Note: _refreshState (which on initial page request is defaulted to false and on subsequent PostBack requests is the value of ViewState) is assigned to the Session["__ISREFRESH"] item and the negated _refreshState is saved to the new ViewState.

Once a PostBack event takes place the LoadViewState method is called.

protected override void LoadViewState(object savedState)
{
object[] allStates = (object[]) savedState;
base.LoadViewState(allStates[0]);
_refreshState = (bool) allStates[1];
_isRefresh = _refreshState == (bool) Session["__ISREFRESH"];
}

Note: The _refreshState is retrieved from ViewState and compared with the value in the Session["__ISREFRESH"] item. The result is stored in _isRefresh, which is used by the IsRefresh Property.

The listing below shows the entire class definition:

namespace StevenBey.Web.UI
{
public class Page : System.Web.UI.Page
{
private bool _refreshState;
private bool _isRefresh;

public bool IsRefresh
{
get
{
return _isRefresh;
}
}

protected override void LoadViewState(object savedState)
{
object[] allStates = (object[]) savedState;
base.LoadViewState(allStates[0]);
_refrehState = (bool) allStates[1];
_isRefresh = _refreshState == (bool) Session["__ISREFRESH"];
}

protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] allStates = new object[2];
allStates[0] = base.SaveViewState();
allStates[1] = !_refreshState;
return allStates;
}
}
}

Testing The Process

<%@ Page Inherits="StevenBey.Web.UI.Page" %>


Detecting Page Refresh





IsRefresh = <%= IsRefresh %>



Clicking the “Test Refresh” button invokes a PostBack, however the value of IsRefresh doesn’t change until you click on the browser’s Refresh button or press F5 on the keyboard (and then click “Retry”). Clicking the “Test Refresh” button once again resets the value of IsRefresh to false.

Live Demo
Conclusion

In this article I have demonstrated a simplified method of detecting a page refresh event.

Download the files used in this this article.

Saturday, December 25, 2004

Microsoft Security: IIS Lockdown Tool

Microsoft Security: IIS Lockdown Tool

After installing this,

Need to fix 2 things
aspnet_regiis -i once again

edit urlscan config at %WINDIR%\System32\Inetsrv\URLscan

add DEBUG inside [AllowVerbs]

remove DEBUG from [DenyVerbs]

Thursday, December 23, 2004

aspnet_regiis.exe to register ASP.NET with IIS

ASP.NET Forums (Logged in as: jarednevans): "was getting an error that said 'Visual Studio has detected that this server is not runnig ASP.NET 1.1', although I new I was inded running 1.1. I asked a friend about this error and he said I had to register the components. However he could't remember the command. So, I was browsing this forum and come across this post. typed in the 'C:\Windows\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i' and sure enough bam! just like that. thanks yall, I didn't even have to ask, lol. My situation was similiar as I have a brand new installation of XP SP2 and of course the Framework 1.1, as VS.NET is installed and working."

optimize large data access

optimize large data access

Posted: 12-22-2004 01:17 PM
I've been having headache for 3 days on this problem of retrieving 65,000 rows of DataTable from Oracle database. Customer needs to download the entire bill data. I tried a couple of ways of getting data, by filling DataSet or executing a DataReader, and generate a .csv file and zip it up on the server for download. But it either takes too long or gives an error of 'Page Cannot be displayed'. What is a good approach to this issue? Anybody can advise?



Re: optimize large data access
Posted: 12-22-2004 06:13 PM
You most likely need to use a FileStream to write out the data, depending on how much data there is, you might not be able or want to keep all of it in memory.

I suggest using the data reader because:

You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Results are returned as the query executes, and are stored in the network buffer on the client until you request them using the Read method of the DataReader. Using the DataReader can increase application performance both by retrieving data as soon as it is available, rather than waiting for the entire results of the query to be returned, and (by default) storing only one row at a time in memory, reducing system overhead.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcontheadonetdatareader.asp

and then writing to a file as you get more data. Consider writing every 100 rows or some other number because FILE/IO is just too expensive.
xpcoder.NET
csharpalmanac.NET"