Debugging Ruby Selenium Webdriver RSpec tests on JetBrains IntelliJ on a Java Project

So, you already have a Java project on IntelliJ and want to run and debug ruby selenium tests.

Specify Ruby SDK in IntelliJ for the project.
1. Navigate to File -> Project Structure -> SDKs -> Project.
2. Select SDK, in my case Ruby-2.0.0.
3. Click Apply and OK

Create a Ruby Module (This is specific to my scenario, so your module settings may be different)
1. Navigate to File -> Project Structure -> Modules
2. Remove existing Java module.
3. Create New Module based on Ruby Gem.
4. Select project’s root level as the module, rest of the fields autofill.
5. Remove Ruby Gem facet from module.
6. Click Apply and OK

Create RSpec Configuration
1. Edit Configuration -> Add New Configuration -> Rspec
2. Select spec and SDK.
3. Click Apply and OK
4. Run/debug

Troubleshooting
If you get the Teamcity Formatter error below error in Intellij when executing the RSpec script, try the following.
1. Execute the Create a Ruby Module step
2. Remove the existing RSpec configuration
3. Re-create the RSpec Configuration

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /usr/bin/rspec spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter
Testing started at 9:47 AM ...
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `block in setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `each'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration_options.rb:25:in `configure'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:21:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'

Process finished with exit code 1

Bootstrap 3.1.1 and Typeahead.js 0.10.2

Additional CSS I needed per discussion on https://github.com/twitter/typeahead.js/issues/378 as of today, using the latest available packages on bower.

.twitter-typeahead {
width: 100%;
position: relative;
}
.twitter-typeahead .tt-input,
.twitter-typeahead .tt-hint {
margin: 0;
width: 100%;
color: #555555;
vertical-align: middle;
background-color: #ffffff;
border: 1px solid #cccccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}
.has-warning .twitter-typeahead .tt-input,
.has-warning .twitter-typeahead .tt-hint {
border-color: #c09853;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.has-error .twitter-typeahead .tt-input,
.has-error .twitter-typeahead .tt-hint {
border-color: #b94a48;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.has-success .twitter-typeahead .tt-input,
.has-success .twitter-typeahead .tt-hint {
border-color: #468847;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.twitter-typeahead .tt-input:focus,
.twitter-typeahead .tt-hint:focus {
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
}
.has-warning .twitter-typeahead .tt-input:focus,
.has-warning .twitter-typeahead .tt-hint:focus {
border-color: #a47e3c;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
}
.has-error .twitter-typeahead .tt-input:focus,
.has-error .twitter-typeahead .tt-hint:focus {
border-color: #953b39;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
}
.has-success .twitter-typeahead .tt-input:focus,
.has-success .twitter-typeahead .tt-hint:focus {
border-color: #356635;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
}
.twitter-typeahead .tt-hint {
color: #a1a1a1;
z-index: 1;
border: 1px solid transparent;
}
.twitter-typeahead .tt-input {
z-index: 2;
}
.twitter-typeahead .tt-input,
.twitter-typeahead .tt-hint {
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
}
.twitter-typeahead .input-sm.tt-input,
.twitter-typeahead .hint-sm.tt-hint {
border-radius: 3px;
}
.twitter-typeahead .input-lg.tt-input,
.twitter-typeahead .hint-lg.tt-hint {
border-radius: 6px;
}
.input-group .twitter-typeahead:first-child .tt-input,
.input-group .twitter-typeahead:first-child .tt-hint {
border-radius: 4px 0 0 4px !important;
}
.input-group .twitter-typeahead:last-child .tt-input,
.input-group .twitter-typeahead:last-child .tt-hint {
border-radius: 0 4px 4px 0 !important;
}
.input-group.input-group-sm .twitter-typeahead:first-child .tt-input,
.input-group.input-group-sm .twitter-typeahead:first-child .tt-hint {
border-radius: 3px 0 0 3px !important;
}
.input-group.input-group-sm .twitter-typeahead:last-child .tt-input,
.input-group.input-group-sm .twitter-typeahead:last-child .tt-hint {
border-radius: 0 3px 3px 0 !important;
}
.input-sm.tt-input,
.hint-sm.tt-hint,
.input-group.input-group-sm .tt-input,
.input-group.input-group-sm .tt-hint {
height: 30px;
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
}
.input-group.input-group-lg .twitter-typeahead:first-child .tt-input,
.input-group.input-group-lg .twitter-typeahead:first-child .tt-hint {
border-radius: 6px 0 0 6px !important;
}
.input-group.input-group-lg .twitter-typeahead:last-child .tt-input,
.input-group.input-group-lg .twitter-typeahead:last-child .tt-hint {
border-radius: 0 6px 6px 0 !important;
}
.input-lg.tt-input,
.hint-lg.tt-hint,
.input-group.input-group-lg .tt-input,
.input-group.input-group-lg .tt-hint {
height: 45px;
padding: 10px 16px;
font-size: 18px;
line-height: 1.33;
}
.tt-dropdown-menu {
width: 100%;
min-width: 160px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
*border-right-width: 2px;
*border-bottom-width: 2px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.tt-suggestion {
display: block;
padding: 3px 20px;
}
.tt-suggestion.tt-cursor {
color: #fff;
background-color: #0081c2;
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=’#ff0088cc’, endColorstr=’#ff0077b3′, GradientType=0);
}
.tt-suggestion.tt-cursor a {
color: #fff;
}
.tt-suggestion p {
margin: 0;
}

.input-group .twitter-typeahead {
display: table-cell !important;
}

 

CAS 3.3.1 to CAS 4.0.0 Upgrade/Migration

CAS 4.0.0 is in the process of being released, and the documentation is not comprehensive. Here are somethings I did to get from CAS 3.3.1 to CAS 4.0.0 in terms of the maven overlay project.  This was mainly to get the fix for CAS-1318.

Overlay pom dependencies

updated cas-server-webapp from 3.3.1 to 4.0.0
added cas-management-webapp 4.0.0
added cas-server-support-generic 4.0.0
added cas-server-support-x509 4.0.0
added cas-server-support-openid 4.0.0
cas-server-support-ldap 4.0.0
removed outdated dependencies from overlay/lib

Files copied over from github https://github.com/Jasig/cas/tree/master/cas-server-webapp

src/main/webapp/WEB-INF/webflow/login/login-webflow.xml
src/main/webapp/WEB-INF/webflow/logout/login-webflow.xml
src/main/webapp/WEB-INF/cas-servlet.xml (too many changes, added my changes after copying over)

Updated files

login-webflow.xml,
uncommented startAuthenticate, changed flow in serviceAuthorizationCheck to transition to startAuthenticate instead.  Note: my project was using x509check, so the commented out code seemed to run the x509check

deployerConfigContext.xml,
added namespace util
modified auditTrailManager bean to point to new class
added healthCheckMonitor bean
added registeredServiceList, modified to fit our services
added monitorsList

xml schema upgrades in overlayed xml files
beans 2 -> beans 3
webflow 1 -> webflow 2

Changed Credentials.class references to Credential.class in custom code in extensions

Relevant Links
http://jasig.github.io/cas/4.0.0/index.html
https://wiki.jasig.org/display/CASUM/Auditing+and+Statistics+Via+Inspektr
https://github.com/UniconLabs/simple-cas-overlay-template
https://github.com/Jasig/cas/blob/master/cas-server-core
https://wiki.jasig.org/display/CASUM/Best+Practice+-+Setting+Up+CAS+Locally+using+the+Maven+WAR+Overlay+Method
https://github.com/leleuj/cas-overlay-demo/blob/master/cas-overlay-server-demo/src/main/webapp/WEB-INF/deployerConfigContext.xml
https://wiki.jasig.org/display/CASUM/Upgrading
https://wiki.jasig.org/display/CASUM/X.509+Certificates
https://github.com/Jasig/cas/blob/master/cas-server-support-x509/src/test/resources/deployerConfigContext.xml
https://github.com/Jasig/cas/blob/master/cas-server-support-x509/src/main/java/org/jasig/cas/adaptors/x509/authentication/handler/support/X509CredentialsAuthenticationHandler.java
http://comments.gmane.org/gmane.comp.java.jasig.cas.user/17466
https://groups.google.com/forum/#!msg/jasig-cas-user/jS2GjedsMd4/o-MGC_Tpn7IJ
https://wiki.jasig.org/display/CASUM/OpenID
https://github.com/leleuj/cas-openid-demo/blob/master/cas-openid-server-demo/src/main/webapp/WEB-INF/cas-servlet.xml
https://groups.google.com/forum/#!msg/jasig-cas-user/jS2GjedsMd4/o-MGC_Tpn7IJ
https://wiki.jasig.org/display/CASUM/Services+Management
http://mmmsoftware.blogspot.com/2008/11/migrating-from-spring-webflow-1-to.html
http://www.jasig.org/upgrading-spring-web-flow-2-cas4
https://github.com/Jasig/cas/wiki/Installation-Guide
https://github.com/Jasig/cas/wiki/CAS4-Documentation-(GitHub-Pages)
https://github.com/Jasig/cas/blob/master/cas-server-webapp/src/main/webapp/WEB-INF/cas-servlet.xml

Each project is different, but I basically just fixed compilation errors and went through the runtime errors.  I didn’t write down the details of each change, but the relevant links should have more information on what the exact changes were.

Good luck!

Google Chrome has crashed, relaunch now? loop

This morning, I was unable to open Google Chrome, and I was stuck in an endless loop of error messages.

The error message read, “Google chrome has crashed, relaunch now?”

I tried deleting/backing up my “%localappdata%/Google/Chrome/User Data” folder and running scans to check for system file corruption with no luck.

My system uses PowerBroker and Enhanced Mitigation Experience Toolkit (EMET), I had to turn off EMET’s configuration for chrome.exe to not call PowerBroker.  In the “caller” column, uncheck the box for chrome.exe

Angular and Browserify

Angular works beautifully with browserify.

I loved what Require JS did for my Marionette project, but I hated the complexity that it added for everyone else.  I had to jump through hoops to write independent modules using Require JS and Marionette JS.

However, browserify is very simple to use and makes independent modules a breeze.  I had to update angular and modify some files to get it working (not checked in yet) but here’s where I plan to check in my prototype forked from another repo.

https://github.com/leedavidr/angular-seed-with-browserify-and-mocha

TinyMCE WYSIWYG editor to PDF and DOCX formats using docx4j

Few steps to get this done after the environment set up.  Basically prep html document, convert to xhtml, add to docx4j document, and generate.

1. (Preparing HTML) Wrap TinyMCE generated HTML in a root element such as div.

2. (Preparing HTML) Replace   with

3. (Preparing HTML) Use regEx to remove height and width attributes from images.  Affected version 2.8.1.  See http://stackoverflow.com/questions/15659076/does-docx4j-convert-xhtml-to-docx-in-memory

4. (Convert to XHTML, Generate) Use XHTMLImporter to convert the html into xhtml.  See http://priasardi.wordpress.com/2012/01/17/convert-html-to-docx-using-docx4j/

* Update – 2.8.1 seems to have trouble with underline and background color.  3.0.0 fixes that.  Both versions have trouble with table border and table caption.  3.0.1 (unreleased) should fix table border.  See http://www.docx4java.org/forums/pdf-output-f27/tabl-caption-and-border-issue-docx4j-3-0-0-t1763.html