Categories
Geeky/Programming

C# 3.0 Features – Extension Methods

C# 3.0 and .NET 3.5 are out and ready for consumption, and I have been using some of the new features. One of the new features, Extension Methods, is really cool and can help you consolidate and reuse your code in a logical manner. Take for example, System.Data.DataSet – there is always something I do when getting a DataSet back. Check if it isnull and check if the table in the [0] index has more than zero rows.

Now, you end up having all these if statements to check this every time you get a DataSet back. Something like this:

DataSet myDataset;
myDataset= _database.ExecuteDataSet(dbCommand);

if(myDataset != null && myDataset.Tables[0].Rows.Count > 0)

{

…

}

Now, in previous versions of .NET, you could make a method in a Core library you have, or whatever and pass in the dataset and pass back a bool if that dataset met that condition. What you can do now is this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace SteveNovoselac.MyCoreLib.Common.Extensions
{
    public static class DataExtensions
    {
        public static bool IsEmpty(this DataSet d)
        {
            if (d != null && d.Tables[0].Rows.Count > 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}

You can see, I created a class called DataExtensions. I have a method "IsEmpty()" that takes "this DataSet d" (this makes it an extension method for DataSet)

Now, in my code I can do this:

if(myDataset.IsEmpty())
{

…

}

Awesome! Next time I will go over Automatic Properties and the pros/cons in them.

Categories
Blogging Life Random

Madison Blogger Meetup

Trying to get a Madison Blogger Meetup going. There is a Facebook group here: http://www.facebook.com/group.php?gid=17843681384

Hopefully next week (Thursday  Feb 21st, at Mickey’s Tavern)

Everything is subject to change at this point 🙂

On an unrelated note, Obama is in Madison tonight, at the Kohl Center. I got called 3 times to go and twice to go by people here. I am not going, I will watch it streaming online and watch MSNBC for the Chesapeake Tuesday results 🙂

Categories
Uncategorized

links for 2008-02-11

Categories
Geeky/Programming

iPhone: 1.1.3 Firmware and YouTube "You must first connect to iTunes with an Internet connection to enable Youtube"

So, after I upgraded to 1.1.3 Firmware on my iPhone, I tested everything. Everything works as planned, even my voicemail works great (not visual VM, but when I hit VM when on a diff carrier it actually goes to my VM!)

But, one issue I saw: "You must first connect to iTunes with an Internet connection to enable Youtube" when I tried to use YouTube

To fix: go to Installer.App, add a source "i.unlock.no" , let it refresh, then install the YouTube Activation Fix. Restart your iPhone and it works! Brilliant!

Categories
Geeky/Programming

Cisco VPN – Launch a Hidden Constant PING Window on Connect

The other day I blogged about getting Cisco VPN to stay connect in Vista. The fix was a constant ping. It is all good but then you have this CMD window open all day in your taskbar, just taking up space, etc.

I decided to workaround it.

I created a .vbs (Visual Basic Script) called pingserver.vbs and put this in it:

Set WshShell = WScript.CreateObject("WScript.Shell")
cmd = "ping servername -t"
Return = WshShell.Run(cmd, 0, True)
set WshShell = Nothing

(replace servername with your name of the server you want to constant ping)

Then in Cisco VPN. Options Menu->Application Launcher. Check "enable" and browse to your VBS. Then when you connect it will run that VBS file, and you will have a hidden constant ping going to your server. Nice..

 

Categories
Product Reviews

Trying a new IM client: Digsby

I decided to try out a new IM client tonight, Digsby

I have been using pidgin for a long time and really like it. Looks like digsby is just like pidgin with some more features, so that is cool. I used code "lifehacker" to download/install

Check it out if you are sick of your current (read: trillan) IM client

Technorati Tags: ,,,
Categories
Geeky/Programming

iPhone Hacking: Updating my 1.1.1 Unlocked iPhone to 1.1.2, then 1.1.3 (Activate, Jailbreak, Unlock, oh my!)

I tried this http://cre.ations.net/blog/post/the-113-soft-upgrade-jailbreak-faq but for whatever reason it thinks my phone isn’t 1.1.1 and jailbroken, so I had to find another way.

found this: http://modmyifone.com/wiki/index.php/OsX113devjailbreak

but I am 1.1.1, so need to update to 1.1.2, so I followed this tutorial http://modmyifone.com/wiki/index.php/Getting_Started_iPhone_Modding_OS_X_current_3

Worked great .. well wait, at the end my phone was stuck in restore mode. Doh. What to do? Well, try to restore 1.1.2 again I suppose, probably going down debacle road here.. we will see..well I decided to restore back 1.1.1 (http://modmyifone.com/wiki/index.php/Getting_Started_iPhone_Modding_OS_X_current) first, then go back to 1.1.2 again..

Unlocked 1.1.1 again using the same method I did before (the prefs, but did the jailbreakme.com stuff)

I restored to 1.1.2 then, and it was at emergency screen. I decided to use independence 1.1.3 beta to active/jailbreak 1.1.2 for me, so now I am there, not unlocked yet. I need to get Installer.app on there manually here (http://rapidshare.com/files/87105691/Installer.zip.html)

I then decided to unlock using AnySim 1.2.1u before trying 1.1.3 (maybe just so I could check my text messages in between upgrades? :)) Didn’t work. Forgot to turn on airplane mode. Restored back 1.1.1, then to 1.1.2, but this time I used independence to get it out of restore mode at the end (the tutorial above doesn’t say that – so the first time I did it, I figured I messed up or something! Doh!)

Now, lets unlock this baby using AnySim 1.2.1u (http://modmyifone.com/wiki/index.php/Unlock_the_iPhone_1.1.2_Upgrade) – remembering airplane mode!!!

Ok that worked, now I am on 1.1.2, unlocked, jailbroken, ready to go to 1.1.3..(http://www.modmyifone.com/forums/showthread.php?t=27648)

After it running for an hour, then a black screen for a while, I decided to reboot, and BOOM 1.1.3! I love the web clips, I put Facebook, Google Reader and Meebo on the home screen, as well as installed the Contacts Icon app through installer.app (since I am running 1.1.3, jailbroken, and unlocked (T-Mobile))

Whew..I am sure I missed some thing in between here, but I kind of "live blogged" it 🙂

The Google Maps locate map feature doesn’t work by default (known issue when upgrading/unlocking) So I am installing Navizon to try that, I guess it fixes Google Maps (http://repo.navizon.com to sources in Installer.app)

Categories
Blogging

WordPress 2.3.3, PHP, Windows Live Writer, Allowed memory size of 8388608 bytes exhausted

After I updated to WordPress 2.3.3, I was seeing some pages in my admin screens getting errors like this:

Allowed memory size of 8388608 bytes exhausted

WTF? So, pages still worked though. I cleaned out everything I wasn’t using (themes, plugins, etc) in my WordPress directories, still getting it.

So researched a little, had to edit my php.ini in the etc directory of my webhost. I changed memory_limit from 8M to 16M. Pages started working again. cool!

Anyways, Windows Live Writer was getting an error on posting after I upgraded "Invalid response document returned from XmlRpc server" and the post would save as a draft in WLW (but still post to my blog)  After posting to the WLW groups on MSN, Joe Cheng at Microsoft wrote me to send me the WLW log file. (Help->About->Show Log File). After looking at the log file myself I noticed the same "Allow memory size…" errors and realized that the php.ini fix probably fixed the posting problem.

After I fixed the php.ini, my posts now go through with no issue.

I know some people have just updated the xml-rpc.php and they are having issues. I recommend just updating your whole WordPress installation. If you are using a custom theme you are ok. Just disable your plugins and re-enable after updating the files. the wp-config.php doesn’t get overwritten, so you are ok.

Categories
Geeky/Programming

Get Microsoft Windows Vista SP1 RTM NOW!

Ok, so I wasn’t sure about this, but tried. it.

Create a batch file with this in it and execute:

@echo off

reg delete HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateVistaSp1 /f > NUL 2>&1
reg delete HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionWindowsUpdateVistaSP1 /f > NUL 2>&1

reg add HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateVistaSp1 /v Beta1 /t REG_SZ /d dcf99ef8-d784-414e-b411-81a910d2761d /f
IF NOT %errorlevel% == 0 ( goto ERROR)

:SUCCESS
@echo.
echo ===========================================================
echo  Windows Vista SP1 registry key has been set successfully.
echo  Please check for updates in Windows Update.
echo ===========================================================
@echo.
goto END

:ERROR
@echo.
echo ===========================================================
echo  FAILED to set Windows Vista SP1 registry keys.
echo  Please run this script by right clicking and selecting
echo  "Run as Administrator".
echo ===========================================================
@echo.
goto END

:END
pause

Then run windows update. I had to install and reboot twice with two updates first before I got the SP1 download. In Windows Update it says it is the RC1 version, but after install my build is 6001.18000.x86fre.longhorn_rtm.080118-1840

which I have read in various forums is the RTM version that matches Windows Server 2008 RTM

Works for me. If it isn’t RTM, I will just update when it comes out.

Categories
Blogging

Upgrade Your WordPress Installation – ASAP!

There have been a few security related fixes for WordPress released. The are currently on 2.2.3

http://wordpress.org/development/2008/02/wordpress-233/

I use HostMySite.com for my hosting and they won’t upgrade your WordPress installation for you, so you need to do it yourself. Pretty simple, just follow the directions here:

http://codex.wordpress.org/Upgrading_WordPress

I backed up my WordPress instance, then disabled my plugins, then uploaded the files to FTP over my existing files, then hit the upgrade link on my site, and it all worked.

I already had Akismet plugin but they have a new version in the 2.2.3 zip file, everything worked after, I just re-enabled it. As for my other plugins, some work, some have new versions that I need to update..

Viper’s Video Tags causes errors with class-snoopy.PHP , I have tried numerous things to fix it but it seems that the only one at this point that I can get to work is to disable the plugin, which means all my YouTube videos are not working at this point – ugh…

Technorati Tags: ,,,