C# Desktop RSS News Ticker

by nealbailey 11. January 2010 16:48

I actually finished this project many years ago, back in 2003-2004 (originally in VB.NET v1.0!). Reviewing all my source code a little while ago I came across this old project. It still worked great but it had some memory leak issues so I spent a few hours refactoring the original code base to C#.

 

 

Refer to the code-project article for full source code.

The code is really simple. It uses the RSS.NET library to enumerate the RSS feeds specified in the settings.ini file and append them all in a StringBuilder. The tricky part is figuring out how to make a nested label in a panel control scroll seamlessly with no screen flicker.

When the RSS enumerator has fetched the feeds and fed them back to the TextBox control, we set the label's Text property:

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
   this.label1.Text = this.textBox1.Text;
}

 

There is a Timer control, which re-positions the Label control on the panel on each Tick event:

 

private void timer1_Tick(object sender, System.EventArgs e)
{
   this.label1.Left = this.label1.Left - 1;
   if (this.label1.Left + this.label1.Width < 0)
   {
      this.label1.Left = this.panel1.Width;
   }
}

 

That's basically all that's needed to create the stock ticker effect; a Timer, a Textbox, a label, and a Panel.

 

DOWNLOAD - BaileyRss_News_Ticker.zip (108.13 kb)

Note: The download is ONLY the program (reuires .NET 2.0+). Go to Code-Project for the source code.

 

Tags: , ,

Code

Zip Each File In a Folder Into It's Own Archive

by nealbailey 8. January 2010 23:29

One of the biggest annoyances with 7zip (a great free Zip utility) is a feature it lacks (which is included in WinRar) where you can highlight all the files in a folder and zip each file into it's own archive. For example, rather than creating one huge zip file to store my source code, I prefer to zip each folder into its own archive and move them to my backup file server. Having to zip each folder one at a time is incredibly tedious and time consuming for me.

I have developed a very simple JavaScript utility which allows you to compress each file in a path, or each folder in a path into it's own zip file. The code is pretty simple stuff and it relies on the 7z.exe (redistributable) command line utility. I have created a package for download that has everything you need. You can run the tool at the command line or you can edit the included Go.cmd batch script and put in the path to work and run that by double clicking it. 

DOWNLOAD - ZipBatch.zip (340.00 kb)

 

/* ======================================================================
NAME: 7zBatch - Batch Zip Utility
AUTHOR: Nealosis
DATE  : 1/8/2010
COMMENT: Zip Files & Folders into seperate archives
========================================================================= */


if (WScript.Arguments.Count() < 1) {
    WScript.Echo("Usage: 7zbatch.js [path] [action]");
    WScript.Echo("Example: cscript 7zbatch.js c:\temp\emulators\NES /files");
    WScript.Echo("");
    WScript.Echo("Action: /files - zip all files in a path in a seperate archive");
    WScript.Echo("Action: /folders - zip all folders in a path in a seperate archive");
    WScript.Quit();
}

var _strPath = WScript.Arguments.Item(0);
var _strAction = WScript.Arguments.Item(1);

var _objFso = new ActiveXObject("Scripting.FileSystemObject");
var _objShell = new ActiveXObject("WScript.Shell");
var _dir = _objFso.GetParentFolderName(WScript.ScriptFullName);

var _7zexe = _dir + "\\7z.exe";
var _7zparms = " a -bd -tzip -mx=9 ";

Main();

function ZipFiles(path){
    var objFolder = _objFso.GetFolder(path);
    var files = new Enumerator(objFolder.Files);
    for (; !files.atEnd(); files.moveNext()){
        var objFile = _objFso.GetFile(files.item());
        var zipper = _objFso.GetFile(_7zexe);

        WScript.Echo("Zipping File: " + objFile.ShortPath);
        _objShell.Run(zipper.ShortPath + _7zparms + "\"" + objFile.Path + "\"" + ".zip " + objFile.ShortPath, 0, true);
    }
}

function ZipFolders(path){
    var objFolder = _objFso.GetFolder(path);
    var fols = new Enumerator(objFolder.SubFolders);
    for (; !fols.atEnd(); fols.moveNext()){
        var objFol = _objFso.GetFolder(fols.item());
        var zipper = _objFso.GetFile(_7zexe);

        WScript.Echo("Zipping Folder: " + objFol.ShortPath);
        _objShell.Run(zipper.ShortPath + _7zparms + "\"" + objFol.Path + "\"" + ".zip " + objFol.ShortPath, 0, true);
    }
}

function Main(){
    WScript.Echo("");
    WScript.Echo("7zbatch Started - Nealosis 2009");
    switch (_strAction)
    {
        case "/files":
            ZipFiles(_strPath);
            break;
        case "/folders":
            ZipFolders(_strPath);
            break;   
    }
    WScript.Echo("Tasks Completed.");
}

 

Tags: , ,

Code

Auto-Update uTorrent Ban lists

by nealbailey 6. January 2010 18:58

uTorrent, the bitTorrent client, integrates seamlessly with P2P blacklists to block machines connected in a bitTorrent swarm from connecting to your machine if they are on the banlist. Ban lists are extremely helpful for blocking machines who are interested in violating your privacy by monitoring your actions or by targetting advertising to you based on your downloading habits. There are a lot of products developed exclusively to provide this protection, for example PeerGuardian, which acts like a dedicated firewall to block connections, but they require seperate installation and constant administration. If you don't use one of these products then you're left hunting the internet for current black lists to import into uTorrent.

This morning I whipped up a tiny JavaScript that will automatically download and update uTorrent with the most recent black lists: 

Using the tool is extremely simple, you just double click the UpdateBlocklist.cmd file and the script will do its magic. You should run this as a Windows scheduled task once a week or you can run it periodically whenever you feel the need to update your ban lists. At present there are about 270,000 IP addresses on the ban list. 

DOWNLOAD - uTorrent_block_updater.zip (567.07 kb)

 

Engine Source Code

/* ======================================================================
NAME: uTorrent Blocklist Updater
AUTHOR: Nealosis
DATE: 1/6/2010
COMMENT: Blocks bad people from connecting to you in a bitTorrent swarm.
========================================================================= */


var _oFso = new ActiveXObject("Scripting.FileSystemObject");
var _oShell = new ActiveXObject("WScript.Shell");
var _appData = _oShell.SpecialFolders("AppData");
var _uTorrentAppData = _appData + "\\uTorrent";
var _bListL = _uTorrentAppData + "\\ipfilter.dat";

/* The internet location of the most recent ban/blocklist */
var _bListR = "http://emulepawcio.sourceforge.net/nieuwe_site/Ipfilter_fakes/ipfilter.dat";

main();

function main() {
    WScript.Echo("");
    WScript.Echo("Nealosis.com P2P Banlist Updater");
    WScript.Echo("=======================================");
    WScript.Echo("");
   
    if (isInstalled()) {
        BackupBlocklist();
        DoUpdate();
    }
    else {
        WScript.Echo("uTorrent is not installed. Good bye!");
    }
}

function isInstalled() {
    if (_oFso.FolderExists(_uTorrentAppData)) {
        return true;
    }
    return false;
}

function BackupBlocklist() {
    if (_oFso.FileExists(_bListL)) {
        WScript.Echo("Local blocklist found, backing it up.");
        _oFso.CopyFile(_bListL, _bListL + ".bak", true);
        _oFso.DeleteFile(_bListL);
    }
    else {
        WScript.Echo("Local blocklist not found.");
    }   
}

function WGETPath() {
    var path = _oFso.GetParentFolderName(WScript.ScriptFullName);
    return path + "\\wget.exe";
}

function DoUpdate() {
    WScript.Echo("Downloading latest blocklist, this may take a few minutes.");
   _oShell.Run("\"" + WGETPath() + "\" -r --tries=3 " + _bListR + " -O \"" + _bListL + "\"", 1, true);
    WScript.Echo("Blocklist downloaded, restart uTorrent to apply latest bans.");
    WScript.Sleep(5000);
}

 

 

Tags: , , ,

Code

Creating a Better Emulator Experience

by nealbailey 10. November 2009 01:21

Gaming and I go WAY back, all the way to Atari and Nintendo. I have so many games from my childhood that I still play and one of my biggest complaints with emulators is their lack of a quality user experience. For example, why don't emulators maintain a database which can retrieve game reviews and descriptions from web sources as well as allow you to rate games and add notes? Of all the emulators I tried UberNES, was the closest to offering this functionality. Unfortunately, of the games I tried only a few had descriptions, box-art, or screenshots.

So I decided to create an application I call, NES-Loader which adds all this meta data from an online scraper. You can see from the screenshots below, the application interface. The application starts up and all the games are listed with details like the developer, the year it was released, its genre and whether it is a "recommended" title or not. This is really helpful for sorting the list by genre (e.g. I only want toplay shooter games today) or the developer (such as Konami).







You can see below the NSIS installer which I used to package everything up into a single installer so I can install everything I need on any of my machines with just a few clicks.

 


DOWNLOAD - Retro-Gaming-XLoaders-1.2-FINAL.torrent (238.45 kb)

Tags: , ,

Code | Gaming

CD Beaver CD-DVD Management

by nealbailey 2. April 2009 04:34

 

  Utterly and completely frustrated with my Disk Stakka units I have finally decided to smash them with a hammer and build my own solution. What I have come up with is a little program I call CD-Beaver and its working out great for me. Refer to my code-project article for additional details and the source code.

Tags: ,

Code

Sharing Quotes With Friends and Co-workers

by nealbailey 23. March 2009 20:20

 I an amazing show of love and affection, a relative purchased an Amazon Kindle 2 for my birthday and I must admit, it is amazing.  

 After learning to use the device and reading a few books, one of the features that really jumps out at me is the ability to take notes, bookmark, and highlight passages in books. I immediately started to make highlights of great quotes and passages and I got to thinking about how I could share these quotes and passages online with friends. 

This morning I developed a quick Web Service to serve up quotes to anyone who wants them. Whats great about the system is that it can be consumed by anyone's appliction or read directly from the internet. I have not decided on a front end for the system; whether I'm going to create a Web Site, desktop or facebook application, or a Vista sidebar gadget. 

Backend Scripts
 
 
As I continue to read more content, I'm going to continue to pluck words of wisdom from these books for later reference. Currently the scripts return plain-text format quotes. I may move to XML if I find that people want to use a RSSReader or I want more detail meta-data about the quotes. 
 
 

 

Tags:

Code

Batch Renaming Files

by nealbailey 20. September 2008 16:00

Last weekend I found myself needing to rename some files on one of my servers. Ok, more like thousands of files because they were not named in a way that was conducive with XBMC's media information scraping features. When I looked at the sheer volume of files needing to be renamed I decided to write a small utility to rename the files in batch based on standard string replacements or Regular Expressions

For more details on the program or to get the code go to my code-project article on it. 

 

Tags:

Code

Parsing CBR Files in C#

by nealbailey 27. July 2008 16:04

The acronym CBR stands for Comic Book Reader. Basically a CBR file is a renamed RAR archive file. CBR files are used in comic books and slideshows where the images in the archive need to be accessed sequentially. There are some great CBR reader applications out there such as Comix, CDisplay and Comic Reader X which are used to display the book in the correct order.

My goal is not to re-invent the wheel in creating a reader but rather gain access to the CBR archive so I can categorize these collections appropriately and provide a nice interface for browsing the collection. I have found a great library for reading RAR files which I'm using for this project. Below you can see an example of how I'm extracting the first file in the archive to use in our proof of concept.

private void GenerateCover()
{
  this.ErrorMessage = string.Empty;
  string path = string.Empty;
  Chilkat.Rar rar = new Chilkat.Rar();
  bool success = rar.Open(FilePath);
  PageCount = (int)rar.NumEntries;

  path = Path.GetTempPath();
  if (success)
  {
     Chilkat.RarEntry entry = rar.GetEntryByIndex(0);
     if (entry.IsDirectory)
     {
       entry = rar.GetEntryByIndex(1);
       entry.Unrar(path);
     }
     else
     {
       if (entry.Filename.IndexOf(".jpg") > -1)
        {
          entry.Unrar(path);
        }
      }
      CoverPath = Path.Combine(path, entry.Filename);
  }
  else
  {
    this.ErrorMessage = "There was an Error: " + rar.LastErrorText;
  }
}

You can see the demo application which for now is a CD launcher program that you run on autostart. The application loads, scans the directory, and generates a book style index of the CBR files contained on the disc.

For full details and source code, read my code-project article on the project 

 

Tags: ,

Code | Comics

Powered by BlogEngine.NET 1.6.0.0
Theme by Extensive SEO