Monthly Archives for July 2004
I recently moved from a home-grown blogging engine to .text (dottext), mainly because of the ‘blog anywhere’ web admin interface, and comment support. Because my old site was written by myself, it had in it most of the things I wanted. The released of .text contains many skins, but none of them were really what I was after, so I have started dabbling with skin design. You are probably reading this article on a page with my own skin. When you create your own skin or edit another you can add your own controls to the page.
Some of the user controls that I had written for my old site allowed me to syndicate some of my friends’ blogs. I wanted this functionality in my .text site, so I went hunting. As usual, it was Scott Mitchell who showed me the way, with his RSSFeed control. I have implemented a version of this in my site and I am happy with the result. See the code posted below.
Disclaimer: I am not a programmer, I am an infrastructure geek who dabbles. The below code has no error-handling, so if something goes wrong with the feed it will break your whole site. I tried to put in error handling but it didn’t work. I hope a real programmer reads this and tells me what to do.
Because I don’t want to potentially show a 2000 word post in the 200px wide box allocated, I have written a function to shorten the post to 49 characters.
<%@ Control Language="c#" ClassName="darrynRSS" Inherits="Dottext.Web.UI.Controls.BaseControl" targetschema="http://schemas.microsoft.com/intellisense/ie5” %>
<%@ Register TagPrefix="skm" Namespace="skmRss" Assembly="skmRss" %>
private void Page_Load(object sender, System.EventArgs e)
{
RssFeed1.DataSource = “http://www.darryn.net/rss.aspx/“;
RssFeed1.DataBind();
}
public string shorten(String input)
{
string shortbody = “”;
string [] a; // array of strings are square-bracketed
int j; // int not Integer
if(input == null)
{ // real quick error check to stop more serious errors
return “”;
}
a = input.Split(” “.ToCharArray()); // get our array of strings
int maxnum = a.GetUpperBound(0) ; // We actually know that 49’s max from above
if(maxnum > 49)
{
for(int x = 0; x <= 49; x++)
{ // I love C style loops
shortbody += ” ” + a[x];
}
shortbody += “…”;
}
else
{
return input; // can return any string - not sure if using the function name as the string is “done” in C#
}
return shortbody;
}
Please provide feedback below if you have a better solution, or for whatever reason.
Popularity: 3% [?]
Written on 20 July 2004
by darryn under
Uncategorized
with
Tagged with tech
Someone broke in to my car on Saturday night. I did not discover the break-in until Sunday afternoon, when I found the car to be unlocked, with the driver’s seat all the way reclined and everything scattered throughout the car. The contents of the glove compartment, door and console had been ripped out and thrown on the floor and seats. They left almost everything, money, CD’s, sunglasses, the lot. The only thing that seems to be missing is the warranty papers for my engine, which I had replaced in 2001. The thing that pisses me off is that they bumped the indicator stick, and so my battery was flat when I needed to use the car.
When I reported the incident to the police I was surprised to hear that my story was not unusual. Apparently it is very common for the seat to get reclined during a car break-in, and also the theft of papers is more common than other contents. The operator informed me that they use the papers for rebirthing stolen cars, or committing other kinds of fraud.
As Kirsten’s car is currently experiencing issues, I let her take my car to work today, and I caught the bus. This decision has a slightly disappointing consequence - just as I was about to leave for the bus I was visited by the Police fingerprint squad, who had come to dust my car for prints. If only they had told me! The nice police lady told me that a house 3 doors down had been broken into around the same time as my car so it was possibly the same perp.
*she didn’t actually say ‘perp’
Popularity: 8% [?]
I have nearly completed an article on Monitoring Bigpond Broadband usage with mrtg in Windows. It is published, but I still think it needs a bit of polish.
It is the first proper article I have written for a long time. I liked it.
Popularity: 2% [?]
Written on 15 July 2004
by darryn under
Uncategorized
with
Tagged with tech
Ok, I have done a bit more reading and thinking, and I am starting to form a picture of what it might be. I think that the reason it is so difficult for me to accept is that the whole point of Zen is to think in an intuitive way that is totally in opposition to logic and reason. My mind is perhaps more logical that most (here come the flames!) and so I have a particularly hard time with Zen. A challenge!
So I have come to the suspicion that perhaps there are other forms of thinking that differ from the way that I think. I don’t mean differences of opinion, I mean different styles of thought. It is possible that all the stupid people aren’t stupid, just different. My way is still the best, though.
This discovery has reminded me of
arguments I used to have with
Jai when she tried to explain art to me. To me, at that time, she was just talking shit, making no real sense. Perhaps instead she was just thinking differently. I think I will have to buy a Zen book. You could buy one for me, if you want. Check out my
wish list.
Popularity: 2% [?]
[update 23/7/2004: TristanK has added to the script to remove the requirement for lynx. A thousand thanks.]
Bigpond Broadband* is a cable/adsl ISP in Australia. As with almost all Australian ISPs, they provide a limit on the number of megabytes that a user may download in a month. In order to help a user monitor their usage and avoid paying astonishingly high excess usage charges (currently $0.15 per Mb) Bigpond provide a service known as the ‘Usage Meter’. Although unreliable, the Usage Meter is the best available way for a Bigpond user to monitor their quota usage, as it takes into account the ‘unmetered’ traffic (to some Bigpond internal services). Client side monitoring will not reflect the numbers that go onto a user’s bill.
Recently Bigpond has released some client-side tools to allow a user to tell at a glance what their current metered usage is. These take the form of an Internet Explorer toolbar or a small applet in the system tray. Although not incredibly useful themselves they introduced something useful - a usage meter XML feed. With this we can create our own client, and that is what this article is about.
I have developed a way to use free tools to create graphs of your Bigpond usage over time, such as the sample image below, of a week’s usage:
What you will need:
- Perl - I use Activestate Activeperl. This is a free, quality-assured perl distribution. Perl is a scripting language.
- mrtg - the Multi Router Traffic Grapher. Originally a tool for monitoring network links, its usage has been expanded by the community to be a multi-purpose monitoring tool.
- FireDaemon or srvany - Both of these tools allow you to run programs as Windows services, FireDaemon is a commercial product with a free version, and srvany is part of the Windows 2000 Resource Kit (and also the NT4 Resource Kit - maybe 2003 as well?).
- Windows Script - although you probably already have this installed, you can get the latest version from here.
- This script - this is the script that I wrote (remove the “.txt“ when you save it).
- This CFG file snippet - add this to your current CFG file.
- A web server such as IIS or Apache (not required).
I will not go into installing ActivePerl and mrtg, this is covered
extensively elsewhere. I am assuming that you are now at the point where you have mrtg running and have produced some graphs.
Add the CFG snippet to the end of your mrtg CFG file - making sure that you edit the line
Target[bpausage]: `cscript //nologo bpausage.vbs`
to reflect the full path of the script, if necessary. The next thing you will need to do is edit the script (bpausage.vbs). There are two (or five, if you use proxy authentication) things that you will need to change in the section marked “Edit Here“ your Bigpond username, and your Bigpond password (and your proxy URL, username and password. Because your username and password are stored in clear text, please do not place this file somewhere that Bad People can get to it. The actual internet connection it makes to the Usage Meter is via SSL so you are pretty safe there.
The current plan that I am on allows for 5GB of usage per month, so I have tweaked scale of the graph to be relevant to me, showing a scale from 0-6 GB. Yuo might be on a different plan, so here is how you make the graph relevant to yuo. It is these lines that affect the scale:
YTics[bpausage]: 6
MaxBytes[bpausage]: 6000
AbsMax[bpausage]: 6000
The YTics value is how many vertical sections are in the graph. The MaxBytes and AbsMax values should be set to the number of GB in your plan times 1000 (Bigpond count a gigabyte as 1000 megabytes).
The way that the whole thing works is this:
- when mrtg does its 5 minutely run, it starts the script bpausage.vbs
- the script connects to the Usage Meter and logs on as you
- the usage meter returns XML data about your usage
- the script processes the XML and outputs it in a format mrtg can understand
- mrtg processes the data and updates the relevant graphs
The output graph shows two values - the total usage (both downloads and uploads) in solid orange, and the upload usage as a blue line. Look at the sample above to get the idea. While you look, notice the little dips around Monday/Tuesday. These are evidence of the increasingly frequent cable outages in my area. If you are not like me and are only online from time-to-time, the graphs will give you an idea of how long you spend online.
I would like to thank
this project for giving me a head start, as it does basically the same thing for a *nix environment.
I hope that this article is helpful to you. Feel free to comment below, and if you find an error or make an improvement then I would love to find out about it.
*Bigpond Broadband a.k.a. Bigpond Advanced, Bigpond Cable, BPA, BPC, BCP.
Popularity: 11% [?]