Skip navigation

Category Archives: Code

Anything dealing with any kind of source code that I may interact with. Personal projects, bug fixes, workarounds for IDEs, experiments with different frameworks, stuff like that.

I finally got tired of manually typing out all of the characters in the branch names that JIRA was creating for my projects on the M1 Macbook Pro that work has provided for me.

Solution is really simple and I’m kicking myself for not having done it earlier now.

Inside a Zshell terminal, type the following two lines:

echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
source ~/.zshrc

That will enable tab autocomplete and reload the shell so the change takes effect immediately.

Source

Right now, I’m spending some of my free time getting up to speed with Spring Boot. Opinionated frameworks like Spring seem like they’d be a great way to build some quick prototypes for some ideas I’ve got bouncing around my head without having to go through the learning curve a whole new language. I’m already overwhelmed enough with my operations (Linux, networking, security, application servers, etc) and Unity automation for work. And now I’m throwing some AWS into the mix for some side work with a friend.

In my experimentation with Spring Boot, I threw together a quick cat fact web service. Running mvn spring-boot:run and accessing the endpoint at http://localhost:8080/getcatfact returns some super-simple JSON with a random cat fact. Yay kitties!

I created another package, based on the Spring Boot tutorial, designed to be a “Hello, World” example. When I run the application, everything starts up fine, and the Cat Fact endpoint still works. But trying to access the http://localhost:8080/greeting endpoint results in a weird “White Label Error Page”. After some internet searching, I found a decent answer. It seems the error is related to having my packages at the wrong level. Spring will search for and load Boot applications at the initial application’s package level and any sub-packages. Since the net.bencarson.catfact and net.bencarson.hello packages were siblings and didn’t share a parent, it was obvious how to fix my problem. I just needed to create a common parent SpringBootApplication and package and move these existing applications underneath.

I created a new class for net.bencarson.services.MyServicesApplication and moved the catfacts and hello packages under the new net.bencarson.services package, the application was still throwing the White Label error for ‘greeting’.

Proper application hierarchy for Spring Boot
Moved the Spring applications under a parent package and application

The final piece I was missing was that I needed to modify my pom.xml. Inside, I had to change the <start-class> element.

<start-class>net.bencarson.services.MyServicesApplication</start-class>

Now the service starts correctly and both ‘catfacts’ and ‘greeting’ endpoints are accessible!

I encountered a rather obscure IE bug at work this week. After coding up a series of text inputs that enable/disable other radio buttons based on their values, I was dismayed to find out my javascript code wasn’t working in a test environment. I opened Internet Explorer’s F12 Developer Tools to check for any errors.  Unfortunately, the javascript console was useless; nothing was there! No errors, no warnings, nothing. Maybe the console hadn’t recorded an error because it wasn’t open at the time or something, I thought. So I entered another value and found that the javascript was all of a sudden activated! The radio buttons were disabled appropriately and the console was displaying my console.log statements. I was confused. I attempted several other scenarios and variations of input, attempting to lock down what exactly was causing my code to become active. No luck. Fortunately, a colleague of mine had experienced this exact problem before and let me know how to fix it.

Simply remove the console.log lines.

Did you know that console.log does not work in IE unless you have the F12 Dev Tools open?! I sure as hell didn’t. And not only doesn’t work, it breaks other javascript on the page too.

Here is a stackoverflow link that explains the issue in more detail.

So I learned my lesson here, be certain that all javascript debug statements are removed from my code before delivering it.

Hey everybody, kind of an exciting Friday Fix this week. I just submitted my first pull request to an open source project!

First, a little back story. A short while ago I noticed a discussion on Twitter, that spread to github, regarding the name of a particular javascript testing library named Testacular. I believe that it was meant to be a play on the work ‘spectacular’, but it doesn’t take a huge leap to notice that it is one vowel away from the word ‘testicular’. A very valid argument was made that by naming the library in such a way, the project’s author was potentially alienating women and thus undercutting the project’s adoptability. After a semi-heated debate on the project’s github issue tracker, the name of the tool was changed to ‘Karma’. Fast forward to this week, and I’m checking out AngularJS to see what the buzz is about. In checking out the tutorials page, I see a reference and link to the Testacular framework for testing. Knowing that this information is no longer accurate, I click the “Improve this doc” button, modified the references to Testacular, created a pull request, and submitted! As of the writing of this post, the change isn’t on the site. But it does look like it passed testing and will be merged into master at some point.

It is an odd feeling, the level of accomplishment I experienced for having done something so simple. But I guess that’s the nature of open source. So many individuals providing contributions, both large and small, all striving toward a common goal. Everyone wants to improve the project, and anyone can contribute. And now, in a very tiny way, I have helped make the open source community a little bit better.

In working with a Liferay theme recently, I came across a curious bug involving jRuby and CentOS 6. It manifested itself in a rather confusing SASS parser error (the details of which I don’t have anymore). To add to this confusion, I had just switched from using the traditional Ant-based Liferay plugins build to using the Maven liferay-theme-archetype. After spending almost two days trying to figure out what was going wrong with my project, and a lot of help from our NetOps genius, I stumbled across the answer. It was a library problem that existed only on Liferay systems running on CentOS 6.

Fortunately the fix is simple, as it’s just a property override.

Add the following lines to your portal-ext.properties file and bounce your server. Everything should be ready for deployment after that.

scripting.jruby.load.paths=
classpath:/META-INF/jruby.home/lib/ruby/site_ruby/1.8,
classpath:/META-INF/jruby.home/lib/ruby/site_ruby/shared,
classpath:/META-INF/jruby.home/lib/ruby/1.8,
classpath:/gems/chunky_png-1.2.1/lib,
classpath:/gems/compass-0.11.5/lib,
classpath:/gems/fssm-0.2.7/lib,
classpath:/gems/sass-3.1.7/lib

I have spent the past month, attempting to learn my way around the Vaadin framework. Kind of sucks that its Eclipse plug-in is broken, right out of the box. As soon as I installed it, I started getting this error whenever I would launch my IDE.

Could not start XULRunner(version 1.9 or higher required)

Could not start XULRunner(version 1.9 or higher required)

I didn’t, and still don’t, know what the hell XULRunner is. Some library from the Mozilla Developers Network that is currently at version 19.0.2, as of this writing. I think the good folks at Vaadin have abandoned this project; version 1.9 is ancient!

Software rot aside, if you’d like to get rid of this annoying error dialog, you will need to add XULRunner 1.9 to Eclipse’s file path. Here’s how I did it:

  1. Close Eclipse, if it is open
  2. Download XULRunner 1.9.2 from MDN
  3. Install XULRunner by following the instructions here for your operating system.
    1. Be sure to perform the registration step
  4. Open eclipse.ini or your Eclipse shortcut (Windows) and add the following line
    1. -Dorg.eclipse.swt.browser.XULRunnerPath=C:<path><to>xulrunner-1.9.x.x
    2. Here, you can see how I added the line to my Eclipse shortcut link
    3. Adding XULRunner to Eclipse's classpath via shortcut

      Adding XULRunner to Eclipse’s classpath via shortcut

    4. Click ‘OK’ or Save the ‘eclipse.ini’ file
  5. Start Eclipse

Hopefully, at this point, the error will be gone and you can move on to being disappointed by the Vaadin Visual Designer, distraction-free!

I spoke with a recruiter recently, in an attempt to get a feel for the marketability of Ruby skills in my area. He hadn’t heard of any Ruby jobs that were available, but he did have one that called for Groovy on Grails. I have heard of this technology in the past, but didn’t know what it was. After a bit of research it seems to be language and convention-over-configuration framework that runs on the JVM, very similar to Ruby. So this has gotten me wondering if focusing on Ruby would be a mistake. Judging by the number of resources I encountered for each during my brief investigation, I’d say that Groovy doesn’t seem to be anywhere near as popular as Ruby. But if there is a job market for Groovy over Ruby in my area, perhaps I should be looking there instead.

Of course, it would be foolish to change my entire career path on such a minor and anecdotal conversation. If I get out of this missed deadline hole I’ve dug for myself at work, I’ll have to research the topic more seriously. I’m new to both, so I’m thinking that I’ll still lean toward the tech with more free tutorials and resources available. I have such a backlog of codeschool lessons and youtube videos to watch, I don’t think I’ll ever catch up.

In related news, I have decided against developing on Dreamhost’s version of Ruby/Rails. They are extremely old (Rails 3.03, anyone?) and I can’t upgrade them on the shared hosting I have. I’ll look at getting some dedicated Ruby hosting once I have something worth sharing.

Managing my own blog has proved to be a bit too cumbersome for me. I’ve moved both blog.bencarson.net and catsandcode.com to a free wordpress.com blog.

This allows for a free SSL-encrypted connection, plus I figure my site’s backend will be more professionally maintained. I am giving up a lot of freedom in the choice of plugins and themes that I can use, but it is worth it to me. I wasn’t really using anything anyway.

Bonus: they made it super easy to add Google Analytics and Bing Webmaster tracking. Hopefully this will give me a better picture of my visitors than Piwik, because, again, I tend to break shit when I manage my own apps.

Betwixt chores and binges of Borderlands 2, I have been attempting to learn the Ruby programming language. First inspired by Arlo and Eric over at the dev1.tv podcast, and getting my first lessons on the language from codecademy, I’ve been really excited about this language. Primarily because its available for free on my Dreamhost hosting, but also because, combined with the Rails framework, it is so damn simple to build a web app!

I plan on chronicling my experiences here as both a writing exercise as well as creating a cookbook for how I’ve done things. I know that inevitably my dumb ass will forget so this blog will become a valuable resource for me to fall back upon.

I’ve been using command-line git for about a year now. I recently decided to tackle my problem of not knowing how to delete remote branches.

I’ve pushed quite a few branches to some remote repos as a means of transporting projects to/from home/work. As a result there are quite a few useless branches in most of my git projects and it makes working with

git branch -a

more cumbersome than it need be.

In searching for an answer, I actually found out that it is much simpler than I had anticipated. Very similar to what I was already doing to push the branch to the remote repo.

git push origin :<branchname>

That’s it! I just have to add a colon to the remote branch name and git deletes it. Not at all intuitive, but very easy to remember.

%d bloggers like this: