Wednesday, December 30, 2009

Resolved: "failed to build gem native extension" on Windows

Running:
- Windows XP SP3
- Ruby 1.8.6 (patchlevel 383, i386-minw32)

Problem:
When trying to do "gem install" on certain gems, I got a message "failed to build gem native extension" and the installation would fail. Some common gems that this happens to include ruby-debug, ruby-debug-ide, hpricot, sqlite3-ruby, and ruby-oci8.

Resolution:
Install the Ruby Development Kit from RubyForge. It's currently only available as a .7z file, so you'll need 7Zip to open it. Follow the instructions in the included INSTALL.txt file, but make sure when you copy the bin folder to your Ruby installation that you copy just the files inside it. Don't overwrite your Ruby installation's bin folder. That would be very bad.

Notes:
So what is a native extension and why is trying to install this?
Your Ruby interpreter (the ruby.exe program) is written C (or Java if it's jruby). Certain gems need to actually add C libraries to your Ruby installation in order to function properly, not just ruby-language files. They're usually downloaded as source (not binaries) and compiled on your machine to match your system's architecture. The problem is when, for instance, your machine doesn't have a C compiler available or not the same one as the gem is expecting (you may see something about "MSC version unmatch" if the version is different). The Ruby Dev Kit comes with a C compiler (gcc) that runs on Windows and is (probably) compatible with the gems. This resolved my issue.

The fact that you have to download the Dev Kit for building native extensions is apparently a recent change (Nov. '09), and it probably only applies to Windows Ruby installations. This change is currently not well documented, which is why I'm posting my findings.

This can also manifest itself in NetBeans IDE if you opt to install the FastDebugger and get similar error messages about native extensions failing to build.

Related Links:

Monday, November 30, 2009

Resolved: SQL Server Agent job notifications fail with "failed to notify '(operator name)'"

Running:
- Windows Server 2003 (5.2, build 3790)
- SQL Server 2005 (9.00.4053.00)

Symptoms:
- A job in SQL Server Agent is set to have an email notification sent to an operator when it fails, but the notifications don't send.
- Running Management > Database Mail > Send Test E-Mail does work, however.
- In the job history, each failed attempt is followed by "NOTE: Failed to notify '(operator name)' via email.".
- In the SQL Agent error log, there is a message saying, "Unable to start mail session... profile name is not valid..."

Solution:
- Go to SQL Server Agent > Properties > Alert System.
- If "Enable mail profile" is unchecked, check it and restart the SQL Server Agent.
- If is checked and still doesn't work, UNcheck it, restart the SQL Server Agent, then go back in and check it again, and then restart SSA again (this fixed my issue).

Commentary:
I found a lot of posts about this issue. Most revolved around the fact that by default the SQL Server Agent comes with the mail profile disabled. But it took me a few hours to resolve this, so it sounded like a good one to post here for others.

There is also a
Microsoft HotFix for certain related problems, but if you've been keeping your system up-to-date, you probably already have installed it in a cumulative update.

You may also want to check out this:
http://msdn.microsoft.com/en-us/library/ms175984.aspx

Thursday, November 5, 2009

SQL dyanmic queries run in separate connections

In SQL Server 2005, it appears that all dynamic queries run in separate connections from that of the query which generated them. This makes a big difference if you are using connection-specific temp tables (e.g., #MyTempTable).

Here's a few examples in SQL Management Studio to demonstrate what's going on.

Query:

--in a dynamic query, create a local temp table and select from it
PRINT 'Example A:'
EXEC('CREATE TABLE #ConnectionTempTable ( [Foo] INT, [Bar] BIT, [Junk] NVARCHAR(100) ) SELECT * FROM #ConnectionTempTable')
PRINT '------'

--in a dynamic query, create a global temp table; then in the static query, drop it
PRINT 'Example B:'
EXEC('CREATE TABLE ##GlobalTempTable ( [Foo] INT, [Bar] BIT, [Junk] NVARCHAR(100) )')
DROP TABLE ##GlobalTempTable
PRINT '------'

--in a dynamic query, drop the local temp table from Example A (FAILS!)
PRINT 'Example C:'
EXEC('DROP TABLE #ConnectionTempTable')
PRINT '------'

--in a dynamic query, recreate the temp table from Example A (FAILS!)
PRINT 'Example D:'
EXEC('CREATE TABLE #ConnectionTempTable ( [Foo] INT, [Bar] BIT, [Junk] NVARCHAR(100) )')
SELECT * FROM #ConnectionTempTable


Results:

Example A:

(0 row(s) affected)
------
Example B:
------
Example C:
Msg 3701, Level 11, State 5, Line 1
Cannot drop the table '#ConnectionTempTable', because it does not exist or you do not have permission.
------
Example D:
Msg 208, Level 16, State 0, Line 20
Invalid object name '#ConnectionTempTable'.

Thursday, October 8, 2009

Resolved: iPhone OS 3.1 download error 3259: "network timed out"

I haven't seen any help about this online so far, but I resolved the issue, so I'm posting my findings.

I have:
- iPod Touch 16GB
- iTunes 9.0.1.8
- Windows XP SP3
- ESET Antivirus 3.0.672.0

Problem:
After paying the $5 to upgrade from iPhone OS 2.1.1 to 3.1.1, the software download in iTunes stopped after completing and eventually displayed an error message that the "network timed out". On the downloads page, it showed error code 3259.

Resolution:
My antivirus software (ESET) was stealing the file from iTunes after the download completed, scanning it, and not returning it in a timely manner, since the file was rather large. I temporarily disabled the antivirus software, restarted the download, and then everything worked fine. (Don't forget to reenable your antivirus when you're done!)

I hope this can help save you a headache!

Thursday, September 10, 2009

Beware of Courier font in Firefox

I noticed today that in Firefox (3.5.2), the Courier font does not size well at all. The smallest it gets is about 12px.

If you want a nice fixed-width font that does work well in Firefox, use Courier New instead.

Tuesday, September 8, 2009

NoMethodError, undefined method `call' for MyController:Class

If you're getting this error:
NoMethodError in MyController#my_action
undefined method `call' for ClientScriptsController:Class

...then you might have forgotten to make your controller inherit (extend) the ApplicationController class, like I did. The big clue is that the undefined method is in the class, not the instance.

Controllers should be set up like this:

class MyController < ApplicationController
def my_action
#do something...
end
end

Friday, August 28, 2009

booleans in ruby


Here's an interesting tidbit about the Ruby language: it has no native boolean type. The true and false keywords are actually instantiations of the TrueClass and FalseClass types. In ruby, things evaluates as a boolean like so:

- false and nil are false

- everything else is true

Sounds intuitive, but it may trip up programmers used to C-style languages to know that 0 (zero) evaluates to true. Here are some tests:





Tests run using Ruby 1.8.6.

Check out this Wikipedia article for more details about booleans in Ruby.

Wednesday, July 8, 2009

Oracle Installation error: ORA-12560

I'm setting up a development environment on my machine for a new web app in Ruby on Rails with an Oracle back-end. This was my first time installing an Oracle database. It's quite an archaic and un-user-friendly process. The good news is, I've spent a lot more time praying than I usually do while at work. I'll try to keep this short.

OS: Windows XP, SP3
Installing: Oracle 10g Standard Edition
Steps:
  1. Download the zipped 10gR2 installer package from Oracle's website (~625MB).
  2. Extract the zip file somewhere on my hard drive.
  3. Run the setup file in the extracted folder.
  4. Follow the wizard, selecting not to create the sample database at the beginning. Use the defaults for everything else. Yay, now we've got an empty Oracle installation.
  5. Now to create a database. Click Start > All Programs > Oracle - OraDb10g_home1 > Configuration and Migration Tools > Database Configuration Assistant.
  6. Follow the wizard, keeping the defaults (except I changed the character encoding to Unicode).
The Problem: I got a whole ton of error dialog boxes popping up. I chose "ignore" on all of them, allowed the database to finish being created, and then took a look at the log file (myOracleFolder\product\10.2.0\db_1\cfgtoollogs\dbca\myDatabaseName\emConfig.log). The log file mentions:

CONFIG: ORA-12560: TNS:protocol adapter error

oracle.sysman.assistants.util.sqlEngine.SQLFatalErrorException: ORA-12560: TNS:protocol adapter error

at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeImpl(SQLEngine.java:1467)
at oracle.sysman.assistants.util.sqlEngine.SQLEngine.connect(SQLEngine.java:814)
at oracle.sysman.emcp.util.GeneralUtil.initSQLEngine(GeneralUtil.java:363)
at oracle.sysman.emcp.DatabaseChecks.validateUserCredentials(DatabaseChecks.java:986)
at oracle.sysman.emcp.ParamsManager.validatePassword(ParamsManager.java:2694)
at oracle.sysman.emcp.EMDBPreConfig.checkConfigParams(EMDBPreConfig.java:1268)
at oracle.sysman.emcp.EMDBPreConfig.checkParameters(EMDBPreConfig.java:1060)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:174)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:160)
at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:141)
at oracle.sysman.assistants.util.em.EMConfiguration.run(EMConfiguration.java:430)
at java.lang.Thread.run(Thread.java:534)
Jul 8, 2009 9:50:33 AM oracle.sysman.emcp.EMConfig perform
SEVERE: Invalid username/password.
Refer to the log file at C:\oracle\product\10.2.0\db_1\cfgtoollogs\dbca\orcl\emConfig.log for more details.
Jul 8, 2009 9:50:33 AM oracle.sysman.emcp.EMConfig perform
CONFIG: Stack Trace:
oracle.sysman.emcp.exception.EMConfigException: Invalid username/password.
at oracle.sysman.emcp.EMDBPreConfig.checkConfigParams(EMDBPreConfig.java:1272)
at oracle.sysman.emcp.EMDBPreConfig.checkParameters(EMDBPreConfig.java:1060)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:174)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:160)
at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:141)
at oracle.sysman.assistants.util.em.EMConfiguration.run(EMConfiguration.java:430)
at java.lang.Thread.run(Thread.java:534)


The solution:
Uninstall the half-created database I just made, restart my machine, and then recreate the database. Now it works. *smacks forehead*

Monday, July 6, 2009

Haikus on learnjapanesepod.com

I often listen to a podcast called learnjapanesepod. It's excellent --highly recommended for anyone studying Japanese as a part of this balanced breakfast, including classes, listening to Japanese music, going to Japan, watching anime, and writing nerdy things in Japanese to your wife on your whiteboard at home.

A couple of haikus that I wrote in the their forums were read "on the air" on their podcast last Friday... I'm excited :) . Btw, the name I used was "jensengo".

Here's the link for that episode: http://learnjapanesepod.com/fun-friday-for-3rd-july-2009/.

Monday, March 23, 2009

asp.net crashes

I thought I would note some possible causes of the evil "server application unavailable" message when you try to view an ASP.NET application. It always helps to check your Event Log messages, too.

1) Cause: Incorrect file-system-level permissions. Solution: set the Windows permissions of your web site source code top-level folder to at least allow "Read & Execute", "List Folder Contents", and "Read" access for the following user accounts, where "MyMachineName" is your local machine's name.
- MyMachineName\IUSR_MyMachineName
- MyMachineName\IWAM_MyMachineName
- MyMachineName\ASPNET

2) Cause: Infinite recursion (stack overflow). Solution: fix your code so a method can't call itself infinity times.

3) Cause: Infinite memory allocation (heap overflow). Solution: something in your code is infinitely requesting memory. Check for a spot in your code where a new command is used in an infinite loop or some other situation where it's repeatedly instantiating objects.

Monday, March 16, 2009

Noonday seashore: a Haiku

...and now for something completely differenter. This is my first attempt at a haiku in Japanese. I provided fairly tight English translation which follows the meter.


昼の海
うるさい鴎
そよ風と

A noon-day seashore
Annoying, noisy seagull
With a gentle breeze



I think it has the greatest effect when you read on line at a time, slowly. I had in mind the shore of Lake Michigan in Saint Joseph, MI, where I grew up. There are lots of happy memories on those beaches. The seagulls can be really annoying, too :) . But please feel free to imagine any shore you like. I think Japanese can probably relate to this, since they are surrounded by ocean.

I used incomplete sentences, both in Japanese and English. I'm not exactly sure how it sounds to a native Japanese (please inform me!). So anyways, that's that. Please let me know what you think of either version! I'd appreciate critiques!

Tuesday, February 10, 2009

application unavailable

Here's a helpful tip if you're getting messages like this when you try to access an ASP.NET page you're working on:

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.



The short answer is: probably stack overflow. Check your methods and properties for infinite recursion.

Long answer:

This error is not usually very helpful, and the Event Log doesn't show anything interesting except a note that basically says something really bad happened to aspnet_wp.exe, and it exited unexpectedly. Sometimes you can't seem to pause execution in debug mode, too.

Just in case you're fuzzy on what happens normally, aspnet_wp.exe ("ASP.NET") is a chunk stuck onto IIS to serve your ASPX pages. When IIS gets a request from a web user for a file ending in .aspx, it thinks to itself, "What the heck is this?! ASP.NET, do you know anything about this?" And then aspnet_wp.exe says, "Oh sure, I do those all the time." And then IIS says, "Good-- here, take it!" So ASP.NET goes through executing your code for the page. Little does it know that it has fallen into a doomed execution path of infinite recursion that you created! It keeps looping along, until Windows sees that it has a 1.5 bizillion stack frames, and it says, "Hey you! You're taking more than your fair share, mister!" ...And Windows kills the process. Brutal, I know. Then, the .NET Runtime Error Reporting thingamajig comes along and says, "Oh my gosh! They killed ASP.NET!!" And writes that in your Event Log.

So yeah, watch out for infinite recursion. I suppose a similar problem would happen if you overflowed the heap instead.

Friday, January 30, 2009

Moving files in TortoiseSVN

I'm using WinXP, Subversion 1.5.5, TortoiseSVN 1.5.6.

I was having a little trouble moving some files that were under SVN control, but I was able to quickly find some help on this website: http://vidmar.net/weblog/archive/2007/12/11/subversion-and-tortoisesvn-tips-and-tricks.aspx about doing it.

Don't move files within your repository with Windows Explorer. Instead use the TortoiseSVN > Rename option from the context menu when you right-click a file. Then just use backslashes to specify the directory you want your file (or folder) moved to.

...also, you can use Windows Explorer to move SVN files if you RIGHT-click and drag, not left click. When you release the mouse button, a context menu will show up, where you can choose to "SVN Move to here". That works.