Skip navigation

Category Archives: Software

Posts and entries related to software, libraries, personal projects, bug fixes, code hacks, and workarounds

Inside WordPress’s WYSIWYG editor, if you start a line of text, inside a code tag with a bad character, in my case, the ‘#’ character, the output gets screwed up. Here’s how to fix it.

If anyone looked at my previous post in the first week or two after I posted it, you may have noticed how ugly the post was when it came to the displaying my console’s output. This is because I put the console’s output inside a <code> tag in the WordPress WYSIWYG editor. My intent was to differentiate my blog post text from the output of the console I was using as an example. However, after wrapping the console output in the tag, this is what it looked like:

Code Tag with Incorrect Output

 

I have successfully used the <code> tag in WordPress before to stylize blocks of text, so that’s what I was using here to represent the console output. I didn’t have any trouble in any previous posts, so I wasn’t sure what was different this time. After experimenting a bit, I found that the “#” character that begins each line was the culprit.

code tag with a bad character at the start of each line

 

The fix was simple, I added a space before each line.

Code tag with a bad character, but prepended with spaces

 

This small change gave the output the desired effect.

Code output with corrrect formatting

 

My first open source contribution was just accepted! (Technically, it’s my 2nd contribution, but 1st accepted one!) It was a very minor change, just an update to the user’s profile page on GitLab. Nevertheless, it’s a great feeling, knowing that I can directly improve a great product that I actually use. And I gained a bit of git experience because of this as well.

simple git history

So pretty!

Before I get to what I broke and how I fixed it, I feel the need to defend my self a little first. I like seeing the pretty, flowy lines that are used to track the commits of a project in git. However, the entirety of my git experience has been as a solo developer. As such, I have noticed that every time I merged my feature branch into master, there was no fork reflected in the history (using git log --oneline --decorate --graph). Just a boring-ass straight line. So, purely for aesthetics and not at all efficient or appropriate, I found a way I could get this fork & branch history to show in my logs. I performed my merges with no fast-forwards (git merge --no-ff). This creates an additional commit that mentions the two branches that are merged together, but achieved the effect I was looking for.

So fast-forward (HA!) to today. I followed my usual, ignorant workflow for my submission to the Gitlab project. I forked their repo, cloned locally, branched, made changes, merged with no-ff back to master, and pushed back to origin. From here, I made a merge request for my change to the official GitLab Community Edition project. An admin wrote back that I needed to squash my two commit messages into one. Blerg, I should have known that this practice would eventually bite me! I spent the next few hours unsuccessfully trying to figure this out on my own. After responding to the admin the next day, that I was still working on this, he wrote back with a very helpful link.
So, to squash my pointless commit that --no-ff generated, I had to rebase back to the commit before my first commit. I did this, in interactive mode (git rebase -i <hash of commit>). This opens a text editor with the history of commits between the latest commit and the one that was selected for rebase. In my case, saw my commit, and the autogenerated commit. From the text editor that appears, I can then select what happens with each commit.

# Rebase 408a140..5d5af41 onto 408a140
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

My case was simple. I chose fixup for the superfluous commit and pick for my commit. After saving these changes, the rebase occurred. Everything is fine now, right?
Nope, my dumbass pushed the change to the remote repo already, so I had to overwrite that master branch with my new master branch. A normal git push wouldn’t do it because my local and remote repos were out of sync. Some kind of fast-forward error. So I just forced my changes to overwrite my remote master branch.

git push --force

Ha ha ha Force Push!

git push --force origin master

This force push added my revised master branch to my remote and let me successfully merge my change into the GitLab source! Awesome! Proof positive that you don’t have to be some sort of programming genius to be able to contribute. I don’t even know Ruby!

I’ve been working with a colleague on getting a logo designed for the game company he has recently started. The designer that was hired used a font called “Exo” in the logo. The source file was given to us in a .svg file. And in order to view the logo with the correct font, I first had to install the Exo fontface on my Ubuntu installation.
Here’s how I did it.
First, find the fontface for download somewhere. We ended up finding it on fontsquirrel.com and downloading it in .zip format. Next you will need to create a .fonts folder under your /home/<user-name>/ folder. Inside this .fonts folder, create an ‘exo’ folder to store the actual OTF files. Extract the files from the exo.zip file into /home/<user-name>/.fonts/exo. Finally, run the following command:
sudo fc-cache -f -v

You should see all the font caches on your machine getting refreshed, including the new .fonts folder.
After this, I opened our logo.svg file in Inkscape and the correct font was applied.

Easy as that!

So I’m investigating an Eclipse error I’m getting on my dev laptop and need to search for a bit of text in a file that may be in a hidden file somewhere in my workspace. I don’t trust Eclipse’s global File search (Ctrl + H) to be thorough enough for my needs. I need to do this via the OS.
The “Grep” command is the solution.

It is used like so:


sudo grep ""

For example:

sudo grep "IOException" *.log

Now, my particular issue meant that I didn’t know which folder the file would be located in. To get around that, I used the recursive argument or ‘-r’:

sudo grep -r "IOException" *.log

This loops through all the files in the current directory, as well as sub-directories of the current directory.
At least that’s how I understand it to work. Feel free to correct me if that’s not the case.

I am not sure how long Github has offered their Pages service, but I only recently discovered it. And, as I have been trying to improve my workflow, I found the idea of deploying my site with a simple “git push” very enticing.
I experimented briefly with Pages and decided to go with Github for my webpage hosting. However, I quickly realized I had a problem. I had an existing Github repo that housed the code for bencarson.net. I also had a Github repo in ben-carson.github.io that I had created for my Pages experimentation. I didn’t want to lose the history of my original website project. And I also didn’t really want to just copy-and-paste my original site’s files over my Pages repo, that just felt too inelegant. What I really wanted was to combine these two distinct git projects and their histories into one project.
My Git-fu is still pretty weak, so I took to the web for help. My initial searches provided results on merging subtrees and modules and whatnot. More along the lines of keeping a library that a project uses up-to-date, rather than a one-time project meld. Way overkill for my needs. Then I found this post. It was close to exactly what I was looking for.
For the sake of clarity, I’ll include just the (DOS) commands I ran for this process:

C:\> mkdir bencarson-website

C:\> cd bencarson-website

C:\bencarson-website> git init
Initialized empty Git repository in c:/dev/workspace/blog-post/.git/

C:\bencarson-website> dir > deleteme.txt

C:\bencarson-website> git add .

C:\bencarson-website> git commit -m “Initial commit”

C:\bencarson-website> git remote add bc-gh-io-remote https://ben-carson@github.com/ben-carson/ben-carson.github.io.git

C:\bencarson-website> get fetch bc-gh-io-remote
warning: no common commits
remote: Counting objects: 73, done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 73 (delta 11), reused 69 (delta 10)
Unpacking objects: 100% (73/73), done.
From https://github.com/ben-carson/ben-carson.github.io
* [new branch] master -> bc-gh-io-remote/master

C:\bencarson-website> git merge bc-gh-io-remote/master

C:\bencarson-website> git rm deleteme.txt
rm ‘deleteme.txt’

C:\bencarson-website> git commit -m “removing garbage file”
[master 05b4839] removing garbage file
1 file changed, 10 deletions(-)
delete mode 100644 deleteme.txt

#combine the ‘remote add’ and ‘fetch’ commands with the ‘-f’ parameter
C:\bencarson-website> git remote add -f bc-net-remote https://ben-carson@github.com/ben-carson/bencarson.net.git
Updating bc-net-remote
From https://github.com/ben-carson/bencarson.net
* [new branch] master -> bc-net-remote/master

C:\bencarson-website> git merge bc-net-remote/master

C:\bencarson-website> git remote remove bc-net-remote

C:\bencarson-website> git remote rename bc-gh-io-remote origin

C:\bencarson-website> git push origin master

After this, my new, history-merged, site was pushed up to ben-carson.github.io and is available[Edit 03.10.15: removed all my github stuff]! Super easy, once you know how to do it.

I bought a Raspberry Pi for myself this Fall in order to play around with the minicomputer that is so popular these days as an opportunity to teach myself a little more about Linux, hardware, and networking. I read many many posts about lots of individuals running the Pi as a media server for their first experience with this computer. Seemed like a reasonable place for a Pi noob like myself to start as well…

If this previous paragraph sounds anything like you, consider this post a warning.

TL;DR version: DON’T! Just because you can do something, doesn’t mean you should.

  1. Install RaspBMC to SD card
  2. Boot Pi
  3. Wait for OS to initialize
  4. Realize process is frozen
  5. Reboot Pi
  6. See that installation is corrupted because previous attempt to start failed
  7. Go back to step 1
  8. Continue previous steps until the XBMC interface actually installs all updates without freezing or corrupting itself
  9. Try to do something once interface is loaded
  10. Oops, you moved the mouse too quickly or used the wifi connection and pulled too much power; system is hung
  11. Reboot
  12. Continue this process until you can get to the “Plugins store”
  13. Browse available plugins
  14. Peruse the vast wasteland of useless XBMC plugins
  15. Realize that nothing worth loading runs on an ARM processor (Want Netflix/Hulu/CW/ABC/etc? Too bad!)
  16. Say fuck it all and install something else your SD card. This thing wasn’t meant to run XBMC

If you want a media player, just buy a commercial product like a Roku 3 or Apple TV. By the time you’ve invested enough time, money, and energy in just getting what the Pi needs to run (case, 5V/1A+ PS, USB cable, HDMI cable, powered USB hub, SD card, mouse, keyboard, wifi dongle, etc), you will have spent MORE on an inferior product!

But wait a minute, this was supposed to be a learning exercise for you, right? Didn’t you at least learn something about the hardware or Linux? Well maybe, I did learn how to get my TV tuner working on my laptop, in an attempt to get it working on the Pi. So there’s that. But the time I wasted and frustration I endured was absolutely not worth learning that bit.

I’ve got Raspbian wheezy, a Debian derivative for ARM processors, installed on it now. That is running great so far. Probably just going to keep it there too. I’m still running Mint, also a Debian-derivative. Its easier to keep everything the same for the sake of learning

I have a Samsung Epic 4G. A really old-ass Android phone. Fortunately for me, Android is an open platform and a very talented pool of hackers and coders have created a vibrant non-commercial ecosystem.

Case in point, I am running Android 4.1.2 (Jelly Bean) on a phone that Samsung never intended to get past Android 2.3 (Gingerbread). The features this opened up to me (running apps that previously were blocked, Google cards, enhance system customizability, etc)  made the phone feel as though it were brand new!

Now, to clarify, I am running the very popular cyanogenmod ROM. Currently running version 10. I could go into a whole other blog post about the bluetooth and memory issues I experienced in CM 10.1, but I just want to get to the fix I needed to get CM10 running smoothly.

I immediately started experiencing issues with the software keyboard after I loaded the gapps package for CM10. I was continually getting the error message, “Unfortunately, Android keyboard (AOSP) has stopped working”  popping up everytime I tapped on something that needed text input. This practically made the phone unusable. Fortunately, the Epic has a hardware keyboard and I was able to find a workaround.

First, you will need to download some alternative keyboard app. I had purchased SwiftKey a while ago when it was on sale, so I just added that to my phone again. I imagine that you can install your keyboard app of choice.

Select Menu (hardware key) -> System Settings – > “Language & input”

language & input

Select Language & input

Select SwiftKey or whatever keyboard app you downloaded

Select alternative keyboard app

Select SwiftKey or other keyboard app

Notice that the Android keyboard (AOSP) can’t be unchecked. This is a problem. Even though the SwiftKey keyboard now appears whenever a keyboard is needed, the Android keyboard is still being opened too. The error message is still appearing. This can be fixed by disabling the Android keyboard app.

In order to do this:

From the Home screen:

Select Menu (hardware key) -> Manage Apps

Swipe all the way to the right until “ALL” app list is displayed, and navigate to the list until “Android keyboard (AOSP)” is displayed

Navigate to Android keyboard (AOSP)

Navigate to Android keyboard (AOSP)

Select the Android keyboard to bring up its properties. Then select ‘Disable’.

Disable Android Keyboard (AOSP)

Disable Android Keyboard (AOSP)

This will deactivate the keyboard and thus, Android won’t continue to try to open the broken keyboard.

I haven’t had a keyboard error message since I have done this.

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!

%d bloggers like this: