BeaverBlogg

November 12, 2008

Pretty fine beaver!

Filed under: Beaver — Karl @ 11:42 pm

I found this link ages ago and wrote a post with just the link but never came around to publish it. It’s still one of the coolest things I’ve found on the internet the last years so I hope you enjoy it!

http://compubeaver.com/

Recursive generic extensionmethods are fun!

Filed under: .Net, Code samples, c# — Karl @ 11:39 pm

Just thought I should share a little piece of code with you this evening. It’s a little extension method (i.e it requires .Net 3.5) that extends Control and helps you find all instances of a certain controltype under the Control on which you invoke the method. Just put the following code in an assembly (or a .cs-file in App_Code).

To call it you just invoke FindControls<Control>() on any object that derives from Control (i.e. Page, Label, Calendar, the list can go on forever), see the sample below. Hope you find some use for it!

April 25, 2008

My most downloaded resource

Filed under: Articles, Beaver — Karl @ 1:28 pm

Last week I started wondering how many downloads my products really had had throughout the years. Seeing that I didn’t have complete statistics over the downloads since I’ve rebuilt the sites lots of times and moved servers and such. Currently, these are the download stats from CrazyBeaver Softwares homepage:

  • BeaverSFV 1.1 - 167
  • CrazyBeavers YouTube Downloader 1.01 - 6
  • CrazyBeavers Calendar Class 1.1 - 143
  • CrazyBeavers RSS Class 1.3 - 188
  • CrazyBeavers Upload Class 1.2 - 233
  • CrazyBeavers Chat 1.3 - 123
  • Imager Gallery 5.5 Prerelease - 1276
  • CrazyBeavers Upload 2.4 - 207
  • CrazyBeavers ZIP 1.0 Prerelease 3 - 69
  • Imager Resizer 2.4 - 957

Looking at this it seems quite clear that Imager Gallery and Imager Resizer would be the best candidates for downloaded products. These stats are just for the past few months though but if they’ve had similar numbers since they were released during 2004-2005 it would give quite a lot of downloads. Lets elaborate a bit further though, most of my old ASP and ISAPI/COM applications are listed on HotScripts and Aspin aswell, lets look at their popularity there to the calculation.

  • CrazyBeavers Calendar Class 1.1 - 5 565 views on HotScripts with 3 votes (4.33 average)
  • CrazyBeavers RSS Class 1.3 - 2 175 views on HotScripts with 2 votes (5.00 average)
  • Imager Gallery 5.5 Prerelease - 22 271 views on HotScripts with 74 votes (4.39 average)
  • CrazyBeavers Upload 2.4 - 3 415 views on HotScripts with 15 votes (4.20 average)
  • CrazyBeavers ZIP 1.0 Prerelease 3 - 651 views on HotScripts with 2 votes (5.00 average) - Listed under CGI & Perl though, wasn’t allowed in the ASP category
  • Imager Resizer 2.4 - 6 246 views on HotScripts with 176 votes (4.78 average)
  • Imager Gallery 5.5 Prerelease - 26 940 views on Aspin with 9 votes (5 stars)
  • CrazyBeavers 2.4 - 6 147 views on Aspin with 1 votes (5 stars)
  • Imager Resizer 2.4 - 17 325 views on Aspin with 37 votes (5 stars)

Now thats some numbers, over 22 000 views of Imager Gallery on HotScripts and almost 27 000 on Aspin. If we go a bit crazy and assume that a third the of people (probably it would be closer to a quarter of the people but that isn’t as fun to count with) also downloaded the script we would have 16 000 downloads of Imager Gallery there! If we then add the numbers we would have 17 000 assumed downloads which is quite a lot. Still, Imager Gallery is only the second most downloaded of my products. The true winner, and the only product which I know for sure how many times it has been downloaded, is CrazyBeavers Winamp Controller. Counting in at 25 239 downloads since January 27th, 2005 its by far the most downloaded product I ever created and one of the few that I don’t use myself!

This article was just a little ego boost for myself but it feels so damn good that people actually seem to appreciate my work enough to download it over 20 000 times!

April 19, 2008

CrazyBeavers YouTube Downloader

Filed under: .Net, Beaver, c# — Karl @ 4:56 pm

It’s been a while now since there was a new release from CrazyBeaver Software so I thought I should make some fuzz about it and talk about it here as well.

A few weeks ago a friend of mine asked if I knew any way to save a video from YouTube onto his harddrive so he could use it in his school presentation. A quick search on google turned up few services that could download the .flv for you which was pretty neat though not enough since it would require that the schools computers could play .flv, which they can’t. My idea then was to make a simple wrapper for FFmpeg (a great open-source tool for recording and converting audio and video streams) and let him use that for conversion. The goal at this time was to make it easy for him to do this without my help in the future and maybe to let my other classmates do it as well. It worked out pretty well in the end and I now have a really neat C# wrapper for FFmpeg.exe which I hope to release some day for everyone to use. It was however not really satisfied with this, my application only did half the job, and the easy part was what was missing. I went looking around the net a bit for solutions on how to download the .flv-files from YouTube and found several ways which had their advantages and drawbacks. In the end, I borrowed a few ideas from most of them and got my own working solution for getting the .flv-files.

CrazyBeavers YouTube Downloader 1.01

The result of this was the brand new CrazyBeavers YouTube Downloader which was released yesterday as version 1.0 and earlier today as 1.01 (just love the early bugs, so simple, so devastating). I’ve seen another program out there that does the same as mine but seeing the page I found it on i didn’t really want to download and run that .exe so hopefully this will be of use to more then just my class now.

With this release I also returned to NSIS (NullSoft Install System) for the installation which works a ton better then the Visual Studio setup projects I’ve used for BeaverSFV. I’ve scripted it to check for .Net 2.0 and if not it will download and install it. It also checks if the system is x86 or x64 to decide which package to get. Hopefully I’ll get around to discuss that one some day as well since it turned out really great. But until then, enjoy my new application!

January 23, 2008

Uploading multiple files and form fields in .Net

Filed under: .Net, Code samples, c# — Karl @ 5:37 pm

Recently while building a small application for a friend of mine I came across a part where I needed something that I just couldn’t find in the .Net framework. I needed to upload two files (and specify their fieldnames) and a few form fields to a webpage. I thought this would be easy just using the provided WebClient class but after looking closer at it I found that it didn’t really offer anything of what I needed. Trying not to feel let down by this I started to write my own extended version of WebClient with a few new tricks that the old one couldn’t do.

I tried to keep it as simple as possible so instead of writing new classes to hold form and file data I used two Dictionary<string, string> to pass the values. The Key is the fieldname and the Value the value or the path to the file. An example of uploading a few files and adding a few fields to that could look like this:

It doesn’t look that hard does it? It’s perfect to use if you need to “submit” a form on a webpage from your c# application or just need to send several files to a webserver in the same request. Below is the complete code for WebClientEx displayed. You may use it for anything you want as long as you don’t claim it as your own. If you use it in a project of yours then please write a comment or send me an email about it!

I won’t go in explaining line of this code as I’ve done in a few other samples. The code isn’t that hard to understand if you have moved beyond the “beginner stage” of coding. The thing worth mentioning is the part with MimeHelper.GetMimeTypeForExtension() which is a small function I wrote which checks the registry for any available mimetype for a given extension. I’ve included that code below aswell since it’s needed for WebClientEx.

Enjoy!

November 6, 2007

Recent downtime

Filed under: Beaver, Misc — Karl @ 10:08 pm

Lets see now, on the 10th of June I moved into my new apartment and on the 26th of October I got my internet connection installed. Thats about four and a half month without an internet connection. About a month ago lightning struck and fried a few parts in my web server so I had to replace them, this caused the Windows 2003 installation to fail so I had to reinstall everything which took ages. Since I didn’t have an internet connection at home I decided against putting the server back in it’s original place until I could monitor it closely (and install everything properly since some parts had to be downloaded again). This led to some massive downtime for beaverblogg, crazybeavers.se, beaverpage and a few other sites of which most are restored now.

I’m currently worked up with school and some other (paid) projects but I also have lots of cool stuff coming up for CrazyBeaver Software. First of all I’ve setup my own Subversion server on which I will host most of my new projects making the source available to everyone! To start with I will be the only one who can make commits but that might change if someone shows a real interest in helping out. I’ve also setup Trac to help managing the larger projects (such as ImagerGallery.Net) by giving me a great platform for handling bug and feature requests. Hopefully I’ll have all this aswell as the new CrazyBeaver Software up and running before 1st December but since I don’t know how much I’ll need to do for school and my other projects. Keep watching this spot (maybe subscribe to my RSS feed?) for more info!

July 15, 2007

DynDnsLib and AkismetLib

Filed under: .Net, Beaver, Misc — Karl @ 7:32 pm

It’s been quiet around here lately. I moved to a new apartment a bit over a month ago now and won’t get an internet connection for at least another month it seems so things are going a bit slowly on the development front. I’ve managed to put together a few things though which might be of help to some.

First of all is a .Net library (and client) for working with DynDns services named DynDnsLib (and CrazyBeaversDnsUpdater for the client application) for people who want to add support for DynDns services to their applications. More information (and sourcecode via SVN) can be found at the link below.

http://beaverdnsupdater.devjavu.com/

Second up is an implementation of the Akismet (spam detecting service that WordPress and a few others use) API for .Net 2.0. It is a quite basic implementation that could be extended a bit more if someone wants to but it should be working fairly well as it is. More info (not much) and source at the link below.

http://akismetlib.devjavu.com/

None of these projects are in their final version, but both works fairly well at least. If anyone want to contribute to any of these projects then send me an email to karl.sjogren@gmail.com and tell me what you want to implement/change and I’ll consider giving you write access to the SVN repository.

When thinking about it, checking out source from an SVN repository might be a bit tricky unless you know what you are doing, maybe I should put together an article for that aswell some day if people seem to want it.

June 10, 2007

Installing an ISAPI/CGI extension on Windows 2003

Filed under: Articles, IIS, ISAPI/CGI — Karl @ 11:28 pm

This is the last article that has to be rewritten since I lost my database, it is also the one that people have asked for most so it feels good to finally get it up and running again.

This article describes how to setup IIS6 on Windows 2003 to allow it to execute ISAPI and CGI extensions. For this example I’m using my own ISAPI application called Imager Resizer (which also was the reason that I wrote this article from the beginning).

Internet Information Services (IIS) Manager

First of all you need to locate your IIS Manager, if you don’t have it as a desktop icon as I have you will find it under Start->Settings->Control Panel->Administrative Tools->Internet Information Services and open it up.

IIS Manager

When the IIS Manager opens up you first click on “Web service Extensions” node in the tree view on your left. This brings up a list with the currently known ISAPI/CGI extensions on your server. At the top of the list you’ll see “All Unknown CGI Extensions” and “All Unknown ISAPI Extensions”, by default both these are prohibited and I would recommend that they stay that way. If you are running a ton of different ISAPI or CGI extensions or is just a very lazy person that doesn’t care to much about security you can allow unknown extensions to execute but remember that if someone manage to put an ISAPI or CGI extension on your server without you knowing (a flawed upload script or whatever) they can do almost anything with it. If you decide to allow all unknown extensions you can skip to the last part of the article now.

IIS Manager with expanded Action menu

To add a new extension to the list you can either go via the Action menu and selecting “Add a new Web service extension” or you can right click in the list (not on an item though!) and select the same thing.

IIS Manager with the New Web Service Extension dialog open

This dialog is quite self explanatory but I’ll describe it anyway. Here you assign a name to identify the extension, in my case I chose “Imager Resizer” for the name. Then I click the “Add” button to browse to the required files (only Imager.dll in my case) and then finally I check the checkbox with the label “Set extension status to Allowed” so I don’t have to enable it manually afterwards. After that, I simply click OK and the dialog vanishes. Now Imager Resizer will be visible in the extension list (since I took the screenshots from my production server Imager Resizer was already in the list though) and it’s status is set to Allowed.

Properties dialog for a virtual directory in IIS Manager

Now we’ve introduced Imager.dll to IIS and told it to allow it to execute, however there is one more condition that must be filled and it has been there since IIS5 and maybe even longer then that. Anyway, what you need to do is to set the “Execute permissions” for the folder that holds the extension to “Scripts and Executables”. This is done by locating the folder in the IIS Manager (under Web Sites->MySite for example), right clicking on it and then selecting properties. In the properties dialog you chose the “Virtual Directory”/”Home directory” tab and look at the bottom of it. The second combobox counting from the bottom is the “Execute permissions” (hopefully you were able to read that yourself though) and it is probably set to “Scripts only” to start with. Set it to “Scripts and Executables” and click OK.

Thats it, now you should be able to browse to your extension and see it in action. If using Imager Resizer you can use the /test action to verify that it works correctly by going to http://www.mysite.com/Imager.dll/test. It should then return a page looking something like this: http://www.kallesbildarkiv.se/cgi-bin/Imager.dll/test. Thats it for this article, hope I didn’t miss anything essential and that it will help a few people setting up Imager Resizer or any other ISAPI or CGI extensions.

May 9, 2007

Pidgin 2.0.0 is out!

Filed under: Misc, Picked up on the net — Karl @ 11:17 pm

*NOTE*
If you came here looking for the ISAPI on Windows 2003 tutorial it has been moved to here due to a database crash.

The first ever stable release of Pidgin is out! For those who didn’t know, Pidgin is the new name of the great IM client Gaim. Everyone that has grown tired of all the extra stuff that comes with regular msn messenger, aol messenger or almost any other IM protocoll this is really worth trying. For more info on the new release you just have to head over to www.Pidgin.IM and have a look!

April 24, 2007

Displaying an RSS feed using XMLDom and ASP

Filed under: ASP, Articles, XML — Karl @ 3:21 pm

It happened again. I saw some really horrible examples today on how to show an RSS feed using XMLDom so I took another trip with the WayBackMachine to try to dig this article up. After figuring which id-number this post had on the old installation it wasn’t that hard.

Anyone remembered why I wrote this article the first time? Here is a quote from the original about why I wrote it.

Imagine a script that selects all nodes (XPath query was something like “//*”), not caring where in the document, then looping them thru looking at their names and guessing what they are and then adding them to four separate strings with some weird separator. After doing this, they split the strings into four arrays and started looping out the content. Oh please, it was horrible. No real sense of XML at all I’m afraid . I know there are better resources then that on the net, but I still felt I had to contribute with just one more.

Hopefully there are still people who need to learn this out there so I didn’t waste my time recovering it. Anyway, let’s get going

If you never heard of RSS earlier, you are either very ignorant to what happens on the web these days and/or you are stuck running Internet Explorer which lacks any built in support for it. It all comes down quite easy though. An RSS feed is an online news syndication in the XML format. The main idea is to have a standardized way to share news over the net. I for an instance offers my articles as an RSS feed so people easily will know when I’ve written something new. For those who want to dive deeper into RSS I would recommend “What Is RSS” over at XML.com.

I thought that it might also be a good idea to show a short RSS feed with only one news item in it so you know what source we are working with.

This is a quite minimal feed document. It could have any number of “item” nodes aswell as it could have way more descriptive tags both for the channel and for the items. This is not how the feed for my site looks. I’m using a nice tool that generates everything for me and puts in 10 or 15 extra tags that are far from necessary. I feel that it would be quite an overkill to start out with that and I doubt that more then 5% of the RSS readers out there actually cares about all those tags anyway.

Anyway, lets get going. For those who have read my previous tutorials, there isn’t anything really new here, for those who haven’t, I would recommend reading XML, XMLDom and ASP Part 1 and XML, XMLDom and ASP Part 2.

So lets start examining the code then.

This part is very almost a carbon copy of the first lines in my second article, I just added nodeCol, oNode, oChildNode and i to the variable declaration and set the async property to false. The async property tells if the dom should proceed in asynchronous or synchronous mode. Since we don’t want it to continue to execute without being done with the HTTP request, we set it to false (synchronous mode).

Next, we have a simple if statement to see if the document has a documentElement (root element, remember?). If not, we show a short error message.

If the script got this far, we probably got our RSS feed without any problems. Now we call the selectNodes function to select all item nodes from the feed and put the collection in nodeCol. Then, we do a simple for-each loop to go through all the nodes in the collection.

This might seem like a long chunk of code, but it’s quite repetive so I think you can handle it. First of all, we write some standard html markup. We encapsulate each item in a paragraph. Next, we try to select a childnode from the current node. Each item should have a title, a pubdate, a description and a link, but since people are lazy sometimes they leave one or several of them out so to make this as general as possible we make sure that the nodes exists to avoid a crash. Anyway, we try to selet any childnode named title and put it into the oChildNode variable. Then, if not oChildNode is nothing, we can ouput the text content of that node by using oChildNode.text. Again we are adding some markup to the code, this to make it easy to style it afterwards using CSS. We repeat the exact same thing for the other “supposed to be there” nodes and print them out accordingly. We even make a link out of the link node if it exists. And well, thats kinda it.

This post didn’t take long to write so I apologize if it contains any errors of some sort. If it do, then please tell me so I can correct them as fast as possible. It was quite fun though to join the stuff I’ve written about in the first to articles into this one and there will be more to come!

Next Page »

Powered by WordPress