bit by bit

The largest upload starts with the first bit. (Inspirational)

Elmah Security

Nuget packages make adding Elmah to your project a breeze, but don’t forget to add some security to it’s visibility.

If you are using a ASP.Net based role provider, you can add the following settings to your web.config so that only a specific role can see elmah.axd

<location path="elmah.axd">
    <system.web>
        <authorization>
            <allow roles="admin" />
            <deny users="*" />
        </authorization>
    </system.web>
</location>

If the users is in the admin role, it will allow him, otherwise it’s a denial.

Don’t forget to allow remote access, so that you can see the log from around the world ;)

<elmah>
    <security allowRemoteAccess="1" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Elmah.ErrorLog" />
</elmah>

SQL Server 2008 - Rebuilding System Databases

I was having a Collation conflict on my Dev SQL Server, unfortunately it was a third party product so I couldn’t change to code to go around the conflict. Additionally I didn’t want to uninstall and reinstall my SQL Server

So I ended up rebuilding my system db’s, using the SQL Server setup executable.

  1. Download or execute the SQL Server installation file. When you execute the file it will extract it’s content to a folder in your drive, and when you close it the directory gets deleted. You can make a copy of the directory while the file is open.
  2. Open up the command prompt (cmd.exe) (I tried as an Administrator). 
  3. Execute the following command on the setup.exe file:
    setup.exe /ACTION=REBUILDDATABASE /INSTANCENAME=SQLEXPRESS /SQLSYSADMINACCOUNTS="Windows Username with spaces" /SAPWD=myWindowUserPassword /SQLCOLLATION=SQL_Latin1_General_CP1_CI_AS

Notes:

  • I had a Mixed authentication mode, so I used my windows account. And because it had spaces I enclosed the username in quotes.
  • You could add the /QUIET to hide all dialogs, but I removed it so I could get the error message.
  • The log file is in your installation directory ex. C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log

(Source: blogs.msdn.com)

Visual Studio 2010 and Beyond Compare

If you are thinking about using Beyond Compare for Visual Studio, you probably are using Team Foundation, so you need to look into

Tools -> Options -> Source Control -> Visual Studio Team Foundation -> Configure User Tools...

And then just setup the compare and merge commands:

Command: PathToBeyondCompare\BComp.exe

Arguments:

  • Compare:  %1 %2 /title1=%6 /title2=%7
  • Merge:  %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9

(Source: stackoverflow.com)

BitBucket ssh-agent annoying password

So I followed BitBucket instructions to import my code:

$ cd /path/to/my/repo 
$ git remote add origin ssh://git@bitbucket.org/guzart/abccc.git
$ git push -u origin master

And for some reason git kept asking me for the password even if I had the ssh-agent running, setup my public key on BitBucket.

Turns out for some reason my “git remote” was pointing to the https repository url, so after removing the remote and adding the remote again without the ssh:// the ssh-agent kicked in.

$ git remote rm origin
$ git remote add origin git@bitbucket.org/guzart/abccc.git
$ git push -u origin master

Now if you are adding the new remote to different computer but already have code in the server, do not use the git push -u, instead set your config to merge with the new remote.

$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master

Ruby Segmentation Fault

Even if there was plenty of info around, it was still a pain. I am using Snow Leopard with RVM and Ports.

First I tried:

rvm install ruby-1.9.3 --with-openssl-dir=/opt/local \ --with-iconv-dir=/opt/local

as described in: 55 Minutes Ruby Segmentation Fault 

But even if I had the openssl 1.0 using ports and the latest iconv, it will stil give me an error. Until I finally tried a combination of the answers at this post: Ruby Segmentation Fault and Open SSL

$ rvm remove ruby-1.9.3
$ export PATH=/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.rvm/bin
$ rvm pkg install iconv
$ rvm install ruby-1.9.3 --with-openssl-dir=/opt/local --with-iconv-dir=$rvm_path/usr

Basically use openssl from ports but a local package for iconv.