Christopher's profileBlue FenixPhotosBlogListsMore Tools Help

Blog


    May 25

    Sql Server Management Studio Express - you suck.

    I would like to know who thought it was a good idea to remove "import data..." and "export data..." from this particular flavor of the worst front end to an otherwise badass rdbms. I shouldn't have to fight with a program to get my databases in order. What a joke.

    [ Nothing Playing. ]

    April 25

    Exposing Hidden Events

    I recently ran into a neat little nugget of functionality in C# with events. Normally in C# when we define events we stop at something like this:

    public event EventHandler<MyEventArgs> MyEvent;

    The thing is, you can explicitly implement the add and remove accessors if you throw some curly braces into the mix. Why does this matter? Imagine that you have a MainForm, and a usercontrol named ControlPanel. ControlPanel contains another usercontrol called hiddenControl that exposes an event that you want to handle in MainForm, but all MainForm has access to is ControlPanel...

    public event EventHandler<MyEventArgs> MyEvent{
    	add{
    		this.hiddenControl.MyEvent += value;
    	}
    	remove{
    		this.hiddenControl.MyEvent -= value;
    	}
    }

    Now you can subscribe to the event in MainForm without making the usercontrol member public in ControlPanel.

    [ Currently Playing : Burn Away - Foo Fighters - One by One (4:57) ]

    March 22

    Windows Updates Make Me Nervous

     

    Rather surprised by the new 'updates are ready' message from Microsoft. Hmmm.

    revised updates message from microsoft

    Perhaps they know just how much frustration we had on the home pc recently due to their dodgy updates.

    (Fixed thanks to Scott Swigart)

    Source: Windows Updates Make Me Nervous

    March 15

    ASP.NET - UrlRewriting with PathInfo and base urls

    I read this excellent post from ScottGu and decided to use it with a page that implemented a masterpage. I didn't have to use postbacks in my scenario, but there were links included from the masterpage. The problem is that if you use app-relative paths for your href attributes (ex: <a href="/default.aspx">) the browser (FF 2.0.0.2 and IE 7 anyways) interperets the url with pathinfo differently than a url without. The base url includes the original page (ex: http://localhost:3333/rewriter.aspx/default.aspx). Guess what? The webserver picks up the last .aspx extension, default.aspx, that bad boy doesn't exist, and you get a 404 instead of going to http://localhost:3333/default.aspx.

    In the comments, Ian Oxley suggested that you can re-base links in your page/css/other static files using the <base> element in the head of your page. I expanded on it a little, since this behavior is only on one page of my site currently, and added the following code into the Page_Load event of the offending page:

    this.Header.Controls.Add(new LiteralControl("<base href=\"" + Request.Url.ToString().Replace(Request.RawUrl, "").Replace(Request.PathInfo, "") + "\">"));

    Now the base tag works on both the live site and the one that WebDev.WebServer spins up as well.

    [ Currently Playing : Them Bones - Alice in Chains - Nothing Safe: Best of the Box (2:29) ]

    March 08

    SubSonic Scaffold control - a GridView with Class

    So I've been able to dig my teeth into some asp.net hacking recently, and I've been wrestling with learning to use SubSonic in the process.

    In dealing with the scaffold control I ran into a funny issue: none of the exposed properties on the scaffold control will output any style info of the GridView that the control uses (that I could figure out anyways). I ended up with black text on a black background. :/ Seeing as I have the source, I decided to give the scaffold control's GridView a little class...hello GridViewCssClass property! I set it up just like the EditTable*CssClass properties, just a string property, with similar attributes to the other properties hanging around there:

    [Bindable(true)]
    [Category("Display")]
    [Description("Sets the CSS class used by the gridview.")]
    [DefaultValue(ScaffoldCSS.WRAPPER)] //CDF: just to have something to start with.
    public string GridViewCssClass {
    	get { return _gridViewCssClass; }
    	set { _gridViewCssClass = value; }
    }

    Then, in the CreateGrid method make it actually do something:

            private void CreateGrid()
            {
                Label lblTitle = new Label();
                surroundingPanel.Controls.Add(lblTitle);
                lblTitle.Text = "<h2>" + schema.Name + " Admin</h2>";
    
                grid.ID = "grid";
    	    grid.CssClass = this.GridViewCssClass;
    
                surroundingPanel.Controls.Add(grid);
    
                if (!Page.IsPostBack)
                {
                    BindGrid(String.Empty);
                }
                //add a column to the grid for editing
            }

    And now I can declaratively set the CssClass that the GridView uses to, oh, say, .whitetext :)

    August 16

    Windows Live Writer

    It looks pretty neat. I really dig the "type inside the preview" Web Layout. That's just sweet. The plugin support looks promising...I've already started coding up a CodeHTMLer plugin for syntax highlighting ala PostXING, now if I can get one going that will allow me to post the same content to more than one blog I'll be in business. I've been on a little hacking-hiatus on PostXING for the past few months to spend the summertime with my son Ethan, so what a great way to stretch my geek muscle all over again at the end of summer!

    August 11

    RE: Finding calling method using reflection

    Exactly what I was looking for...I don't know a lot about reflection, so I wonder if there is a more elegant way to get this info.

    July 20

    Whip it Real Hard

    Last night I got an impromtu text message saying that Ghostface Killah was playing at Warehouse live downtown. As a Wu-Tang fan, I decided to go out and see what he was all about. Pretty good show, I really dug the ODB medley they did in honor of Ol' Dirty.

     

    As an extra added bonus, Rick Ross opened up for Ghostface. He only did like 5 tracks, but was spot on for Hustlin'. He's obviously very comfortable with the song by now and it shows in his performance. Looked like he was really having fun with it which always helps for a good show.

     

     

     

     

     

     

     

     

     

     

    [ Currently Playing : Smiley faces - Gnarls Barkley - (3:05) ]

    July 07

    Gaffling that ribbon style

    Close enough. This should be fun.

    June 28

    Step your game up, Microsoft.

    Unfortunately, the rants about WGA causing a bluescreen are true. It happened a little while ago on my home PC. Thankfully, F8 booting into safemode still works, and I was able to restore my system to a daily checkpoint. Boy am I glad that was setup. Installing .net 1.1 sp1 worked fine, as did an audio driver I was missing.

    After having to rollback to a system restore checkpoint.

    Way to go, guys.

    June 13

    We'll miss you, Mr. Holmquist.

    My high school principal died on Monday.

    This is surreal. It feels like it was just last week that I was skipping class and getting a pep talk from Mr. Holmquist in North House. Worst of all, I went to school with his daughters. Amber was in my graduating class, but she was real into sports (and I wasn't). We had a couple of classes together but I was closer to her sister Kendra, a fellow thespian.

    This is so confusing...I've been in the Holmquist house a couple of times, and now...we'll miss you, Mr. Holmquist. Alief is a sad town today.

    In the unlikely event that either of my readers finds out any information about the funeral, please let me know. My cell is (281) 684-5688. Alternatively, if I find out anything I will post here.

    update: I got this from a friend in the district:

    The Holmquist family has made the following arrangements:

    Viewing services will be at Forest Park on Westheimer at Dairy Ashford on Thursday evening from 6-8 p.m.  The memorial service will be held Friday morning at 11:00 a.m. at Memorial Drive United Methodist Church on Memorial Drive between Wilcrest and the Beltway.

     

    Respectfully,

    Paula Smith

    May 10

    PostXING: Shameless request for feedback

    http://postxing.net/gemini/issue/ViewIssue.aspx?id=32

    I'm about to start cracking on this issue, but I'd love to get a little feedback on it before I put it into code. If either of you have an extra minute, shoot to the url above and leave a comment. I normally don't solicit feedback like this, but I kind of feel like I'm missing something. Although I could just be thinking about it too much. Either way, help a code munkey out if ya can :)

    [ Currently Playing : This Could Be Love - Alkaline Trio - Good Mourning (3:47) ]

    May 04

    Getting a temporary filename the easy way - feedback

    Path.GetTempFileName() guarantees that you will get an available name, it does actually go ahead and create the file so it is guaranteed to be yours when you use it. If you strip the extension off and substitute your own you may end up overwriting an existing file. Not a smart thing to do.

    In my case, I just really want the filename. Whether or not I change the extension, that file is mine to do with what I will. Also, since it's not in the same folder as the originating file, it can be the exact same name, extension and all, and it will still be a different file that what was generated by the framework. I should take care of file cleanup, and that zero byte file is still in the temp directory...

    Be aware the GetTempFileName() actually creates a zero byte file in the temp folder. Your code will leave the temp file behind in the temp folder. If you use that a lot, you will end up with a lot of files in the temp folder.

    true! So, maybe I was a little quick to post about this one, but it was one of those things that struck me as particularly useful. If you just want a temporary filename, and want to clean up the file that is created by GetTempFileName(), perhaps this will work a little better:

    string GetTempFileName(){
    	string filename = Path.GetTempFileName();
    
    	File.Delete(filename);
    
    	return Path.GetFileNameWithoutExtension(filename);
    }

    Okay y'all...rip it to shreds :) If I've missed something else obvious, call me out. Or, if you have a preferred method of generating temporary file names, show the way.

    Getting a temporary filename the easy way

    If you need to generate temporary / semi-unique filenames, here is a little snippet that uses the framework:

    using System.IO;
    
    string GetTempFileName(){
    	return Path.GetFileNameWithoutExtension(Path.GetTempFileName());
    }

    As the name implies, this will return the temporary name of a file without the extension, so it's up to you to add whatever filetype you may be trying to create. For example, let's say I wanted to generate a .gif:

    string GetTempGifFileName(){
    	return string.Format("{0}.{1}", GetTempFileName(), "gif");
    }

    I had overlooked this little piece of functionality because the component that I was using generated filenames with GUIDs, so I never really worried about it. Way to make my life easier, .netfx :)

    [ Currently Playing : Mississippi Queen - Ozzy Osbourne - Under Cover (4:11) ]

    April 14

    the yield statement - not so mysterious after all?

    Using Yield in Practice
    The moral of the story is STOP thinking so hard about it, just use "yield return" the next piece of data in the list.  When using the yield statment GetEnumerator's job is to answer foreach's question - "what's my next item please".  Walk all the items in your collection and yield return what you want.  Don't worry about remembering where you were - that's all part of the generated statemachine goo - it will stop and start the function you write as it pleases in it's MoveNext implementation or whatever (cause we dont really care - we're not suppposed to be thinking, remember?) .  =)

    [Via jfo's coding]

    I'll admit, I haven't thought a whole lot about yield because, well, I couldn't find anything that described what it did in terms I could understand. I just kept thinking "oh, cool, another new feature in .net 2.0 that I'll get to learn by the time 3.0 comes out" and moved on to the next task.

    Thinking about it as kind of a "macro" (similar to what a using(){} block does) lets it gel a little better.

    March 30

    Visual Studio 2005 Designer: Touchy, Thouchy!

    If you do anything "out of the ordinary" in your UserControl or Form derived classes in Visual Studio 2005, let me introduce you to a little snippet that will probably save you lots of headaches:

    if ( DesignMode ) return;

    or, its equally useful counterpart

    if(!DesignMode){
    	doStuff();
    }

    Now, the "out of the ordinary" thing I was doing was...hooking up an instance EventHandler using a static property that exposes a Form derived class in an OnLoad override. What? I know, not the clearest situation, and probably one that could use a boatload of refactoring, but it works. In short, if you are having designer problems in Visual Studio 2005, it may be worth it to sit back for a bit and think about what introduced the designer error. Prime candidates are constructors and OnLoad overrides that use static methods for functionality. This code didn't allow me to view the designer of a different form:

    public override void OnLoad(EventArgs e){
    	AppManager.ConcreteEditorForm.NewPostCreated += new EventHandler(HandleNewPost);
    }

    while this one would:

    public override void OnLoad(EventArgs e){
    	if( DesignMode ) return;
    	AppManager...
    }
    March 09

    PostXING - It's Beta Time!

    For the adventurous among you, we've decided to release beta 1 of PostXING available for download at ProjectDistributor!

    There are a few known issues, but as far as I know there aren't any showstopper bugs. I've been running the development build for quite some time now, and for PostXING v1.1 users, I think this release is a big step up in terms of usability. Since the only working provider at this time is the MetaBlogProvider, the functionality remains basically the same, i.e. you can manage a MetaWeblog enabled weblog using PostXING from your desktop.

    If you find any issues, bugs, or you just think something could be done better, head on over to the Gemini issue tracker. To add an issue, click the All Issues link and then Create Issue at the top of the page. If you don't want to get that involved, you can always use the contact form over at PostXING.net to at least get your issue addressed...or you could just let it ride and hope I run into it myself :)

    If you're feeling really adventurous and want to hack on PostXING, you can do so by using TortoiseSVN and pointing to http://postxing.net:8080/PostXING. All main development is done on the trunk by version. If you don't like how something works, send me a diff. I think I've been pretty receptive to criticism and feature requests (even tho we can't put them all in at once), so the very least that will happen is that you will be able to use a program that you feel works better. Thanks, and enjoy!

    [ Currently Playing : Jesus Just Left Chicago - ZZ Top - Tres Hombres (3:31) ]

    March 01

    PostXING plugin: MetaPinger

    Well, it turns out that PostXING's mystery plugin author is none other than Taras Naumtsev, and Taras is on fire! Check out the new MetaPinger plugin:

    MetaPinger is a PostXING plugin that notifies a number of services that keep track of
    weblogs and publish them. By pinging, you let the services know that your blog has been updated ,
    they crawl your blog, publishing your site contents, thus increasing your blog's popularity.

    MetaPinger


    Setup
    Extract the ZIP archive into the "plugins" subdirectory of PostXING's install directory

    Configuration
    You will need to configure MetaPinger plugin to notify ping services.
    Enter blog name.
    Enter blog url.
    Add ping service urls ( one per line )

    MetaPinger - Configuration

    Usage
    To ping press the "Ping" button.

    Download MetaPinger plugin

     

    MetaPinger has been tested with the following ping services:
    http://1470.net/api/ping
    http://api.feedster.com/ping
    http://api.moreover.com/RPC2
    http://api.moreover.com/ping
    http://api.my.yahoo.com/RPC2
    http://blogdb.jp/xmlrpc
    http://blog.goo.ne.jp/XMLRPC
    http://coreblog.org/ping/
    http://ping.blo.gs/
    http://ping.bloggers.jp/rpc/
    http://ping.blogmura.jp/rpc/
    http://ping.cocolog-nifty.com/xmlrpc
    http://ping.syndic8.com/xmlrpc.php
    http://rpc.blogbuzzmachine.com/RPC2
    http://rpc.blogrolling.com/pinger/
    http://rpc.technorati.com/rpc/ping
    http://www.weblogues.com/RPC/

     

    Technorati Tags:  PostXING  Tagging  Utility  Software  Blogware  Plugin 

    [Via .Net Adventures ]

     

    [ Currently Playing : Beef (Feat. Mobb Deep) - The Notorious B.I.G - (4:57) ]