tag:blogger.com,1999:blog-59720752151391590162024-03-05T00:59:39.666-06:00Software Maniacs NetworkA blog devoted to sharing things I've learned related to software.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-5972075215139159016.post-14837982454162028892016-01-01T11:36:00.001-06:002016-01-01T11:36:39.866-06:00Application.js and Application.css not being cached by my browserI was recently troubleshooting an issue with an application I'm building. I'm using Apache 2.x, Rails 4.x and after properly configuring the asset pipeline for my staging environment to use pre-complied assets and allowing Apache to serve those assets the application.js and application.css files were not being cached by Chrome. At first I thought this was an issue with Rails but quickly tailing the log file indicated that Rails wasn't involved with the assets and this was something on the Apache or browser end. I suspected Apache so I reviewed my configuration but everything seemed just fine. That's when I stumbled across <a href="https://code.google.com/p/chromium/issues/detail?id=110649" target="_blank">this post on Chrome not caching files if HTTPS is used...</a> It turns out that I am indeed using a self signed certificate in my stage environment and my application enforces SSL so that's why these files were not cached by the browser. Maybe this should have been obvious to me but I did spin for a couple hours on this so because of that I thought this post was in order to hopefully save someone else the same effort. Basically, if your using self signed certificates you should expect Chrome to cache your assets.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-85263748951934463122015-09-30T09:14:00.000-05:002015-09-30T09:14:47.152-05:00Food for thought...My normal posts involve technical problems and how I've solved them so please forgive this off topic post but I do feel as though I need to give a plug here.<div>
<br /></div>
<div>
For the better part of three decades I've worked for and with <a href="http://www.mfjspeaker.com/" target="_blank">Michael Johnson</a>. I've learned a great many things from my friend and colleague over time and he's just recently started doing some short podcasts on business and technology. Michael is a true no business business guy and he has an excellent technology background. These podcasts represent many things I've learned from Michael over the years and I urge you to take a few minutes to listen.</div>
<div>
<br /></div>
<div>
Michaels <a href="http://www.mfjspeaker.podbean.com/" target="_blank">podcast page can be found here</a> and one of my <a href="http://mfjspeaker.podbean.com/e/common-sense-comments-your-favorite-technology-word-should-be-no/" target="_blank">favorites of his podcasts is here</a>.</div>
<div>
<br /></div>
<div>
<br /></div>
Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-59782980760509369582015-01-26T02:39:00.001-06:002015-01-26T09:32:09.297-06:00A rake task named database.rake task is loading twice<h3>
What was happening...</h3>
I was working on a Rails 4.1.5 project and ran into a strange issue with some defined rake tasks. Whenever I would attempt to run a task my task would actually run twice. After a fair amount of reading on how this might be possible I ran across this <a href="http://sdqali.in/blog/2012/06/06/know-your-tools-dont-shoot-yourself-in-the-foot/" target="_blank">POST (see Rake's Redefining Behavior section)</a> indicating that if a Rake task was actually loaded more than once the way Rake works it would cause the task definitions to be "appended" to the original or first defined task. This would cause the task to actually run twice which is exactly what I was seeing. That post put me on the right track and I set about trying to determine what could possibly cause the rake file to be reloaded. I added the following bit of code to the top of the rake task file so I could confirm it was definitely loading twice.<br />
<div>
<br /></div>
<div>
<pre class="brush: ruby">if $AM_HERE
puts "AGAIN! LOADED 2nd TIME"
puts "#{caller.join("\n")}"
else
puts "HERE WE ARE FIRST LOAD"
puts "#{caller.join("\n")}"
end
$AM_HERE = true
</pre>
</div>
<div>
<br /></div>
<div>
When I executed the rake task I saw both messages indicating the file was indeed being loaded twice. I was also able to see a stack trace that indicated it was related to dependency loading. The following <a href="http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/" target="_blank">POST (see File Lookup Rules section)</a> was a great help in understanding what was happening.</div>
<div>
<br /></div>
<h3>
Bottom Line...</h3>
<div>
If you run a rake task and it appears to execute twice, look for something unintentionally loading your task file more than once. It took quite some time to track down the cause of this issue. It turns out that the the <a href="https://github.com/rails/activerecord-session_store" target="_blank">0.1.0 version of the activerecord-session_store GEM</a> has a subtle defect with way that it references the <span style="font-family: Courier New, Courier, monospace;">database.rake</span> task in the project. Due to this issue, when Rails was using Railtie to load rake tasks for the GEM, Rails was actually finding my <span style="font-family: Courier New, Courier, monospace;">lib/task/database.rake</span> file and loading it instead of the <span style="font-family: Courier New, Courier, monospace;">database.rake</span> in the GEM. I forked the project and made a quick fix to confirm and then put in <a href="https://github.com/rails/activerecord-session_store/pull/41" target="_blank">my pull request for the fix</a>. </div>
<div>
<br /></div>
<div>
Hope this saves someone time troubleshooting the same error.</div>
<div>
<br /></div>
Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-75344593202637760702014-09-15T16:33:00.001-05:002014-09-16T09:12:15.330-05:00RSpec appears to stop prematurely without any all test output running feature test with Capybara<h2>
Problem</h2>
I recently ran into an issue where a particular feature test (using RSpec and Capybara) was prematurely exiting to the command prompt and not reporting any error. Or at least that is what I thought was happening until I dug into the issue a bit more. As it turns out the normal console output from RSpec wasn't showing completely and then the test would just stop. In reality that test and all other tests were running to completion and this was obvious once I looked in my log files. After I realized that the tests kept running then the other explanation was that something stole $stdout from RSpec.<br />
<br />
<a href="http://stackoverflow.com/questions/21550514/cucumber-tests-suddenly-stops" target="_blank">This post</a> on stackoverflow.com is where I found my answer to the problem. The problem described on this post matched what I was seeing. I inserted the following code:<br />
<br />
<pre class="brush: ruby">Capybara.server do |app, port|
require 'rack/handler/thin'
Rack::Handler::Thin.run(app, :Port => port)
end
</pre>
<br />
near the top of my<b> <span style="font-family: Courier New, Courier, monospace;">rails_helper.rb</span></b><span style="font-family: Courier New, Courier, monospace;"> </span>to trigger the use of Thin instead of the default web server for Capybara. After this change I started to see all the test output. <br />
<br />
I've made this post because it was particularly tricky to figure out what was happening and my search results kept turning up things that didn't help. Hopefully this will help you out!<br />
<br />
<h3>
References</h3>
<div style="background: rgb(255, 255, 255); border: 0px; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 1.3; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<a class="question-hyperlink" href="http://stackoverflow.com/questions/9558777/webkit-server-hangs-periodically-when-run-from-capybara-in-ruby" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: black; cursor: pointer; margin: 0px; padding: 0px; vertical-align: baseline;">webkit_server hangs periodically when run from Capybara in Ruby</a></div>
<div style="background: rgb(255, 255, 255); border: 0px; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 1.3; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<a class="question-hyperlink" href="http://stackoverflow.com/questions/21550514/cucumber-tests-suddenly-stops" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: black; cursor: pointer; margin: 0px; padding: 0px; vertical-align: baseline;">Cucumber tests suddenly stops</a></div>
<div>
<div style="background: rgb(255, 255, 255); border: 0px; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 1.3; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">
<a class="question-hyperlink" href="http://stackoverflow.com/questions/4303401/how-to-make-cucumber-selenium-run-thin-server-instead-of-webrick" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: black; cursor: pointer; margin: 0px; padding: 0px; vertical-align: baseline;">How to make cucumber/selenium run Thin server instead of Webrick</a></div>
</div>
<div>
<br /></div>
<br />
<br />Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-16438414564226138192014-01-02T11:56:00.001-06:002014-01-02T11:56:19.021-06:00Replacing the scaffold_controller Generator in Rails 4<h4>
Background... </h4>
If you're like me, when you start working on a project for hire the pressure to accomplish something quickly often leads to poor software development practices. When I'm running the project I can usually avoid the poor practices and help strike a balance between getting things done and setting things up for future success with some good development practices. On a recent project I found myself in the boat of continuing poor practices already in place by others on the project. The "when in Rome" approach. Although not the worst of practices, one such practice was something I think a lot of us do on Rails projects. We copy around whole sets of CRUD views or partials around and even the controller code and then tweak it to do the next thing we need. This doesn't feel very DRY and every time I do it I think to myself "I should make a Rails Generator to make this easier and less error prone.<br />
<br />
<h4>
Enter a new project... </h4>
A good friend and I have been working on a new project together using Rails 4, Ruby 2.0, and Twitter Bootstrap 3.0. We created the initial model, agreed on general application layout and on using certain javascript components for the UI. I created some initial views and a controller to get things working like we think they should. Normally this is the point when the copy / paste / renaming starts happening but this time I made myself do something different. I decided that rather than creating the next Controller and Views for a new feature I would try to get the Rails scaffold_controller to generate the controller, views, and a presenter we need. This turned out to be quite fun and a good learning experience so I decided to capture the highlights.<br />
<br />
<h2>
How to replace the scaffold_controller in Rails 4 with your own custom version.</h2>
<br />
I could have just created my own Generator but I opted to create a replacement for the scaffold controller because I need to generate a new "presenter" class file and I wanted to keep all the nice stuff (in my opinion) that the current scaffold_controller generator can do.<br />
<br />
<h3>
Where does the code go?</h3>
All of your new code will go somewhere specific in your applications "lib" directory. <br />
<br />
The templates for your CRUD views will go into <b><span style="font-family: Courier New, Courier, monospace;">lib/templates/haml/scaffold</span></b> OR if your using ERB <b><span style="font-family: Courier New, Courier, monospace;">lib/templates/erb/scaffold</span></b>.<br />
<br />
The template for the controller should be placed in <span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><b>lib/templates/rails/scaffold_controller</b></span><br />
<br />
The actual scaffold generator code should be placed in <span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><b>lib/generators/scaffold_controller</b></span><br />
<br />
It should all look something like the directory structure in the following image.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizJYQIEB5ht5Em74bDVzASEoeHnAdiKioJ5IF5FLuvIBkvW6YvVLkjkVzvEGOqkh71hhibupEEP0rpShbRCcxMlFYAtmEy8u3_-W4kFYuXft6aE-9F-EltizRBu6ga5nYqO7Quplba-W4/s1600/Screen+Shot+2014-01-01+at+5.00.20+PM.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizJYQIEB5ht5Em74bDVzASEoeHnAdiKioJ5IF5FLuvIBkvW6YvVLkjkVzvEGOqkh71hhibupEEP0rpShbRCcxMlFYAtmEy8u3_-W4kFYuXft6aE-9F-EltizRBu6ga5nYqO7Quplba-W4/s400/Screen+Shot+2014-01-01+at+5.00.20+PM.png" width="277" /></a></div>
When it came down to getting the initial source for these I just used my own views as a starting point for the CRUD templates. Then I pulled the <span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><b>scaffold_controller_generator.rb</b></span> and <span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><b>controller.rb</b></span> from the Rails source. You can find them in your<br />
<b><span style="font-family: Courier New, Courier, monospace;">railties-4.0.x/</span></b> directory here:<br />
<br />
<span style="font-family: Times, Times New Roman, serif;"><b>lib/rails/generators/rails/scaffold_controller/</b></span><br />
<span style="font-family: Times, Times New Roman, serif;"><b>lib/rails/generators/rails/scaffold_controller/templates</b></span><br />
<br />
If you need to get starting points for the CRUD templates you'll have to pull them from one of two places depending on your template engine. If you using ERB then you can find them in the <b><span style="font-family: Courier New, Courier, monospace;">railties-4.0.x/</span></b> directory here:<br />
<br />
<span style="font-family: Times, Times New Roman, serif;"><b>lib/rails/generators/erb/scaffold/templates</b></span><br />
<br />
Or if you're like me and prefer the HAML templates then you'll want to pull them from your <span style="font-family: Courier New, Courier, monospace;"><b>haml-rails-0.x</b> </span>directory here:<br />
<br />
<span style="font-family: Times, Times New Roman, serif;"><b>lib/generators/haml/scaffold/templates</b></span><br />
<br />
Note: That <b><span style="font-family: Courier New, Courier, monospace;">datatable.rb</span></b> in the <span style="font-family: Courier New, Courier, monospace;"><b>templates/rails/scaffold_controller</b></span> directory is my own custom template I use to create a class that helps me render code for jQuery Datatables. (ie. so you won't find that in the Rails source)<br />
<br />
By placing the code in these locations Rails will successfully use the as overrides to the existing scaffold_controller generator.<br />
<br />
<h3>
Basic scaffold templates...</h3>
<div>
To bring things a little more into perspective. Here's my example <span style="font-family: Courier New, Courier, monospace;">_form.html.haml</span> template:<br />
<br /></div>
<div>
<pre class="brush: ruby">.row
.col-xs-12
= render 'shared/show_record_errors', record: @<%= singular_table_name %>
.col-xs-12
= form_for @<%= singular_table_name %>, :html => {class: 'form-horizontal', role: 'form'} do |f|
<% class_name.constantize.content_columns.each do |attribute| -%>
.form-group
= f.label :<%= attribute.name %>
= f.text_field :<%= attribute.name %>, class: 'form-control'
<% end -%>
.form-group
= bootstrap_save_button(f)
</pre>
</div>
<div>
<br />
<br />
I'm merely showing this as an example of what I'm doing. Might not fit your workflow. I'm using <span style="font-family: Courier New, Courier, monospace;"><b>class_name.constantize.content_columns</b></span> because I'm almost always going to be working with an existing model when using this generator. That's a bit different then the original <span style="font-family: Courier New, Courier, monospace;">scaffold/scaffold_controller</span> implementation on this so you probably should look at the original template for a comparison. Also, don't be fooled by the file extension. This is ERB that is outputting HAML. <br />
<br />
<h3>
Basic scaffold_controller generator replacement...</h3>
<br />
Here's my <span style="font-family: Courier New, Courier, monospace;">scaffold_controller_generator.rb </span>file.<br />
<br />
<br /></div>
<div>
<pre class="brush: ruby">require 'rails/generators/resource_helpers'
module Rails
module Generators
class ScaffoldControllerGenerator < NamedBase # :nodoc:
desc "========================================================================\n" +
"NOTE!!!!!\n" +
"This is an OVERRIDE of the original Rails Scaffold Generator!\n" +
"Used to create Twitter Bootstrap 3.0 HAML views and custom\n" +
"extensions specifically for this project.\n\n"+
"It is assumed that you have already created the associated model and the\n" +
"model will be referenced for creating any field related source.\n" +
"Source can be found in lib/generators/scaffold_controller\n" +
"The template can be found in lib/templates/rails/scaffold_controller\n" +
"========================================================================\n"
include ResourceHelpers
check_class_collision suffix: "Controller"
class_option :orm, banner: "NAME", type: :string, required: true,
desc: "ORM to generate the controller for"
argument :attributes, type: :array, default: [], banner: "field:type field:type"
class_option :disable_common, type: :boolean, default: true, desc: 'SETS: --no-helper --no-view-specs --no-request-specs --no-routing-specs'
def create_controller_files
if @options[:disable_common]
puts 'Project Overrides'
puts 'Disabling: helpers, view-specs, request-specs, and route-specs'
@options = @options.merge(helper: false)
end
template "controller.rb", File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
template "datatable.rb", File.join('app/datatables', controller_class_path, "#{controller_file_name}_datatable.rb")
needed_route = <<-FILE
resources :#{plural_table_name}
namespace :#{plural_table_name} do
post :act_on_list
end
FILE
route(needed_route)
end
hook_for :template_engine, :test_framework, as: :scaffold do |invoked|
if @options[:disable_common]
invoke invoked, [ controller_name ], {view_specs: false, request_specs: false, routing_specs: false}
else
invoke invoked, [ controller_name ]
end
end
# Invoke the helper using the controller name (pluralized)
hook_for :helper, as: :scaffold do |invoked|
invoke invoked, [ controller_name ]
end
end
end
end
</pre>
</div>
<div>
<br />
Again, this code is highly specific to my project. I suspect that really is the only good use of generators because otherwise the code becomes to generic an needs significant modifications to create something useful. In my opinion that almost defeats the purpose of generated code. You really should review the original Rails code for this generator and compare it to what I have for the best picture. However, to help shed some light on that this is doing here's a quick review.
Most of the work is handled in the <span style="font-family: Courier New, Courier, monospace;">create_controller_files</span> method. This method is in the original Rails source and so I just added my code. First thing I'm doing is overriding the generation of "helpers" as I don't find them particularly useful to create the specs right away. I'd rather not have the empty / pending files around as the odds are I won't use most of them. You can also see that I'm using my <span style="font-family: Courier New, Courier, monospace;">datatable.rb</span> template to create a file in they <span style="font-family: Courier New, Courier, monospace;">app/datatable</span> folder. Then because I want to establish some initial routes I'm adding some route information to my <span style="font-family: Courier New, Courier, monospace;">routes.rb</span>. Moving on to the hook_for event handlers you can see that I've basically added some code that will override the creation of other spec files I don't want to create initially.<br />
<br />
<h3>
<span style="font-family: Courier New, Courier, monospace;">Running the generator... </span></h3>
This is the best part of overriding this generator. I don't have to remember a new generator name or how to run it since I basically have the same generator but it's using my Bootstrap 3.0 related view templates and my own custom presenter for jQuery Datatables. <br />
<br />
<span style="font-family: Courier New, Courier, monospace;">bundle exec rails g scaffold_controller ModelClassName</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<h3>
<span style="font-family: 'Courier New', Courier, monospace;">References...</span></h3>
</div>
<div>
<span style="font-family: 'Courier New', Courier, monospace;"><a href="http://guides.rubyonrails.org/generators.html" target="_blank">RoR Guide</a></span></div>
<div>
<a href="http://stackoverflow.com/questions/8688220/rails-3-1-changing-default-scaffold-views-and-template" target="_blank">StackOverflow POST on where to override template files</a></div>
<div>
<a href="http://spilth.org/notes/rails3-custom-scaffolding/" target="_blank">Post - Notes: Rails 3 Custom Scaffolding</a></div>
<div>
<a href="http://zigzag.github.io/2010/01/18/customizing-your-scaffold-template-become-easier-in-rails3.html" target="_blank">Post - Customizing your scaffold template become easier in Rails3</a></div>
<div>
<a href="http://nicksda.apotomo.de/2010/09/getting-a-bloody-rails-3-generator-running-and-testing-it/" target="_blank">Post - A Rails 3 Custom Generator </a></div>
<div>
<br /></div>
Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com1tag:blogger.com,1999:blog-5972075215139159016.post-37846782361390158892013-11-18T22:15:00.000-06:002013-11-18T22:15:02.630-06:00Setting cell color using Ruby spreadsheet GEMI've recently been working on a Rails project and needed to output some data in spreadsheet format. My client wanted some simple styling of the spreadsheet but the standard colors didn't seem to fit the bill. That's when I discovered that there are other options besides :red, :blue, :green, :cyan, etc. for the background style on a spreadsheet cell using the spreadsheet GEM. Although I couldn't find any reference to these additional colors it is obvious from looking through the source code for the GEM that they exist. Unfortunately, the symbol names used to represent these "additional" colors didn't lend themselves very well to visualize what color they represented. They are :xls_color_0, :xls_color_1, etc... and you can see them by looking at the <a href="https://github.com/zdavatz/spreadsheet/blob/master/lib/spreadsheet/datatypes.rb" target="_blank">source code here</a>. <br />
<br />
So I decided to output a quick spreadsheet with cell text representing the symbol name and then formatting the cell background with the color. This makes a handy reference for those colors as well as providing some examples of how to format a cell. Here's the source code:<br />
<br />
<script src="https://gist.github.com/brampey/7363955.js"></script>
The <a href="https://gist.github.com/brampey/7363955" target="_blank">Gist is here</a>.<br />
<br />
The program will output a file colors.xls that looks like the following:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioTPA4aF_JbH96CLOeOBx_ZEqo2y6Zte4zfVcigrEfDlwH4CBAJ_bUOvCPmqlaZlVgSCrJYGHRayAU_K0mDA3GND7RGK_Xp_Qew3PrgpbBFxKsMgJ5eS9Zl8iZTxsh-Hq_Nm9RPFWvLLQ/s1600/Screen+Shot+2013-11-07+at+7.04.51+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="456" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioTPA4aF_JbH96CLOeOBx_ZEqo2y6Zte4zfVcigrEfDlwH4CBAJ_bUOvCPmqlaZlVgSCrJYGHRayAU_K0mDA3GND7RGK_Xp_Qew3PrgpbBFxKsMgJ5eS9Zl8iZTxsh-Hq_Nm9RPFWvLLQ/s640/Screen+Shot+2013-11-07+at+7.04.51+PM.png" width="640" /></a></div>
<br />Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-65463587326913579522013-11-07T14:16:00.001-06:002013-11-07T18:07:14.747-06:00Capistrano deploy fails with gem hosted on GitHub.comA college of mine and I recently upgraded on of our side projects from a Rails 3 and ruby 1.9.3 to Rails 4 and ruby 2.0. In the course of doing so we needed to ensure that all the dependent GEM's we are using were Rails 4 and ruby 2.0 compatible. As is usually the case someone had done the leg work and although not all of the core projects were updated, he was able to find forks on the original projects that had done the upgrades.<br />
<br />
Today I was finally getting around to making sure the the application could still deploy to our staged environment. Unfortunately it was failing. I use Capistrano for the deployment and I was seeing it fail to clone the one of these GitHub hosted, upgraded GEMs my college found. The error was:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">Permission denied (publickey).</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">fatal: The remote end hungh up unexpectedly</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">Git error: command `git clone 'git@github.com:tsmango/default_value_for.git'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj288SfA-oIJmn-43kTriNEKDjy5uOUdVxivogRRWmorUyDF8U6Dbi7KTYBKTJSYfmVNi4EW_Bhictu_SGxjtJqU2rsr3JXIEd-Cn6GNfcZyfnZ-4tLR3fJfeYdsN40hyPKUQWpi-ZZQIk/s1600/Screen+Shot+2013-11-07+at+2.47.44+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="132" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj288SfA-oIJmn-43kTriNEKDjy5uOUdVxivogRRWmorUyDF8U6Dbi7KTYBKTJSYfmVNi4EW_Bhictu_SGxjtJqU2rsr3JXIEd-Cn6GNfcZyfnZ-4tLR3fJfeYdsN40hyPKUQWpi-ZZQIk/s640/Screen+Shot+2013-11-07+at+2.47.44+PM.png" width="640" /></a></div>
<br />
I immediately tried to clone the project from my terminal window and all worked fine. I thought, GitHub.com must be having an issue but upon checking that out on the status page they were not reporting any issues at all. If I had paid more attention to the details all the clues I needed where right there in front of me but the actual problem still didn't dawn on me until I looked up<a href="http://stackoverflow.com/questions/11557759/gem-file-with-git-remote-failing-on-heroku-push" target="_blank"> this post.</a><br />
<br />
Turns out the our GEMFILE needed to reference the non-SSH read-only URL for the projects so that I didn't need to authenticate with ssh.<br />
<br />
Changed the entry in my GEMFILE from:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">gem 'default_value_for', :git => '<b style="background-color: #ffe599;">git@</b>github.com<b style="background-color: #ffe599;">:</b>tsmango/default_value_for.git'</span><br />
<div>
<br /></div>
to:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">gem 'default_value_for', :github => 'tsmango/default_value_for'</span><br />
<br />
Once that change was made <b>bundle install </b>was required but then I was able to successfully deploy our application.<br />
<br />
Hopefully this saves someone else a few minutes of time troubleshooting similar errors.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-34553189065965730452013-10-22T16:49:00.000-05:002013-10-22T19:48:55.475-05:00Setup cruisecontrol.rb with rbenv and building with multiple ruby versions<h3>
Overview</h3>
I've found it useful to have my Rails projects running tests on changes to the source code repositories. It helps to raise awareness to test failures. I use cruisecontrol.rb for that purpose and have found it to be useful. However, this post isn't about the merits of continuous integration, but rather about how to setup cruisecontrol.rb under rbenv and have it build your Ruby 2.0.0 projects. <br />
<br />
Recently I started working on several Rails 4 projects and at the same time using Ruby 2.0. Unfortunately I ran into several issues with how I was using cruisecontrol.rb to build my projects which up until now have been Ruby 1.8.7 or 1.9.3. Unfortunately, my cruisecontrol.rb setup was choking on Ruby 2.0.0 which was a little frustrating. To simplify my setup a little bit I decided to move from RVM to RBenv to manage my rubies. <span style="font-size: x-small;">(side note: Move from RVM to RBEnv if you haven't, you'll probably thank me in the end) </span><br />
<br />
For this post I'm <b>NOT </b>going into how to setup CruiseControl.rb as there is already ample sources for that information. The same is true for setting up rbenv as you can also find many sources of information for that installation as well. If you want to start off with some sources I've used here they are:<br />
<br />
<b>CruiseControl.rb</b><br />
<a href="http://cruisecontrolrb.thoughtworks.com/">http://cruisecontrolrb.thoughtworks.com/</a><br />
<a href="http://cruisecontrolrb.thoughtworks.com/documentation/manual">http://cruisecontrolrb.thoughtworks.com/documentation/manual</a><br />
<a href="https://github.com/thoughtworks/cruisecontrol.rb">https://github.com/thoughtworks/cruisecontrol.rb</a><br />
<br />
<b>rbenv</b><br />
<a href="https://github.com/sstephenson/rbenv">https://github.com/sstephenson/rbenv</a><br />
<a href="http://edapx.com/2013/05/23/switching-from-rvm-to-rbenv/">http://edapx.com/2013/05/23/switching-from-rvm-to-rbenv/</a><br />
<a href="https://gist.github.com/brentertz/1384279">https://gist.github.com/brentertz/1384279</a><br />
<br />
<h3>
How to Configure CruiseControl.rb to use rbenv and build a Ruby 2.0.0-p247 project</h3>
NOTE: The following assumes you have a working cruisecontrol.rb setup and in addition you're using rbenv to manage your ruby versions.<br />
<br />
First thing you'll need to do is change the cruisecontrol configuration file for your Ruby 2.0.0 project.<br />
Open the file cruise_config.rb located in your .cruise/projects/(project name) folder, with your editor of choice and add the following line:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">project.use_bundler = false</span><br />
<br />
This tells cruisecontrol.rb not to use bundler automatically for your project. This is important because you have cruisecontrol.rb running under Ruby 1.8.7 or Ruby 1.9.x and it will cause bundle failure. <span style="font-size: x-small;">(side note: I'm running cruisecontrol.rb under 1.9.3-p327 for a year now and it works well) </span><br />
<br />
You'll also want to make sure you are using your own project build command. You should include a line<span style="font-size: x-small;"> (or un-comment the one in the default file) </span>so that it looks something like the following:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">project.build_command = '../build_(your project).sh'</span><br />
<br />
I keep my build file in the same directory as the cruise_config.rb file which is immediately above the work folder cruise control uses to build your project.<br />
<br />
So you're cruise_config.rb for the project should look something like this at the end of the file.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-HA_VGhCkl5GXbL2E0ScDuLLwJ3hXzywS6KszNn1OmRolUrwAzORgLtLN1yVst73OFhIJgYx9AvGQJSjiI1zcZeM5NTJ3l_yyIT7lqpFlWsFn9FeSxj_Fqn6E2Lg6XSZB7nsR7zbpOh8/s1600/Screen+Shot+2013-10-18+at+10.55.06+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="301" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-HA_VGhCkl5GXbL2E0ScDuLLwJ3hXzywS6KszNn1OmRolUrwAzORgLtLN1yVst73OFhIJgYx9AvGQJSjiI1zcZeM5NTJ3l_yyIT7lqpFlWsFn9FeSxj_Fqn6E2Lg6XSZB7nsR7zbpOh8/s400/Screen+Shot+2013-10-18+at+10.55.06+AM.png" width="400" /></a></div>
<br />
<br />
After you've made that change you'll need to create or modify your shell script for building your project. My build script looks like this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMbC7YrUZ6BMUDyh7uDnGGGkhv-ULSaplxbMuK1SdAZczXBZxWCXnSqw6EhYcbtkWjXWHVCH05ctcGYKgQVJJ-5RNidX5fUMVD7cEDXdnrFTQEZNb4LsKwQgXh90OBVw9dp5c4eeITqwE/s1600/Screen+Shot+2013-10-18+at+11.02.40+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMbC7YrUZ6BMUDyh7uDnGGGkhv-ULSaplxbMuK1SdAZczXBZxWCXnSqw6EhYcbtkWjXWHVCH05ctcGYKgQVJJ-5RNidX5fUMVD7cEDXdnrFTQEZNb4LsKwQgXh90OBVw9dp5c4eeITqwE/s400/Screen+Shot+2013-10-18+at+11.02.40+AM.png" width="400" /></a></div>
<br />
It's important that you include the <span style="font-family: Courier New, Courier, monospace;"><b>RBENV_VERSION</b></span> line in your script. This identifies the correct ruby version for your build. Also, note the line <b><span style="font-family: Courier New, Courier, monospace;">rbenv exec bundle install </span></b> as it is important for your setup to get the bundle setup correctly since you've told cruise control not to use bundler. Your basically forcing the bundle to run using the specific ruby version. I needed this because my Gemfile specified 2.0 and without it and the <span style="font-family: Courier New, Courier, monospace;"><b>RBENV_VERSION</b></span> line I was seeing this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDL3FNh4QBBqUL_5RrOEOcogN7qPAOFxRhISEUk-hMfuDB184a0aXv1GoSuE6_Lw3Pp_-Bx80D_LNpZCIbbr9RYLdRiDpptuBMgsgwkTmMROPJqDlqW5nxvVDJuCCu35Qmg3gOeTOJB1I/s1600/Screen+Shot+2013-10-18+at+10.55.58+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="299" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDL3FNh4QBBqUL_5RrOEOcogN7qPAOFxRhISEUk-hMfuDB184a0aXv1GoSuE6_Lw3Pp_-Bx80D_LNpZCIbbr9RYLdRiDpptuBMgsgwkTmMROPJqDlqW5nxvVDJuCCu35Qmg3gOeTOJB1I/s640/Screen+Shot+2013-10-18+at+10.55.58+AM.png" width="640" /></a></div>
<br />
I have the lines rbenv and rbenv versions in my build file so that I can see the log file contains the correct version information. This was helpful while troubleshooting this setup.<br />
<br />
It's also important to note that since you are using bundler, instead of cruisecontrol.rb using it, that you might find that your project already has a .bundle/config file that has identified where your bundle should be stored. You might want to change that file. I had to in order to make sure that the bundle wasn't setup globally for all projects.<br />
<br />
Hopefully this helps to get you up and running building Ruby 2.0.0 projects with cruisecontrol.rb<br />
<br />Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com2tag:blogger.com,1999:blog-5972075215139159016.post-76935421271871664902013-09-25T18:06:00.000-05:002013-09-25T18:09:15.865-05:00Postgres SQL connection error - Is the server running locally...I ran into an issue on my Mac Mini today while setting up for a development footprint for a Rails 4 project I'm starting to work on this week. This new project requires Postgres which I have not used before. I ran into a snag installing it on my Mac Mini which is running OS X version 10.8.5<br />
<br />
I proceeded to use homebrew to install by preforming these steps:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">brew update</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">brew install postgres</span><br />
<br />
In typical fashion the recipe presented some notes about continuing the setup. The next steps were:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">initdb /usr/local/var/postgres -E utf8</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist</span><br />
<br />
Then I needed to use the postgres client to create a user and new database. When I issued the command<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">psql -d template1</span><br />
<br />
I received the following error:<br />
<br />
<span style="background-color: #f4cccc; font-family: Courier New, Courier, monospace; font-size: x-small;">psql: could not connect to server: No such file or directory</span><br />
<span style="background-color: #f4cccc; font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Is the server running locally and accepting</span><br />
<span style="background-color: #f4cccc; font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?</span><br />
<br />
The initial indication here is that postgres wasn't running. <a href="http://www.revsys.com/writings/postgresql/errors.html#cannot-connect-local" target="_blank">This post suggests</a> verifying that by using the command:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">ps auxw | grep post</span><br />
<br />
and confirming that postgres was actually running. In my case it definitely was running. Several processes were matched.<br />
<br />
Then I stumbled across numerous post suggesting that the PATH was set wrong. That possibly Mac OS X Mountain Lion actually has pre-installed a postgres client that looks in a different place for the connection socket. I don't know if that's true or not. However, unfortunately for me, it turns out that I was actually running an older / different version of the client located in<b> /usr/bin</b> instead of the newly installed on from homebrew located in <b>/usr/local/bin</b><br />
<br />
You can check by the command:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">which psql</span><br />
<br />
and for me that result was <b>/usr/bin</b><br />
<br />
In my case the <b>/usr/bin</b> directory is in my PATH prior to the <b>/usr/local/bin</b> so rather than reverse that (like I probably should) I opted not to have any other surprises by a PATH change and simply copied the new psql client from <b>/usr/local/bin</b> to <b>/usr/local</b><br />
<br />
Hopefully this helps someone recover from this issue quickly.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-56044361853649229862013-08-23T09:33:00.000-05:002013-09-04T16:30:29.042-05:00Subtle parse error for database.yml file<h2>
Subtle parse error for database.yml file</h2>
<div>
Recently I was setting up capistrano for a new Rails 3.x application deployment. In typical fashion I was adjusting the database.yml file for a new environment but subtly introduced and error. </div>
<div>
<br /></div>
<div>
The specific error was:</div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b>... did not find expected key while parsing a block mapping at line 4 column 1 ...</b></span></div>
<div>
<br /></div>
<div>
The short answer is: Indentation of your YAML is likely off.</div>
<div>
<br /></div>
<div>
At first, the problem wasn't obvious so I ran to Google for help. My search turned up the following <a href="http://stackoverflow.com/questions/11741799/rails-not-parsing-a-valid-yaml" target="_blank">post on stackoverflow.com</a> which has the answer but still required close inspection of the accepted response.</div>
<div>
<br /></div>
<div>
New to me but there is also a site you can use to confirm your YAML: <a href="http://yamllint.com/" rel="nofollow" style="background-color: white; border: 0px; color: #4a6b82; cursor: pointer; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">http://yamllint.com/</a></div>
<div>
<b>(note: It should be obvious but I'll spell it out, don't past YAML with your passwords into the lint site)</b></div>
<div>
<br /></div>
<div>
Hopefully this post helps you resolve something quickly.</div>
Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-71435015021704706472013-02-01T19:40:00.000-06:002013-02-01T19:46:34.453-06:00Microsoft Keyboard with Mac OS X<h2>
Boring story...</h2>
<span style="font-size: xx-small;">(you can skip this part)</span><br />
I've always favored using the best tool for the job at hand. This is something I learned along time ago when working with my grandfather in his workshop. If you have a nail then the tool to use is a hammer. Probably not just any hammer either, there are actually hammers designed to drive nails and ones that aren't. Of the ones designed to drive nails there are different sizes and different manufacturers. Sometimes the manufacturer makes a difference and sometimes it doesn't. I've never forgotten those years and I always have looked to apply those same principals in choosing technologies to work on various software projects during my 28 years developing software commercially. That's what left me trying to use the keyboard I have grown quite use to using with the new Mac Mini that I just recently started using. In this instance writing code is the nail and my hammer of choice is the...<br />
<br />
<h2>
Microsoft Natural Ergonomic Keyboard 4000 v1.0</h2>
It is perfect for me. Unfortunately, even with the Microsoft supplied Mac OS X Intellipoint device drivers the keyboard was frustrating to use on the Mac Mini. The most frustrating point was the number pad <b>NumLock key</b>. It simple didn't function as a NumLock. The keypad on this keyboard when attached to the <b>Mac OS X 10.8 (Mountain Lion)</b> operating system was simply always in number mode. I use the number pad to navigate around my code and it simply would no longer work. I was <b>frustrating</b> myself trying to use the keyboard. I would edit code and constantly being inserting 2's, 4's, 6's and 8's. What a mess. Countless searches trying to find a solution turned up many people who shared my problem but NO solutions. I started to contemplate, was it time for a new hammer? I think not!<br />
<br />
As luck would have it I found an answer!<br />
<br />
KeyRemap4MacBook <br />
http://pqrs.org/macosx/keyremap4macbook/<br />
<br />
We despite the title it worked for my Mac Mini. In no time at all this <b>genius little utility fixed the issue for me by making the NumLock key work</b>. I was so happy I donated to his cause so he could have a couple beers on me. <br />
<br />
If you decide to use the utility to solve this particular problem I can save you some time looking through the hundreds of settings available with this utility. Once you have it installed. Go to System Preferences -> Other -> KeyRemap4MacBook then choose the section labeled "For PC Users" and you'll see a few different options. The one you want is:<br />
<br />
"Use clear key to toggle "Keypad as Arrow (PC Style Home/End/PgUp/PgDn)"<br />
<br />
In addition to that setting there are a few others under this same section that will likely help you out if you're like me and spend a majority of your day using a Windows OS.<br />
<br />
As always I hope this helps someone with the same issue I was having.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-23839197015207469282012-08-07T10:56:00.001-05:002012-08-07T10:56:29.030-05:00MySQL where to start performance tuningRecently I needed to setup an instance of MySQL on CentOS and I found myself once again wonder where to start tweaking to get initial performance of the server beyond defaults. I'm a firm believer that early optimization can lead to problems but I figured there must be some basic common sense things to do with MySQL that would tune it to the environment where it lives. My initial search turned up this page:<br/>
<br/>
<a href="http://library.linode.com/databases/mysql/centos-5">http://library.linode.com/databases/mysql/centos-5</a><br/>
<br/>
I often start with documentation on the linode.com site since I use there VPS services. Rather then just blindly make the changes recommended for a "low" memory environment I decided to do a bit more reading in the MySQL documentation. I was trying to discover what (if any) difference there was between "key_buffer" (shown on this linode page) and "key_buffer_size" (as outlined in the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld-option-tables.html">MySQL documentation</a>) I never did find an adequate explanation although one post I found suggested that key_buffer_size was depreciated. (apparently they both will work) In any event, I didn't dig any further because in digging around I found a script that seems to be quite helpful with my original quest to tune MySQL to my server environment.<br/>
<br/>
You can locate the page here:<br/>
<br/>
<a href="http://www.day32.com/MySQL/">http://www.day32.com/MySQL/</a><br/>
<br/>
There are several scripts on this page that may be useful for future stuff but the script <a href="http://www.day32.com/MySQL/tuning-primer.sh">MySQL Performance Tuning Primer Script</a> located at the top of the page is the one I started with. I downloaded it using:<br/>
<br/>
wget http://www.day32.com/MySQL/tuning-primer.sh<br/>
<br/>
I reviewed the script (just stating the obvious and if you don't know why then you shouldn't ever download anything) before marking it as execute and running it. This script ran without any problems on CentOS. It dumps a bunch of recommendations to the console and upon the initial review it the recommendations appear to be solid.<br/>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpDhFTvExLtkcMfA_YFW3IHPP8m2SnplNhIJKBlT8ZMFu0w_PmP_Ou2NLeuv2Wq8VyvKpYKOcMZk7YQbLIMlb0Kml9A1d7xa40f1132YGPmVwF1aiZrIXFpx2wkF01VY1u1eAHl0n2S_4/s1600/msql1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpDhFTvExLtkcMfA_YFW3IHPP8m2SnplNhIJKBlT8ZMFu0w_PmP_Ou2NLeuv2Wq8VyvKpYKOcMZk7YQbLIMlb0Kml9A1d7xa40f1132YGPmVwF1aiZrIXFpx2wkF01VY1u1eAHl0n2S_4/s320/msql1.jpg" width="320" /></a></div><br/>
<br/>
Of course, I didn't stop there. I wanted to run the script on a VPS (linode.com) where I have another instance of MySQL. This server is setup with Ubuntu 10.04 (Lucid) and unfortunately the script did not run immediately. I received a nice error message from the script:<br/>
<br/>
"Error: Command line calculator 'bc' not found!" <br/>
<br/>
The script has a dependency on BC, a free command line calculator. I installed this with:<br/>
<br/>
sudo apt-get install bc<br/>
<br/>
to provide the necessary dependency and this got things going on Ubuntu for me.<br/>
<br/>
Overall the script will be most useful if you have been running your MySQL instance for a while and have some useful data for it to review.<br/>
<br/>
<b>REFERENCES</b><br/>
<a href="http://www.blogger.com/Matthew%20Montgomery">MySQL Scripts by Matthew Montgomery</a><br/>
<a href="http://lists.mysql.com/mysql/167048">Reference to key_buffer_size being deprecated</a><br/>
<a href="http://dev.mysql.com/doc/refman/5.1/en/index.html">MySQL documentation</a><br/>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-2605290618681084362012-05-25T16:32:00.002-05:002012-05-25T16:34:22.486-05:00Setting LDAP parameter to invalid value caused strange errorI was working on a web based application using C# and ran into a bit of a strange error. I'm using an LDAP to try and set the option "Require user to change password at next login" for an Active Directory account. A small typo resulted in a strange error that lead me to waste some time today. Thought I'd share to hopefully prevent others from having the same issue. The error I received was:<br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)</span><br />
<br />
The snippet of relevant code:<br />
<br />
<br />
<pre class="brush: ruby">
public bool RequireUserToChangePwd(bool force)
{
bool success = false;
try
{
DirectoryEntry user = loadSpecificEntry();
if (user != null)
{
if (force)
user.Properties["pwdLastSet"].Value = 0;
else
user.Properties["pwdLastSet"].Value = 1;
user.CommitChanges();
user.Close();
success = true;
}
}
catch (Exception ex)
{
tossFormattedExceptionMessage("Unhandled error requiring force password change",ex);
}
return success;
}
</pre>
<br />
<br />
The exception was happening on the call to CommitChanges(); It was happening because the "pwdLastSet" property only has two valid values 0 and -1 so when I called this method with force = false the exception was being tossed. Needless to say the error message "A device attached to the system is not functioning" is a bit misleading. Changing the code to supply the proper value of -1 resolved the issue. I imagine this error could potentially show up in when using invalid values for other properties being modified using LDAP. If you're reading this, hopefully I've saved you some time.<br />
<br />
<span style="font-size: large;">References</span>
<br />
<a href="https://groups.google.com/forum/?fromgroups#!topic/microsoft.public.adsi.general/qUfqhn0qb6M">https://groups.google.com/forum/?fromgroups#!topic/microsoft.public.adsi.general/qUfqhn0qb6M</a>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-19988650140821541562011-03-31T22:55:00.000-05:002011-03-31T22:55:51.288-05:00Ruby Gems 1.6.0 and Rails 2.x - uninitialized constant ActiveSupport::Dependencies::MutexIf you're like me and you have some older Rails 2.x applications or even prefer to stay on Rails 2.x you might have run across this problem. I was trying to deploy a Rails 2.3.5 application on one of my Linode virtual servers and received the following error.<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">uninitialized constant ActiveSupport::Dependencies::Mutex</div><br />
Fortunately there are a couple places to find information on this error. Unfortunately most of the suggested fixes were not working for me. The suggested fixes involved requiring "thread" in just about every place imaginable but that did not resolve the issue for me. I was running Rails 2.3.5 and RubyGems was 1.6.2 which apparently just wasn't going to work. I choose to upgrade to Rails 2.3.11 because of this post that <a href="http://www.pixellatedvisions.com/2011/03/13/fixing-mysql-and-rubygem-errors-on-a-new-rails-2-3-8-install">suggested it was going to fix my problem</a>. Moving to Rails 2.3.11 was the only way to resolve the issue for my setup. If you're having the same problem you'll want to try the steps listed in the "Fixing Rails" heading on that post.<br />
<br />
<b>References</b><br />
<a href="http://www.ruby-forum.com/topic/1193619">Ruby Gems 1.6.0 release notes </a><br />
<a href="http://www.pixellatedvisions.com/2011/03/13/fixing-mysql-and-rubygem-errors-on-a-new-rails-2-3-8-install">Fixing Rails - Suggestion that fixed this problem</a>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-80167707952719120142011-02-07T16:36:00.002-06:002011-02-18T10:25:46.973-06:00Grep for WindowsI was using a new virtual machine I setup not long ago and was missing a good way to search for a file by it's content. Normally I would use a command line version of <a href="http://en.wikipedia.org/wiki/Grep">grep</a> but unfortunately this virtual machine was a Windows 2008 box and not quite setup like I normally would. Since I was looking for a grep utility quick I decided try Google for the answer. Turns out I stumbled across a GUI Grep utility for Windows and so far I'm loving it. You can find it here. <a href="http://www.wingrep.com/index.htm">http://www.wingrep.com/index.htm</a>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com1tag:blogger.com,1999:blog-5972075215139159016.post-52819923593706494122010-11-30T20:00:00.000-06:002010-11-30T20:00:27.839-06:00Pay attention to tiny annoying little files that don't exist.I'm not sure if this will help anyone or not. However, it's an interesting story so I thought I'd share. <br />
I've been working on project XYZ.com <i><span style="font-size: x-small;">(named changed to protect the innocent)</span></i> trying to stablize it for the owners because the morons who built it were ... well... morons. <i><span style="font-size: x-small;">(You can only work a project so long before you come to these type conclusions. I am probably being a bit harsh.)</span></i> In any event, there is a couple parts of the application that makes heavy use of the session to manage dynamic search results.<i> <span style="font-size: x-small;">(remember that I'm coming back to it.)</span></i> This application current supports three out of the four major browsers <i><span style="font-size: x-small;">(at least by my standards)</span></i> IE, FF, and Safari and one browser (Chrome) had been turned off almost a year ago because it was "acting too flaky" and "not rendering images or pages properly" according to the owners. As I've come to find out, actually all of the browsers behave a little flaky now and then but not as bad a Chrome which in some features of the app just refused to work.<br />
<br />
So today I was trying to address another major flaw in the site. The whole site is HTTPS <i><span style="font-size: x-small;">(for no good reason except that Firefox "seemed to have issues with images in http")</span></i> so I'm trying to at least make it somewhat intelligent on which protocol is used when. Turns out this was no small feat with these monster size controllers that do everything. <span style="font-size: x-small;"> <i>(Did I mention this was a .Net MVC 1.0 application?)</i></span><br />
<br />
So I decided that I should turn on Chrome to do some testing and I immediately got frustrated with the crapy results. In fact, I was about to give up totally and disable it again when a bit of blind luck happened. I was using the Visual Studio Debugger and I had Fiddler open <i><span style="font-size: x-small;">(as I often do now)</span></i> I actually noticed that Chrome was being freaky agressive about asking for the favicon.ico file. I mean like freaky, every 3 or four requests it would ask again <i><span style="font-size: x-small;">(like if that file is not there the first time it's going to somehow magically appear seconds later, and who really cares anyway?)</span></i> and on top of it it was doing that <i><span style="font-size: x-small;">(as it should)</span></i> in a separate request. The only problem was, the file does not exist on this site. It never has. So the MVC framework (I think) or who the hell knows what because I haven't dug any deeper yet, was doing a redirect to "Index" which Chrome followed the redirect <i><span style="font-size: x-small;">(on the file which is technically only suppose to be in one location)</span></i> which caused app to serve up the home page. This is where things started to get ugly. This caused caused the session data <i><span style="font-size: x-small;">(did you remember? it used heavily in a couple key places)</span></i> to be wiped totally clean. So when you try to create that user account or store your search results they vanish before your eyes! Bingo! Flaky results at random intervals!<br />
<br />
<span style="font-size: large;">Moral of the story... You must pay attention to tiny annoying little files that don't exist.</span><br />
<br />
I love Fiddler... I love the debugger ... the end.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-90706741405865788062010-11-25T12:31:00.000-06:002010-11-25T12:31:47.633-06:00Capistrano deploy from Windows failing in transfer.rbI recently ran into an issue with deploying from Windows using Capistrano. The project I was using had been setup as a multi-staged deployment with Capistrano and had been working quite nicely deploying to my staging and production environments. Unfortunately, the project sat for a few months and collected some dust while I was busy earning a living. When I finally got around to working on it again I discovered that capistrano was now failing on the deploy command. The error I was getting looked liked this:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnyYbHNxI9y4-S0aHvDl7F6SJDLjH78EJarEOW_v7NoTT1Sq9fUoj4RBxRA4aK1UXPf5HdlqQi6bIQX0mKSKfUIiT5D4iwIt-le9MPfCQPhhfAUvI7CEN7G_vAvo2zIogPx1-f6w_NT3w/s1600/capfail.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="191" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnyYbHNxI9y4-S0aHvDl7F6SJDLjH78EJarEOW_v7NoTT1Sq9fUoj4RBxRA4aK1UXPf5HdlqQi6bIQX0mKSKfUIiT5D4iwIt-le9MPfCQPhhfAUvI7CEN7G_vAvo2zIogPx1-f6w_NT3w/s400/capfail.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">capistrano/transfer.rb:156</td><td class="tr-caption" style="text-align: center;"><br />
</td></tr>
</tbody></table><b><span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:156:in `[]=': undefined method `[]=' fo<br />
r nil:NilClass (NoMethodError)<br />
from C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:207:in `handle_error'<br />
from C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:48:in `process!'<br />
from C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:43:in `loop'</span></b><br />
<b><span style="font-family: "Courier New",Courier,monospace; font-size: x-small;"> </span></b><br />
Although not completely obvious, the clue to the failure is in the location of the failure. Failed in capistrano in transfer.rb and it's failing there because tar didn't execute and therefore didn't create the archive file to transfer to the server.<br />
<br />
<br />
I truly love that when capistrano runs it identifies each command it's going to execute so you can see what it's trying to do. I'm sure it would have been a much longer trouble shooting session if I had to dig through source to figure that out instead of it just telling me. When I received that error, knowing that it was working fine a few months ago, it was obvious to me that I had made some changes to my environment that introduced the problem. As it turns out, I was missing unix utilities in my PATH and in particular I was missing tar. Once I added a path to my Cygwin/bin folder to my PATH everything started working again. <br />
<br />
Hope this helps someone avoid a few minutes of trouble shooting.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-50248082590004015662010-11-06T11:17:00.000-05:002010-11-06T11:17:03.138-05:00Upgrade Windows 2008 Standard to 2008 EnterpriseI've recently needed to upgrade Windows Server 2008 Standard Edition to Server 2008 Enterprise Edition to take advantage of additional memory on the server. I'm running the 32 bit version OS not the 64 bit. The 32 bit of Windows 2008 Standard only supports up to 4 GB of memory but the Enterprise Edition will handle up to 64 GB. <a href="http://msdn.microsoft.com/en-us/library/aa366778%28VS.85%29.aspx#physical_memory_limits_windows_server_2008_r2">(memory limits MSDN)</a> All the documentation I could find (blog posts, MSDN, <a href="http://technet.microsoft.com/en-us/library/dd979563%28WS.10%29.aspx">TechEd</a>, etc) suggested that the upgrade could be done in place but that there were some considerations depending on certain roles the server plays. Fortunately my server didn't fall into any of those special circumstances. However, when I ran the install and selected Enterprise Edition I received the message:<br />
<br />
"Upgrade has been disabled.<br />
The upgrade can not be started. To upgrade, cancel the installation and then choose to upgrade to a version of Windows that is more recent than the version you are currently running."<br />
<br />
and the button I would use to perform the upgrade in place was disabled. Naturally I was a bit confused since my current installation was Windows 2008 Standard Edition SP2 and I'm trying to upgrade from Enterprise Edition 2008 SP2.<br />
<br />
After a bit more digging on Google I found <a href="http://www.networksteve.com/forum/topic.php/Upgrade_from_Server_2008_Standard_%28SP2%29_to_Server_2008_Enterpris/?TopicId=14859&Posts=2">this blog post</a> (Thanks Network Steve) that suggested that maybe SP2 was the issue causing the button to be disabled. So, not feeling very good about this approach, but with no other real options, I decided to go for it. After making all the necessary backups I uninstalled the service pack. Yes, the OS still booted and seemed to work and fortunately for me this actually solved the issue with the installer. I was able to do the upgrade in place from Standard to Enterprise Edition.<br />
<br />
Hope this helps someone else!Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com3tag:blogger.com,1999:blog-5972075215139159016.post-74347277623683212522010-10-08T23:08:00.011-05:002010-10-10T17:02:21.269-05:00Install MySQL 5.1 for Development and Enable remote connections<span style="font-size: small;"><b><span style="font-family: Verdana,sans-serif;">Overview</span></b></span><br />
<span style="font-size: small;"><b><span style="font-family: Verdana,sans-serif;"> </span></b></span><br />
<span class="Apple-style-span" style="font-family: Verdana,sans-serif;">I keep getting tripped up by this each time I install MySQL so I thought I would post this as a reminder to myself with the hopes it may help someone else out too. I have probably setup and installed MySQL on Ubuntu at least 5 or 6 times in the past 2 years. Each time I think wow how easy and each time I get stuck when it comes to remotely accessing the MySQL instance. In my production environment this hasn't hit me because I have MySQL on the same VM as my application and only allow local connections. However, in my development environment I don't want that restriction. So naturally, when faced with an information problem, I use a search engine and try looking for this information. Inevitably I either find the posts that show how to change the configuration of the service OR I find the posts showing how to adjust the user privileges but I never seem to find a combination post. Here's my combo post.</span><br />
<br />
<div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><b>Installing MySQL on Ubuntu</b></span></div><br />
<pre class="literal-block" style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">sudo apt-get update</span></pre><pre class="literal-block" style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">sudo apt-get upgrade --show-upgraded
</span></pre><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><br />
</span></div><pre class="literal-block" style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">sudo apt-get install mysql-server</span></pre><pre class="literal-block" style="font-family: "Courier New",Courier,monospace;"> </pre><pre class="literal-block"></pre><pre class="literal-block" style="font-family: Verdana,sans-serif;">Other things you might want to consider I have found useful in <a href="http://library.linode.com/databases/mysql/ubuntu-9.10-karmic">this Linode.com post</a> on setting up MySQL on a VM from their service. (which I have and think it's awesome)</pre><br />
<div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><b></b></span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><b>Enabling some security</b></span></div><br />
<pre class="literal-block" style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">sudo mysql_secure_installation </span></pre><pre class="literal-block"> </pre><pre class="literal-block" style="font-family: Verdana,sans-serif;"><span style="font-size: small;">When running this utility you will be given an option to allow root "remote" access which I would think you should ONLY do in a secure environment if you know what your doing. Have you heard that before?</span> You probably also heard the speech about setting a good root password, so I'll spare that one for you and just say I would if I were you.</pre><br />
<div style="font-family: Verdana,sans-serif;"><b>Allow remote connections </b></div><div style="font-family: Verdana,sans-serif;">Now to make sure that your user connections can actually connect you need to actually grant the users privileges. That looks something like this in my case.</div><br />
<span style="font-size: small;"><span style="font-family: 'Courier New',Courier,monospace;">grant all privileges on *.* to 'devuser'@'192.168.1.%' identified by "CHANGEME";</span></span><br />
<br />
<span style="font-family: Verdana,sans-serif;">If you don't understand what this does you should probably due some reading.The % character can be used in any portion of the address or even as the user name. Refer to the <a href="http://mirror.mirimar.net/mysql/doc/refman/5.1/en/connection-access.html">MySQL 5.1 Access Control - Connection Verification section</a> of the docs for MySQL.</span><span style="font-family: Verdana,sans-serif;"> <i><span style="font-size: x-small;">(If you don't understand why I used 192.168.1.% then I can't help you.</span>)</i></span><br />
<span style="font-family: Verdana,sans-serif;"><i><br />
</i></span><br />
<span style="font-family: Verdana,sans-serif;">This should get you up and running and connecting remotely.</span><br />
<span style="font-family: Verdana,sans-serif;"><br />
</span><br />
<b><span style="font-family: Verdana,sans-serif;">References </span></b><br />
<a href="http://library.linode.com/databases/mysql/ubuntu-9.10-karmic">Linode Reference Library</a><br />
<a href="http://mirror.mirimar.net/mysql/doc/refman/5.1/en/connection-access.html">MySQL 5.1 Access Control - Connection Verification</a><br />
<a href="http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html">A useful post with some firewall notes too</a>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-70534691824777826282010-09-30T08:43:00.000-05:002010-09-30T08:43:54.184-05:00File level encryption prevented rendering of image file on IIS 7.I was recently deploying an application to a staging environment. The application had been tested on several development workstations and everything appeared to be fine. This of course is the "typical" developer story and it is why staging environments are so crucial to successful deployments. Once the application was in staging I proceeded to make a few cursory checks of the new things that would be tested by the people doing QA. That's when I noticed that the new buttons on a page were not rendering. As it turns out, the images for the buttons were actually set for file level encryption. Once I turned off the encryption the buttons were rendered in the view. So if you have magically missing buttons on your web pages under IIS 7 have a look at the attributes for the file. Another clue to the issue came when I looked at the folder containing the images files. The two buttons that were not rendering both were listed (I use the details list quite often) in green color font which made them stand out in the list against the rest being black.<br />
<br />
If you need to remove file level encryption all you have to do (assuming you have permissions to modify the file) is right click on the file then choose properties. When the dialog is displayed clicked the Advance button and then un-check the option "Compress contents to save disk space".Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-16240873483726458132010-09-16T00:20:00.000-05:002010-09-16T00:20:07.798-05:00VMWare increase disk size not showing in OSI recently purchased a new Dell T410 Server so that I can run VMWare Server 2.0 and get a handle on the configuration nightmare that is my virtual machine configurations. So far I am loving the new server and VMWare Server 2.0. I have been using Microsoft Virtual Server and Parallels Workstation 2.2 to manage all the VM's where I do a majority of my consulting work. Using VM's allows me to partition my work effectively. Unfortunately, it's killing my laptop and desktop to keep managing these things this way. Enter stage left, my new Server.<br />
<br />
So as usual, I decided to setup some "template" VM's to make it easier to get started on new things. Unfortunately, I made my Windows 2008 Server VM with the default VMWare Server hard disk size of 16GB which I almost immediately had to change. That's when I ran into a bit of an issue. In fact, it was my issue and not VMWare Server. When you increase the size of your disk(s) on a VMWare virtual machine it works like magic. You can do this from inside the VMWare Server Infrastructure Web Access web interface as long as your virtual machine is powered off. Simply select your virtual machine from the inventory list on the left and then click on the tiny drop down arrow on the disk in the center view. This will produce a small menu of choices one of which is Edit. Note: You will see your capacity and if (and only if) your virtual machine is powered off, you will be able to change the disk capacity. Once you change the size it is reflected in the web interface immediately. I thought to myself at the time "that was easy". When I powered up the virtual instance and checked the size of the disk it still reflected the old size of 16GB. Then I thought, I wonder what's wrong? I am not entirely sure why I thought that the OS would recognize the newly available un-partitioned space. Naturally, it doesn't. You basically have to go into your disk management software and tell it to use the space. On Windows 2008 you can go into Settings --> Control Panel --> Administrative Tools and then choose "Share and Storage Management". Once you're there you can select the "Volumes" tab and then select your drive from the list. At this point you have one of two options. You can Extend your existing drive or you can Provision Storage. I choose to extend my existing C: drive.<br />
<br />
I hope this helps someone avoid a few minutes of confusion.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-73134005758043810492010-08-17T12:29:00.000-05:002010-08-17T12:29:11.752-05:00Testing SharePoint outgoing email with PapercutI found a very cool utility this week that has saved me some precious time. I'm working on a SharePoint 2007 project running on Windows 2003 Server and I needed to adjust a feature of the application to send some confirmation emails. My first inclination was to setup an SMTP server for testing. As usual, I started with a search on Google and fortunately for me I accidentally stumbled across <a href="http://papercut.codeplex.com/">Papercut</a> as an alternative to doing my email testing. No need to setup an SMTP server. No need to constantly jump into my email and check for the confirmation. For those times when you do need to see the email in an email client (when you need to check HTML rendering) you can forward captured emails.Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0tag:blogger.com,1999:blog-5972075215139159016.post-59115277410984239932010-08-11T06:22:00.001-05:002010-08-11T06:24:35.757-05:00Fiddle me this Batman!I've been working in Internet Explorer land lately. This is primarily due to contract work on a SharePoint project where the client really only cares about IE working well. (at least for now) So for all of you Firefox users out there who (like me) are use to have <a href="http://getfirebug.com/">Firebug</a> at your finger tips it can be a little mind numbing to be without a way to see the HTTP traffic in all it's glory. That's where <a href="http://www.fiddler2.com/fiddler2/">Fiddler</a> comes in to play! In fact, it might just replace Firebug altogether for me. I like the stand alone process approach. So far Fiddler is footing the bill. If you're looking for a good Web debugging Proxy that is free then you should give it a try.<br />
<br />
<b><span style="font-size: large;">Reference</span></b><br />
<a href="http://www.fiddler2.com/fiddler2/">http://www.fiddler2.com/fiddler2/</a><br />
<a href="http://getfirebug.com/">http://getfirebug.com/</a>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com1tag:blogger.com,1999:blog-5972075215139159016.post-57005601344147163802010-08-09T22:04:00.002-05:002010-08-09T22:11:59.975-05:00SQL Server 2005, self signed SSL certificates, issue from SelfSSL<div style="font-family: Verdana,sans-serif;">I was working on a project today and ran across a painful delay. I have Windows 2003 Server with Microsoft SharePoint 2007, SQL Server 2005, and IIS 6.0. I was finally to the point (actually long past it) where I should have setup SSL for some testing. Naturally I hit the search engines to find the easiest way to setup a self signed certificate under IIS. That is when I ran across this <a href="http://codeforeternity.com/blogs/technology/archive/2008/02/15/creating-self-signed-ssl-certificates-on-iis-6-0-and-windows-server-2003.aspx">post on SelfSSL</a> which is part of the IIS 6.0 Resource Kit Tools. Unfortunately, that's where my trouble began. I followed the instructions installing just SelfSSL and the log analyzer tool. Then I proceeded to use the SelfSSL to create certificates for my SharePoint site(s). Installing the certificates using the tool was painless. No errors, it just went smoothly. I have form based authentication and I was able to connect via SSL but something weird was happening with AD site and it was preventing me from actually working. Since I couldn't afford to be delayed on some of this work I decided to revert the system back to non-SSL state and keep working figuring that I would get back to this when I had more time to spare on solving whatever issue was keeping things from truly working. That's when all the fun began. I removed the certificates using IIS manager and then restarted the server thinking I'll get a clean start to ensure it would be working again. I was indeed wrong. When the system came back up I wasn't able to connect to the SQL Server instance.</div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;">The first indication came from my SharePoint AD site with the message</div><div style="font-family: "Courier New",Courier,monospace; text-align: center;">"Cannot connect to the configuration database."</div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;">I received a slightly different (and much longer) message from try to connect using SQL Server Management Studio. Here's the important parts.</div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">"</span><span style="font-size: small;">error occurred during the pre-login handshake ...</span><span style="font-size: small;"> No process is on the other end of pipe"</span></div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">Naturally I was confused as to why uninstalling SSL certificates would affect my SQL Server connection but it did. As it turns out, SQL Server uses a certificate to encrypt the login information even if your not going to use a secure connection. In the absences of an assigned certificate SQL server will create a self signed server certificate to use. Unfortunately, if there are certificates available then SQL Server will "apparently" grab a certificate to use providing it meets certain criteria which apparently my discarded SelfSSL certificates did. After reading numerous posts to understand what was happening I was able to clean it up on my system. See below for some of the more useful posts I found on this topic. </span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><b><span style="font-size: small;"><span style="font-size: large;">What must I do to fix this?</span></span></b></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">Make sure you have the same problem. Apparently there are a few ways to get these same error messages from SQL Server so unless you have recently installed or un-installed self signed certificates on IIS where IIS is on the same box as SQL Server 2005 you might find this fix won't do anything for you.</span></span></span></div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">Even though I used IIS Manager to remove the certificates there were still around on the system and SQL Sever was still finding them. So, I basically did the following:</span></span></span></div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">1. Click the Windows Start button and ran MMC to get the Microsoft Management Console.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">2. Choose File --> Add / Remove Snap-in... from the main menu.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">3. Click the "Add" button on the Standalone tab.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">4. Choose "Certificates" and click the Add button.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">5. Choose "Computer account" and click the Next button.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">6. Choose "Local computer" radio button and clicked Finish.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">7. Click the "Close" and "OK" buttons on the previous two dialogs.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">8. In the list I navigated to "Certificates (local computer) -> Personal -> Certificates"</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">NOTE: Your self signed certificates might be some place else but they're most likely here.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">CAUTION: Be sure you SELECT the right certificates in the next step!!!</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"> </span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">9. Click on certificates to select them and use the option to delete. BE SURE TO get the self signed ones. There could be others here!!!</span></span></span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"><br />
</span></span></span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">After I did this my SQL Server 2005 instance was all good again. I was able to connect. </span></span></span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"><br />
</span></span></span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;">Hopefully find this post helpful and it save you some of the 2 hours I lost on this little expedition.</span></span></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: large;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"><b><span style="font-size: large;">References</span></b></span></div><a href="http://www.learnsqlserver.com/Blogs/SqlServerBlog/2007/04/how-to-force-sql-server-2005-to-use.html">www.learnsqlserver.com - Force SQL Server to use particular certificate (SSL)</a><br />
<a href="http://social.msdn.microsoft.com/forums/en-US/sqlsetupandupgrade/thread/ba7e46ec-1e6f-4d63-b810-ec0adb618cd3/">social.msdn.microsoft.com/forums - post on SSL certificate</a><br />
<a href="http://www.eggheadcafe.com/software/aspnet/34857711/error-occurred-during-the-prelogin-handshake--microsoft-sql-server-error-10054.aspx">www.eggheadcafe.com - error on pre-login handshake</a><br />
<a href="http://blogs.msdn.com/b/sql_protocols/archive/2006/07/26/678596.aspx">blogs.msdn.com - no process is on the other end of pipe - bad certificate</a>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com2tag:blogger.com,1999:blog-5972075215139159016.post-10655461517580136232010-07-16T09:30:00.000-05:002010-07-16T09:30:25.431-05:00RMagicK, SQLite3, MySQL - Gem setup on Ubuntu 9.10 KarmicRecently I needed to setup what I think are common gems, for many Ruby on Rails, users on the Ubuntu 9.10 VM I use for development. I thought I'd document these in one place since I had to go to several places to find the information I needed.<br />
<br />
<b><span style="font-size: small;">MySQL</span></b><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install libmysqlclient-dev</span><span style="font-family: "Courier New",Courier,monospace;"> </span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo gem install mysql --no-ri --no-rdoc</span><br />
<br />
<b>SQLite3</b><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install libsqlite3-dev</span><span style="font-family: "Courier New",Courier,monospace;"> </span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo gem install sqlite3-ruby --no-ri --no-rdoc</span><br />
<br />
<br />
<b>RMagicK</b><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install imagemagick</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install libmagick9-dev</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">sudo gem install rmagick --no-ri --no-rdoc </span><br />
<br />
<span style="font-size: large;">References</span><br />
<a href="http://www.jsiegel.com/2008/10/fixed-ubuntu-sudo-gem-install-sqlite3.html">http://www.jsiegel.com</a><br />
<a href="http://superuser.com/questions/96440/how-to-install-the-mysql-ruby-gem-on-ubuntu-9-10">http://superuser.com</a><br />
<a href="http://dev.honewatson.com/install-rmagick-gem-on-ubuntu-feisty-3-steps/">http://dev.honewatson.com</a>Billhttp://www.blogger.com/profile/13172775128757558487noreply@blogger.com0