Monk Seal Software, up and running

By kenglish

For those of you that don’t know, I’m rebranding under Monk Seal Software. New blog to come soon.

categoriaProgramming commentoNo Comments dataOctober 11th, 2012
Read All

Ruby on Rails Class in Hawaii, October 3rd

By kenglish

I’m teaching an Intro Ruby on Rails Class at University of Hawaii’s Pacific New Media. Hope you can make it, here’s the flyer.

Ruby on Rails Class Flyer

categoriaProgramming commentoNo Comments dataSeptember 24th, 2011
Read All

Migrating my heroku/postgres project to Jruby

By kenglish

A little inspired by all the JRuby buzz, I thought I’d take an existing rails app that I have running on heroku and migrate it to Jruby. I wanted to test how easy/hard it would be:

  1. I made a branch of my project:
    git checkout -b jruby-test
  2. Install jruby via rvm
    rvm install jruby-1.6.2
  3. I editted my .rvmc to use Jruby instead of MRI, from:
    rvm use 1.9.2@proj

    to

    rvm use jruby-1.6.2@proj-jruby
  4. I updated my rmvc from :
    rvm use 1.9.2@proj

    to

    rvm use jruby-1.6.2@proj-jruby
  5. I edited my Gemfile. This is where I knew it would get tricky.

    1. Removed:
      gem 'pg'
    2. Added:
      gem 'activerecord-jdbc-adapter'
      gem 'activerecord-jdbcpostgresql-adapter'
      gem 'jdbc-postgres'
    3. Found out hard way had to remove ruby-debug19. DUh, dude :)
    4. Texticle gem does not work. This makes sense because it is plugin to postgres ActiveRecord driver. However, I use this for my minimalistic search functionality.
  6. Ran ‘rake spec’ on the project. My tests for the search feature failed as expected because of the missing Texticle dependency. I had one test that was failing on
    Regular expression. The regular expression looked like this:

    if last_item =~ /sector|leverage_point/

    When examined the code a bit, I found out that last_item was actually a symbol. I guess MRI automatically converts symbols to strings for Regular Expressions and JRuby does not. I changed the line to:

    if last_item.to_s =~ /sector|leverage_point/

    and it worked fine

  7. Ran ‘rails s thin’ and my app was up and running.

Not bad for a JRuby amatuer. Although not having the Texticle gem is a show stopper on this project.
It’s not that Texticle is the best solution for search but we have some code written in it.

categoriaProgramming commento1 Comment dataJuly 22nd, 2011
Read All

Common Accurev Command Line commands and their git/svn counter parts

By kenglish

I’m using Accurev for a new project, thought I’d throw up a blog post of the commands that I use most commonly:

Make a new workspace, similar to ‘git clone’ or ‘svn co’:

accurev mkws -w workspacename -b streamname_from_server -l local_directory

Note: accurev workspaces are similiar to a cloned git repo, kind of but not really…. Are you confused yet?

Update my workspace from the stream, similiarly to a “git pull”:

accurev update

Get status of my workspace, ie, see what’s changed. Same as “git status” or “svn st”:

accurev stat -n

With the ‘accurev stat -n’ command, unlike git, the files shown will be in relation to your current working directory. So if you do:

cd db/migrate
accurev stat -n

You will only see files you have changed in your db/migrate folder. (Why are you changing your migrations???)

In accurev, file not checked into the work space are called “external” files, you see all these with this:

accurev stat -x

Add external file, same as “git add” or “svn add”:

accurev add -x path/to/file
# or add a directory
accurev add -x -d directory

Revert a file, same as “git checkout” or “svn revert”:

accurev purge path/to/file

Promote all kept files to the stream, kind like “git push” or “svn commit” but more like “git push”

accurev promote –c “JIRA-666 comment” –k

I’ll add more as my project progresses…

accurev keep -R -n -c "codenarc fixes" grails-app/domain

categoriaProgramming commento3 Comments dataJuly 12th, 2011
Read All

Override behavior of “rake spec” task

By kenglish

Basically, I have a bunch of folders in my spec directory for a rails project:

spec/acceptance
spec/controllers
spec/fixtures
spec/helpers
spec/javascripts
spec/lib
spec/mailers
spec/models
spec/support

The spec files in my acceptance folder are my capybara/selenium tests and still in experimental phase. I don’t want them to run every time and definitely don’t want the CI server running them. However, when I run ‘rake’ or ‘rake spec’, it runs everything in my ‘spec’ folder. I want it it to run the specs in every directory except acceptance.

I discovered there is not easy way to override a rake task. Redefining the task appends to it which to me is a pretty intuitive default behavior. Apparently, dchemsky knows about this and has opened an issue with rake. I was able to piece together a solution from an old blog post by Jay Fields.

Feel free to comment if you have a better way to do it.

 
require 'rake'
require 'rspec/core/rake_task'
 
class Rake::Task
  def abandon
    @actions.clear
  end
end
Rake::Task[:spec].abandon
 
RSpec::Core::RakeTask.new(:spec) do |t|
  t.pattern = "spec/{models,views,controllers,helpers}/**/*_spec.rb"
end
 
namespace :spec do
  desc "Run the code examples in spec/acceptance"
  RSpec::Core::RakeTask.new(:acceptance => "db:test:prepare") do |t|
    t.pattern = "spec/acceptance/**/*_spec.rb"
  end
end

categoriaProgramming commentoNo Comments dataApril 29th, 2011
Read All

Using Rails 3 helpers and routes in the console or a rake task

By kenglish

To use a Rails 3 helper in the console

If this is your helper:

module ItemsHelper
  def custom_item_display(item)
    item.to_s
  end
end

And you have a route that looks like this:

  resources :items

On the console, you would do this:

ruby-1.9.2-p136 :001 > item = "hello world"
ruby-1.9.2-p136 :002 > helper.extend ItemsHelper
ruby-1.9.2-p136 :003 > helper.custom_item_display(item)
 => "hello world" 
ruby-1.9.2-p136 :004 > include ActionController::UrlWriter
 => Object 
ruby-1.9.2-p136 :005 > items_path
 => "/items"

In the rake task you do this:

namespace :example do
  desc "Do example items"
  task :items => :environment do
    item = "Hello World"
    include ItemsHelper
    puts "ItemsHelper.custom_item_display(item) = #{custom_item_display(item)}"
 
    include ActionController::UrlWriter
    puts "items_path = #{items_path}"
  end
end

Hope that helps.

categoriaProgramming commentoNo Comments dataFebruary 5th, 2011
Read All

Using TinyTDS to connect to SQL Server with Ruby on Rails 3 (for Mac OSX)

By kenglish

Note: please see comments by Ken Collins (metaskills.net) at the bottom of this entry. He mentions a better way to do this without even installing FreeTDS.

You will need FreeTDS to connect to MSSQL Server on Unix-based environments. You MUST use Homebrew to install FreeTDS on the Mac. MacPorts is evil and will not install FreeTDS correctly. Installation of Homebrew is covered excellently in the Homebrew installation docs:
https://github.com/mxcl/homebrew/wiki/installation

Edit the FreeTDS configuration for the FreeTDS library:

brew edit freetds

Replace from “def install” to “end ” with:

def install 
  args = ["--prefix=#{prefix}",
          "--with-tdsver=7.0",
          "--enable-msdblib",
          "--mandir=#{man}"]
 
  system "./configure", *args
  system 'make'
  system 'make install'
end

Install FreeTDS:

brew install freetds

Add an entry to the bottom of your freetds.conf for your MSSQL Server. This file is found at /usr/local/etc/freetds.conf:

[my_sql_server] 
host = <hostip>
port = 1433 
tds version = 7.0

Add the TinyTDS and activerecord-sqlserver-adapter gems to your Rails Gemfile.

  gem 'tiny_tds'
  gem 'activerecord-sqlserver-adapter', :require => false

Run bundler to install the gems:

bundle install

Finally, add the connection to your database.yml file:

development:
  adapter: sqlserver
  mode: dblib
  dataserver: my_sql_server
  database: my_database_name
  username: my_username
  password: xxxxx
  timeout: 5000

A reference for installing UnixODBC (which I don’t recommend), you can follow this tutorial:
MSSQL2005 on Rails on Snow Leopard (the easiest way I know how.)

categoriaProgramming, Tech commento7 Comments dataJanuary 13th, 2011
Read All

Honolulu Hacker’s Guide to Lite Weight Backpacking

By kenglish

Based on some backpacking experience over the years, I’ve come up with this list of ways to reduce the weight of your pack. Read and Learn.

  • Toilet Paper: Anyone who has moved before knows one thing: Books are heavy. Guess what books are made of?…. PAPER! That’s right, the same thing that they use to make toilet paper. I suggest you lighten your toilet paper load. Next time you go to the bath room, make note of how much toilet paper you need. How many times do you wipe? If you average 3-4 wipes, can use only 2 squares per wipe and can estimate you will be going to the bathroom 2 times a day, do some math, figure out how much mountain money you will REALLY need. If you are a guy, congratulations, you can bring less TP. Don’t tell the girls this, they may ask you to carry their tent.
  • Deodorant: Seriously? All or some of your backpacking buddies are gonna smell worse than the slums of Manila. Why are you going out our way to smell good? Leave this item at home.
  • Camera: Skip it. Don’t worry, one of you buddies will bring a camera especially if you are with a big group. One of them may even carry a tripod, a monopod and so much other camera gear that he is going to need a hip replacement by the age of 35. Don’t be that guy. Plus, think about it: if you are taking all the picture, you won’t be in any of them. My wiser older brother once told me: a picture without a person is postcard. If you want pictures of the scenery, just go on flickr and do a search. Chance are pretty good someone else has been there. Make their image your wallpaper. When your co-workers comes, you can brag about what a great trip you had and how much cooler you are than them. Go ahead, gloat away. You’ve got the wallpaper to back it up.
  • Tent: So, you hiked all the way out into the woods so you can sleep INDOORS. Forget that. I have seen someone make a very sustainable shelter out of a rain tarp. You just need to be creative. Cavemen didn’t always make it back to the cave and they didn’t have REI either. What did they do? If the going gets really rough, you can sneak into your buddy’s tent.
  • Water: I don’t think I need to ask this but what human do you know that will deny another person water?… and you can always count on others to carry water.

This only some of the great ideas that will be present in my new book on backpacking. Please e-mail to preorder it.

categoriaProgramming commento1 Comment dataJune 24th, 2010
Read All

Best Music of 2006: My picks

By kenglish

1) Flaming Lips: At War with the Mystics

FlamingLipsAtWarWiththeMysticsFor the second time this decade, the Lips have nailed it. While the first song (“Yeah, Yeah, Yeah“) annoys the hell out of me, the rest of the record is an honest-to-God masterpiece. “Vein of Stars” and “Pompeii AM Götterdämmerung” are my favorites with “Sound of Failure” and “My Cosmic Autumn Rebellion” not far behind. I don’t know what it is about these guys. It’s not like they are best musicians in the world and Wayne Coyne isn’t the best singer (seriously, sometimes he’s really out of key). It must be that they just write great songs and have mastered the studio process.

2) Built to Spill: You in Reverse

BuiltToSpillYouInReverse_coverMusic has given us a Neil Young and a J. Mascis but Doug Martch carries the torch when it comes to loud, garage-rocked guitar shredding. With no apologies, the album kicks off with the 8:42 guitar solo driven “Going Against Your Mind.” The best moment of the album comes later with “Conventional Wisdom” and it’s melodic guitar duals towards the end (although they were probably both played by Martsch). I wouldn’t want to take credit away from the rest of the band, they are certainly sound in top form and remain an indie-rock power house almost a decade later. At first listen this album disappointed me but it has really grown on me over the years. It contains some of the sound of their early work blended with a new energy and some different ideas.

3) Amy Winehouse: Back to Black

AmyWinehouse-Back_to_Black_coverThose of you that know me, know that I don’t normally listen to this kind of music: Pop, R&B, Neo-soul, whatever you want to call it. But at the time I was reading a lot of dlisted.com as a guilty pleasure and Wino was featured everyday in some new humiliating picture or story. I guess any press is good press because I had to hear her music to find out what the big deal was. I’m not only attracted to the drama presented in her lyrics but I genuinely like the sound and structure of these songs. The title track and “You know that I’m no good” are my two favorite here. The record as a whole falls in place very nicely.

4) Sonic Youth : Rather Ripped

SonicYouth-RatherrippedThis is the album Sonic Youth should have made in 1995 coming off their Lollapollza headline spot instead of Washing Machines. In my opinsion, this is the most accessible set of songs they have ever put together. Gone are the ten minutes of feedback and in is some catchy indie rock that is “Reena“, “Incenerate” and Renaldo’s “Rats.” Even the quiet numbers, (“Do You Believe in Rapture?“, “Or“, “Turquoise Boy“) sound like something a person unfamiliar with their style would enjoy.

5) Ratatat : Classics

Ratatat-ClassicsIf you haven’t heard of these guy, go listen to “Wildcats.” This NYC duo creates music that is a fusion of metal sounds and dance beats with a signature fade-in guitar. I’d rate this as the instrumental album of the year. You won’t find any shredding solos here but you’ll find well arranged melodic compositions. It’s great background and foreground music.

6) Bob Dylan: Modern Times

BobDylan-ModerntimesI have said earlier that I don’t think this album is as great as most critics crack it up but I am a Dylan fan and I’d be lying if I said this album hasn’t spent some time in my rotation. His singing is still pretty raspy and irritating at times but His band sounds great and his lyrics are still poetic and profound. I’ll never understand why this album is called “Modern Times” when it sounds more like a shuffle, remincent of old American music. I like “Spirit On The Water” and “The Levee’s Gonna Break” best here. For the die-hard Dylan, be sure to read the wikipedia article about writing credit controversy

categoriaMusic commentoNo Comments dataApril 1st, 2010
Read All

Has comedy changed as a result of the internet?

By kenglish

Let’s think about how comedy has changed since we’ve started consuming digital video on the internet. Prior to the Internet, comedy media was consumed primarily through movies and television. However, the internet has made comedy infinitely more accessible and thus we’ve been laughing a lot harder these days at a lot of different things.

To begin, what is Comedy? The following summarizes a popular book about comedy:

Comedy Writing Secrets by Mel Helitzer

Why We laugh?
The two main motivations:

  • We laugh out of surprise.
  • We laugh when we feel superior.

There are six additional motivations each which supports the first two.

  • We laugh out of Instinct
  • We laugh at incongruity
  • We laugh out of ambivalence
  • We laugh out of release
  • We laugh when we solve a puzzle
  • We laugh to regress.

Recipe for Humor:

The following six elements must be present for any humor to work:

  • Target
  • Hostility
  • Realism
  • Exaggeration
  • Emotion
  • Surprise

These elements have not changed much, what has changed is the content.

How do I consume great comedy vidoes?

This is my internet Comedy Highlight real. Since I won’t have time to show all these videos in class, I hope that the other students will visit my blog and watch them on their own time.

Early history:
Star Wars Gangsta Rap: The most popular flash-video of all time

Lenny Bruce, Eddy Murphy, Richard Pryor were all considered vulgar for their time. Now, notice that vulgarity is almost expected in interactions on the internet.

Popular Targets: Technology and Technology Workers

There is a hostility towards traditional media. Even though we’re consuming more traditional media than ever, it’s easier to make fun of it now:

Charlie Brooker – How To Report The News

Auto-tune the news with Joe Biden singing

Mixing Media:


Star Trek and Monty Python.

Don’t Taze me and MC Hammer.


Kesha/cops parody uses many internet based images.

Target/ Hostility: Popular Movies

Twilight ‘New Moon’ in one minute.


How Star Wars should have ended.

Realism (Fail Videos) Top 100 Fail Clips of 2009:

Tons of Suprises:

Misheard Metal Lyrics.

Digital video can be used to parody how ridiculous Television video is. Does this render Television obsolete or
engage us more in it. For example, before watching the Rap Chop video, I knew very little about the slap chop. Now I always check it out in the “As seen on TV” store.
Slap Chop Video.

Rooftop Comedy introduces us to new comedians in short, easy to consume forms.

Comedy by Consensus? Pride of origination?

So, has comedy changed? Not much. Our tolerance for bad comedy has certainly gone. Nothing is is off limits these days and technology has given comedy infinite more possibilities to expand.

categoriaTech commento1 Comment dataFebruary 21st, 2010
Read All