twit...
ter
forrst...
buzz...
words
you...
tube
del.ic...
ious
last...
fm
flick...
R
linked...
in

Fix for rake(0.9.2.2 ruby) that is giving multiple “warning: already initialized constant”

by chris.blazek on 2012/01/11

I’ve gotten these warnings on several boxes I’ve been working on in the past of couple weeks. I’m posting the fix I found online as a note.

 $ rake
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/version.rb:2: warning: already initialized constant VERSION
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/version.rb:5: warning: already initialized constant MAJOR
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/version.rb:5: warning: already initialized constant MINOR
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/version.rb:5: warning: already initialized constant BUILD
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/version.rb:5: warning: already initialized constant PATCH
/home/user/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/version.rb:6: warning: already initialized constant NUMBERS
...
$ gem list | grep 'rake'
rake (0.9.2.2 ruby)
$ gem uninstall rake

Answer ‘Y’ to both questions.

$ gem list | grep 'rake'
rake (0.9.2.2)
 $ rake
Loaded suite /home/user/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
...

Obviously I’m using rvm and not sure if it’s something with the system and rvm that’s causing that.

No Comments

Tricky Users

by chris.blazek on 2012/01/6

I got a wo ticket for one of my apps that information on a site wasn’t showing up every time the user logged into the application.

I built the app in .net 4.0 using the Account login template bound to AD. The template authenticates the user and allows them to view certain parts of the site.
Completely puzzled I vnc’d to the users machine to watch them login. Funny enough the user was entering an extra space at the very end of their username.
The Account template and AD binding ignore this space and authenticate the user and redirect them to the default page. On the default page I use their AD username to query their AD account and security groups setup for this particular app. Of course the AD username with a space doesn’t exist and the group list is returned null.

The interesting part of this issue was creating a workaround to strip any unwanted trailing characters in a username.
Since this is a template bound to ActiveDirectoryMembershipProvider I pretty much had only one option, Client Side Javascript.
I included my code for future use. It never ceases to amaze me what users find on accident.

<connectionStrings>
	<add name="ADConnectionString" connectionString="LDAP://xxxx" />
</connectionStrings>
<system.web>
	<customErrors mode="Off" />

	<compilation debug="true" targetFramework="4.0">
		<assemblies>
			<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
			<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
			<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
		</assemblies>
	</compilation>
	<authentication mode="Forms">
		<forms name=".ADAuthCookie" loginUrl="~/Account/Login.aspx" timeout="60" protection="All" />
	</authentication>
	<authorization>
		<deny users="?" />
	</authorization>
	<membership defaultProvider="ActiveDirectoryMembershipProvider">
		<providers>
			<clear />
			<add name="ActiveDirectoryMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" applicationName="/" connectionUsername="xxxx" connectionPassword="xxxx" attributeMapUsername="sAMAccountName" connectionProtection="Secure" />
		</providers>
	</membership>
</system.web>
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>		window.jQuery || document.write("<script src='/JavaScript/jquery-1.5.1.min.js'>\x3C/script>")</script>

<script type="text/javascript">
	$(function () {
		var content = $('#<%=LoginUser.FindControl("UserName").ClientID %>').val();

		$('#<%=LoginUser.FindControl("UserName").ClientID %>').keyup(function () {
			if ($('#<%=LoginUser.FindControl("UserName").ClientID %>').val() != content) {
				content = $('#<%=LoginUser.FindControl("UserName").ClientID %>').val();
				$('#<%=LoginUser.FindControl("UserName").ClientID %>').val($('#<%=LoginUser.FindControl("UserName").ClientID %>').val().replace(/^\s+|\s+$/g, ""));
			}
		});
	});
</script>
No Comments

whalebones – I don’t want to live in the city no more

by chris.blazek on 2011/12/8

No Comments

js closure magic

by chris.blazek on 2011/12/6

wizards:22 narwhals:3

No Comments
warm it up chris the roof, the roof, the roof is on FIRE
Fork me on GitHub! Get free lemonade!