All posts by Steven

Simple Char

Ok so I evidently am not the sharpest knife in the drawer. I was trying to figure out how in the heck you set create and set a char variable.

Example:

[code:c#]char c = new char("s".ToCharArray[0]);[/code]

Yea I know now its as simple as using the single tick to specify the char literal;

[code:c#]char c = new char('s');[/code]

Good grief. Ah well, live and learn.

0

Reading Gmail with Sup

I wanted a simple mail client that would handle all the mail I receive from various accounts and ran across Sup. Impressivly simple and very nicely done in a console application.

Here are the steps I took to get Sup both reading mail in my Gmail account and sending mail out via my Gmail account on my Arch workstation;

  • Installed  Yaourt
  • Installed Ruby and Rubygems via Yaourt
    • yaourt -Sy ruby rubygems
  • Installed VI via Yaourt
    • yaourt -Sy vim vim-colorstamplerpack
  • Installed sSMTP via Yaort
    • yaourt -Sy ssmtp
  • Setup sSMTP following this Wiki Entry
  • Installed Chronic (a date parser, dependency of Sup) via the Ruby Gems tool
    • sudo gem install chronic
  • Downloaded the latest Tarball of Sup, unpacked it into /tmp and installed it via the Gems
    • sudo gem install sup -y
  • My ~/.sup/sources.yaml file looks like this;

I found this guide very helpful for Sup

Enjoy!

ps; Man does posting from this HTML interface suck rocks. Gotta get some sorta MS Live Writer going. 

0

Flood of log messages about USB over-current

So on my Notebook I noticed I was getting a flood of these frickin' messages;

I mean like 5 a second, over and over and … and …

Googl'ed this madness and found no good answer, so I thought I would take an extreme approach and just have Syslog-ng just not log it!

Add this to your destination collection in /etc/syslog-ng.conf;


destination nowhere { file("/dev/null"); };

Then add this to the filter section;


filter f_usb_occ { match("over-current change"); };

Then finally add this to the log section;


log { source(src); filter(f_usb_occ); destination(nowhere); flags(final); );

Restart Syslog-ng and viola! no more logging of that irrating message. woot!

Enjoy!

0

Not all USB Flash Drives are Bootable?

I was playing around with getting Arch Linux on my EeePC and one of the first steps is to create a bootable USB Flash drive with the Arch Core ISO put on it to boot.

Easy enough done but then I could not get the stinking EeePC to boot from the USB Flash Drive, acted like it did not even have a boot loader loaded in the MBR, curious.

So then I attempted to use another USB Flash drive and found it to work just fine, I did not change a single setting on the EeePC it just seem that the one USB Flash Drive isnt 'able' to boot.

Curioser and Curioser.

It just appears that some USB Flash Drives wont arent able to boot. The one that would not work for me I picked up at MicroCenter for like $15, one of those generic drives they have at the counter. Some details;

 

Ones that I did get to work; 

SanDisk Corp. SDCZ2 Cruzer Mini Flash Drive (thin) 4GB

Hewlett Packard v120w 2GB 

By the way the HP v120w I picked up at MicroCenter for $12, neat little drive.

If you have some details on a USB Flash Drive that you have that you could not get to boot, it would be great if you could comment here with the Make and Model.  

Enjoy!

0

Coders 4 Charities

Did something different this weekend, hung out with a bunch of geeks and spent something like 30 hours working on a charity website;

Coders 4 Charities 

It was actually alot of fun and I got a chance to play with LINQ in a real world environment. Couple of things I took away with LINQ;

  1. LINQ does not like ALIASES in the SQL for stored procedures. I was not able to get the  DataContext to give me a result until I changed out the 'SELECT p.Firstname from Person P' to a 'SELECT Person.Firstname from Person' in the join clause. Frustrating to figure that one out.
  2. Seems you cant do a join across two DataContext's. If you want you have to include all the tables you want to join together in the same DataContext.

Anyhow my team worked on a bible church and had some challanges getting the membership website all done with VS2008 and using LINQ as the DAL. Good stuff.

0

Load XML into List Collection

I needed the ability to load a XML file into a selectable list. The problem was really two fold, I had a collection of DAT files (like a single column CSV file) that I needed to first convert to XML (I had another existing collection of XML files, yea I know "consistency, consistency, consistency") as well.ScreenShot014

So I can up with a simple couple of utility methods to convert a single column CSV file (herein referred to as a DAT file) to an XML and then another method to take a XML file and return a list collection. This allows me to first convert the DAT and then load the collection into a ComboBox. 

At first I was worried about performance of reading from the XML files, but then I realized we are talking about a collection of strings around the order of 100. This loads using the XMLTextReader class in about 2/10 of a second. I think that is performance I can live with.

This method takes a plurized DAT file (much like the RoR MVC style) and creates a simple XML (that includes the root attributes that the partner XML read method expects). An example would be using a DAT file name ‘colors.dat’ it would make a XML file with ‘colors’ root node and then a collection of ‘color’ nodes with a single element named ‘name’ that contains the value of each DAT file.

Example DAT file (just for clarity):

Method to convert the DAT to a XML file:

 

Now the method to take the newly created XML file and load it into a List<string> collection:

Bit of info on the options:

  • The "displayMember" is the value of the element name to use for the string value (defaults to "name").
  • The "sortList" option is a bool that indicates if the list should be sorted before it is returned.
  • The "includeAll" option is a string value that will be put at the top of the list. Like "- All" or "* Select All *".
  • The "includeEmpty" option is a bool that (if set "true") sets the option to include empty DAT file entries in the string collection.

So put together like this:

Awesome stuff. Super simple and very fast. I loaded up the entire US Zipcode collection in .223 seconds and then put that into a ComboBox in 2.9 seconds. I realize most people are not going to have 40,000 entries in a selectable ComboBox, my point is that it is zooming fast.

Enjoy!

0

Linux Mint, AMD 3850 and 1680×1050 Working!

About a month ago I picked up the ATI 3850 video card thinking it would be significant performance upgrade from my Nvidia 7950GT – it was. However, I was seriously dismayed to see the state of video drivers from ATI – in particular in comparison to the Nvidia driver. My LinuxMint Desktop glory!

Anyhow, so I started the fight. The fight to get my ATI 3850 card to drive my Viewsonic VG2230wm at 1680×1050@60. I tried several of the binary ATI drivers but finally got the 8.01 (the kernel version is 8.45.4, the driver is labeled 8.01 and the ATI website says it’s version 8.1 !? -man is that confusing) driver to work. Simple to install; Download the binary, then from a command line just execute the file as root.

Here is my relevant xorg.conf sections:

Enjoy!

0

Google Chart C# API

I was playing around with the excellent Google Chart API and I wanted to illustrate just how crazy simple it is to ScreenShot013implement this, even on a WinForm app (see nifty screen capture ->).

First grab the Google C# API Wrapper source code. Then take and unzip that and open that project in Visual Studio and compile the DLL. Then add a new Windows Application Project to the solution, drag a new PictureBox on the form, and then paste this into Form1.cs:

0

Dell Latitude c840 + Ubuntu + Restricted Nvidia == blankScreen;

I picked up a nifty Dell Latitude c840 notebook on Ebay for around $185, nice. So I get it and decide to setup Linux Mint (based on Ubuntu 7.10). After the install completes I then have the bright idea to setup the restricted drivers to get the 3D acceleration working (so I can play with Compiz later) and find that I am presented with a lovely black screen after reboot.

yay! black screen of nothing! yay!

So I troll around on the net and discover it’s some sort of problem with the Nvidia NV17 (GeForce4 440 Go) chip and the way the EDID‘s work on the Samsung 1600×1200 LCD, or somesuch silliness.

Anyhow to make it work( read = "I would like to actually see the screen!") reboot and select the "recovery mode" kernel and then do this:

Save file, reboot and click on my Google ads 😉

Enjoy!

0

C# .NET logging with NLog

After messing around with my own logging engine (boo!) I decided to play around with NLog, it looked much simpler to use and configure than log4net (not that log4net looked all that complicated, just that NLog seemed cleaner to me).

So grab the NLog setup package from SourceForge and install it. So that’s it. Yes, that simple really, the installer includes a series of templates that will be used later to create an empty configuration file.

I like using the Datestamp of YYYYMMDD_HHMM so 1:30 PM on April 1st, 1980 would be 19800401_1330. This is the configuration I used in the Nlog.config file to write the timestamp’ed log data to a text file (add a new file to your project and pick the ‘Empty NLog Configuration File” from the My templates section), this setup will also create a Datestamp on the log file:

Here is a example of using the logging:

Good stuff indeed.

Enjoy!

0