12. Extract uppercase words from a file, extract unique words using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.IO; namespace lrn2CSharp12 { class Program { static void Main( string[ ] args ) { string file = ""; string line = ""; string[ ] words; List<string> upperWords = new List<string>( ); List<string> uniqueWords = new List<string>( ); Console.WriteLine( "Input name of a file to read and count words." ); Console.Write( ":" ); try { file = Console.ReadLine( ); FileStream fs = new FileStream( file, FileMode.Open, FileAccess.Read ); StreamReader sr = new StreamReader( fs ); while ( !sr.EndOfStream ) { line = sr.ReadLine( ); words = null; if ( line.Length != 0 ) words = line.Split( ' ' ); if ( words != null ) { foreach ( string w in words ) { if ( char.IsUpper( w[ 0 ] ) ) upperWords.Add( w ); if ( !uniqueWords.Contains( w ) ) uniqueWords.Add( w ); } } } sr.Close( ); fs.Close( ); } catch { Console.WriteLine( "WTF?!?" ); } Console.WriteLine( "Upper Words:" ); foreach ( string s in upperWords ) { Console.Write( s ); Console.WriteLine( ); } Console.WriteLine( ); Console.WriteLine( "Unique Words:" ); foreach ( string s in uniqueWords ) { Console.Write( s ); Console.WriteLine( ); } Console.WriteLine( ); Console.WriteLine( "Press esc to exit." ); while ( !keyPressHandler( Console.ReadKey( true ) ) ) { Thread.Sleep( 250 ); /* no op */ } } private static Boolean keyPressHandler( ConsoleKeyInfo input ) { if ( input.Key == ConsoleKey.Escape ) return true; return false; } } }

posted by dharh 1:08 AM May 30th, 2011 via idt


11. Input is HTML table, Remove all tags and put data in a comma/tab separated file.

Part of this was an exercise in looking up what others have already done.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Data; using System.Text.RegularExpressions; using System.Threading; namespace lrn2CSharp11 { class Program { static void Main( string[ ] args ) { string file = ""; string html = ""; DataSet ds = null; StringBuilder csv = new StringBuilder( ); Console.WriteLine( "Input name of a file with an HTML table in the current directory to convert to csv." ); Console.Write( ":" ); try { file = Console.ReadLine( ); FileStream fs = new FileStream( file, FileMode.Open, FileAccess.Read ); StreamReader sr = new StreamReader( fs ); html = sr.ReadToEnd( ); sr.Close( ); StreamWriter sw = new StreamWriter( fs.Name + ".csv" ); ds = ConvertHTMLTablesToDataSet( html ); if ( ds != null ) { foreach ( DataTable dtc in ds.Tables ) { int iColCount = dtc.Columns.Count; for ( int i = 0; i < iColCount; i++ ) { sw.Write( dtc.Columns[ i ] ); if ( i < iColCount - 1 ) { sw.Write( "," ); } } sw.WriteLine( ); foreach ( DataRow dr in dtc.Rows ) { for ( int i = 0; i < iColCount; i++ ) { if ( !Convert.IsDBNull( dr[ i ] ) ) { sw.Write( dr[ i ].ToString( ) ); } if ( i < iColCount - 1 ) { sw.Write( "," ); } } sw.WriteLine( ); } sw.WriteLine( ); } } sw.Close( ); fs.Close( ); } catch { Console.WriteLine( "WTF?!?" ); } Console.WriteLine( "Press esc to exit." ); while ( !keyPressHandler( Console.ReadKey( true ) ) ) { Thread.Sleep( 250 ); /* no op */ } } private static Boolean keyPressHandler( ConsoleKeyInfo input ) { if ( input.Key == ConsoleKey.Escape ) return true; return false; } private static DataSet ConvertHTMLTablesToDataSet( string HTML ) { DataTable dt; DataSet ds = new DataSet( ); dt = new DataTable( ); string TableExpression = "<table[^>]*>(.*?)</table>"; string HeaderExpression = "<th[^>]*>(.*?)</th>"; string RowExpression = "<tr[^>]*>(.*?)</tr>"; string ColumnExpression = "<td[^>]*>(.*?)</td>"; bool HeadersExist = false; int iCurrentColumn = 0; int iCurrentRow = 0; MatchCollection Tables = Regex.Matches( HTML, TableExpression, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase ); foreach ( Match Table in Tables ) { iCurrentRow = 0; HeadersExist = false; dt = new DataTable( ); if ( Table.Value.Contains( "<th" ) ) { HeadersExist = true; MatchCollection Headers = Regex.Matches( Table.Value, HeaderExpression, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase ); foreach ( Match Header in Headers ) { dt.Columns.Add( Header.Groups[ 1 ].ToString( ) ); } } else { int columns = Regex.Matches( Regex.Matches( Regex.Matches( Table.Value, TableExpression, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase )[ 0 ].ToString( ), RowExpression, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase )[ 0 ].ToString( ), ColumnExpression, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase ).Count; for ( int iColumns = 1; iColumns <= columns; iColumns++ ) { dt.Columns.Add( "Column " + System.Convert.ToString( iColumns ) ); } } MatchCollection Rows = Regex.Matches( Table.Value, RowExpression, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase ); foreach ( Match Row in Rows ) { if ( !( ( iCurrentRow == 0 ) & HeadersExist ) ) { DataRow dr = dt.NewRow( ); iCurrentColumn = 0; MatchCollection Columns = Regex.Matches( Row.Value, ColumnExpression, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase ); foreach ( Match Column in Columns ) { dr[ iCurrentColumn ] = Column.Groups[ 1 ].ToString( ); iCurrentColumn++; } dt.Rows.Add( dr ); } iCurrentRow++; } ds.Tables.Add( dt ); } return ds; } } }

posted by dharh 11:42 PM May 29th, 2011 via idt


The .NET version of neTodo has been released. It's a functioning Preview Release. There are still lots of things I need to do to get it where I want it. Go to the neTodo changelog to read more about this release.

posted by dharh 5:25 PM Mar 19th, 2011 via idt


This post is belated, since the Earthquake and resulting Tsunami happened last Friday. My thoughts and hopes are with the people of Japan as they continue to cope with the aftermath of the Tsunami and current nuclear crisis going on.

I have to however, say something about many of the twitter, facebook, and other comments I've been seeing out there. Such things like this being God's payback for Pearl Harbor. Japan getting what it deserves. Bullshit. You ought to be ashamed of yourselves.

Once again, and I can't believe I have to say this. God didn't send the Tsunami, didn't start the Earthquake, and certainly didn't punish Japan because of Pearl Harbor. Let it go freaks. God doesn't care about our petty little fights. God doesn't punish nations or people. God doesn't need to, we do it all ourselves, so let it go and stop being such assholes.

Please, if you haven't already, donate something to help the Japanese people.


posted by dharh 10:37 AM Mar 16th, 2011 via idt


Hopefully this new year will see some more activity from me. That's my new years resolution for IDT.

As a sort of quick plan for what I want to do this year:

  • Finish building the C#.NET version of IDT.neThing
  • Continue with the 15 Exercises for Learning a new Programming Language series (#lrn2program), fleshing out the java part, adding c++, javascript, and python
  • Work on getting neFeedeater running for other people
  • Permanently pull in the delicious links that currently feed into Sparce from delicious.com and convert Sparce into a semi copy of delicious

Let's see how it all goes.


posted by dharh 10:37 AM Jan 3rd, 2011 via idt


A year ago Google unveiled a new operating system they were working on. One in which their browser, Chrome, is the sole focus. Shedding old operating system conventions to do one thing, allow the user to browse the web. Going so far as to call it the Chrome OS.

Google believes that the internet has reached a critical point, where people spend most of their time on the computer using the internet, where web sites can offer many of the same services that applications have done in the past, where HTML5 can offer a rich environment to develop even better web applications closing the gap between desktop applications and web applications.

Last week Google unveiled more of what they have been working on in the form of a notebook with Chrome OS as its operating system. They call their new laptop CR-48, which is an isotope of the element chromium. They made 60,000 of them and giving many of them through various applications and giveaways. And I got my hands on one of them.

I won't bore you with too many details. If I had done this review earlier I might, but other people have gone into more depth with better writing than me.

Touchpad

It indeed sucks. I chalk it up to both software and hardware. They should have focused on the touch sensor and skipped trying to make it a clickpad. If you understand its quirks and don't try to use the clicky part, it works quite well. The quirk is the further away from the center you get the more off its sensor gets. So double tapping, right tapping work in the center, but not so much anywhere else. In the end though it may just be better to use the alt key for right clicking.

If its a software issue, heres to hoping they get that part nailed down so they can add even more gestures.

Keyboard

It rocks. Best keyboard on a laptop I've ever used. Search in place of caps lock? Genius. The function keys being remapped to internet related functions, perfect.

Battery Life

It's not an iPad, with its ungodly battery life, but it trumps every other netbook I've ever used. I can easily get a full day, and my days are 12+ hours. I imagine using flash more would shrink that down, but not by much.

OS

Shows alot of promise and a few faults.

From first opening the lid to browsing the first page <15 seconds. Close lid, open lid, to browsing page is usually <5 seconds. That is until you've been using it for a couple days without shutting it down completely. You start to notice lag between opening the lid and connecting to wifi growing.

Browsing the web is pretty straight forward, the experience itself is very close the same as using Chrome on any windows, linux, or OSX machine.

Flash, as always, has issues. Hopefully they get that straightened soon, at the very least before launch of the stable Chrome OS.

Perhaps there are other clouds they should focus on as well, besides the Web. Things like Device clouds or IRC.

I think they should open up the linux terminal in chrome, the default, and even the dev terminal are just too lacking. Especially for the curious among us. I wouldn't go to far as to support anything outside of the Chrome OS stack, but at least allow people to do whatever they want to the stable Chrome OS release without having to develop and compile it on their own.

Conclusion

Google has work ahead of them. The software is definitely beta stage.

Also, if they want this to succeed that have to convince more than just me to join the cloud. I've seen quite a few reviews that simply do not understand why anyone would want to use Chrome OS. Google needs to convince these people, because they are the ones who will get the moms and pops, who are the perfect demographic for this, to use it.

Other Tiddlybits

From Tom's Hardware: "The Intel CPU inside is the Atom N455, which is a single core solution, on Intel's CG82NM10 PCH. It's believed that the market versions from Acer and Samsung will use dual-core Atom N550. For memory and storage there's a 2GB stick of Hynix RAM inside, plus a 16GB SanDisk SSD. Its Verizon 3G chip is the Novatel Gobi2000 PCI Express Mini Card, the Wi-Fi is handled by the AzureWave Atheros 9280 802.11 a/b/g/n part, and there's also Bluetooth thanks to the Atheros AR5BBU12 with V2.1 EDR."


posted by dharh 4:32 AM Dec 12th, 2010 via idt


I got my google notebook on my doorstep last night. I'll write a review over the weekend.

posted by dharh 4:49 PM Dec 10th, 2010 via idt


« Previous
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Next »

2011: 5 3 1
2010: 12 9 7 1
2009: 12 11 8 5
2008: 12 5 4 3 2 1
2007: 12 11 10 9 8 7 6 5 4 3 2 1
2006: 12 11 10 9 8 7 6 5 4 3 2 1
2005: 12 10 7 6
2004: 10 9 6 5 4 3 2 1