Apr 14, 2014

Setting up postgres for local development on Ubuntu 14.04

I'm starting to do some ruby development on my trusty (so far) Dell XPS 13. Time to get my stack set up. First order of business is Postgresql. Then Ruby, then rails, then it's go time. Let's get started!

For postgres, first update and get the packages you'll need:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install postgresql postgresql-contrib pgadmin3

I don't know about you, but for local development on my laptop I don't like to set up a password for postgres. Let's set that up.

sudo -u postgres psql
ALTER USER postgres PASSWORD 'newpassword';

If you chose '' in the above you'll have no password so there's one more step to take in order to connect locally. Pop open your editor of choice and modify the pg_hba.conf file. (For me that was located in /etc/postgresql/9.3/main/pg_hba.conf)

You'll want to make sure you entries look similar to this:

local all postgres trust

Here's the part of the file you need to alter:

 84 # Database administrative login by Unix domain socket
 85 local   all             postgres                                trust
 87 # TYPE  DATABASE        USER            ADDRESS                 METHOD
 89 # "local" is for Unix domain socket connections only
 90 local   all             all                                     peer
 91 # IPv4 local connections:
 92 host    all             all               trust
 93 # IPv6 local connections:
 94 host    all             all             ::1/128                 trust

One last thing you'll optionally want to do is uncomment the line in /etc/postgresql/9.3/main/postgresql.conf where postgres listens. This might not be necessary but let's get it done anyway:

listen_addresses = 'localhost'    # what IP address(es) to listen on;

With that out of the way let's give postgres as restart

sudo /etc/init.d/postgresql restart

And now you should be able to connect to postgres via the command line or pgadmin3.

Last thing. If you're going to eventually install the pg gem on ubuntu, you'll need to install the postgresql dev packages. Might as well do that now:

sudo apt-get install libpq-dev

With that all done you should be set. Give it a try from pgadmin3, your client of choice, or the command line
Read on...

Apr 13, 2014

XPS 13 Developer Edition - Day 1

So you pushed the Xubuntu 14.04 LTS Stick in and decided to give it a whirl. Before you go any further, keep in mind that, as of the end of day 1, I still have an overly sensitive trackpad, and can't get past the Operating System not found error without manual intervention. If you're cool with that, let's chat a bit about how I went about getting set up.

First, I went with XFCE. I don't hate Ubuntu proper but Dash isn't as efficient as I'd liked so I decided to step back a little.

Second, I installed a whole slew of software: The heroku toolbelt, build-essential, playonlinx, chromium, an xmodmap script, libreoffice, steam, dropbox, calibre, gnucash, audacity, gvim, vlc and many more.

I also got rid of some apps I'm unlikely to use like gnumeric, abiword, and thunderbird.

With that out of the way, here are some of the tweaks I've used:

1. On upgrade to 14.04 your trackpad may not work as it did before. You'll want to try blacklisting ic2_hid as mentioned in this post.

2. Trackpad still not where you want it? Try installing gpointing-device-settings as described in this post.

3. Want to rest your thumb on the trackpad the way you did on Mac OS X? Me too! I haven't been able to figure it out yet though I did find a blog comment where somebody left some instructions for debian. Didn't work for me but if it works for you, drop me a line!

And that's where I've gotten so far. Most of the other tweaks have been personal preferences to get the right programs and key bindings.

So what's next? I'd like to figure out that Operating System not found error (boot-repair did not work for me). I'd also like to try running a game like Hearthstone or Wildstar via PlayOnLinux. And then if things go really well, maybe try to get a VM set up with Windows or MacOS.

PS: if you mess something up badly and need your service tag number to get support from Dell, you can find it by typing. Probably do that now. :)

$ dmidecode | grep "Serial Number"

Read on...

Apr 12, 2014

Quick Tip: Don't show usernames on Xubuntu 14.04 Login

I'm continuing to peck away at things I want to customize in Xubuntu 14.04. Next on the list is getting rid of the dialog that shows my username on the splash screen. I'm not into having my laptop auto-login and so it's not surprised I don't want to display my username either. To get rid of it, open up a text editor and add these two lines to /etc/lightdm/lightdm.conf.d/10-xubuntu.conf


Restart lightdm (or reboot) and you're on your way. Woot! Read on...

Getting started with the XPS13 Developer Edition - Sputnik

I recently decided to give up my trusty Macbook Air and head back down the road of free-ish software. After considering the Asus Zenbook Infinity and Lenovo X1 Carbon, I opted to get myself a Dell XPS 13 Developer Edition notebook.

There's no single reason why, but the price had dropped significantly (right around $1000 as of this writing) and it came with 8GB of RAM and a touch screen. If it had had an option for a 512 GB SSD I would have probably gotten it long ago.

It appeared on the doorstep a few days ago, in spectacular timing with a price drop of an excellent 512 GB mSATA SSD from Samsung. After carefully swapping the hard disk out, using these handy instructions, I thought a bit more about what I was going to run on this laptop.

Before the hard disk swap I'd gotten a chance to play with the stock Ubuntu 12.04 that came with the laptop. For the most part things just worked though the touch pad configuration is terrible out of the box. I upgraded to 14.04 beta and played around a bit there as well.

14.04 beta is a lot less stable which surprised me given how soon this release is supposed to ship. In the past, I'd heard a lot of complaints about Unity so it was nice to use it for myself. It's not bad. I think my biggest issue is Dash which is just not as efficient as say Quicksilver or Spotlight. There's a much better app for ElementaryOS called indicator-synapse but I sadly couldn't figure out how to bind activation to my preferred Space keystroke.

So it was good to know that 14.04 was there and usable. But I have this brand new hard disk.. so I played around a bit. Here are the cliff notes:

1. Debian 7.4 with non-free drivers. (Required due to the firmware for my wireless card which is non-free). Booted but did not get WiFi

2. Debian Jessie alpha installer with non-free drivers. Booted but did not get WiFi

3. Linux Mint LMDE (Debian Edition). Booted, had wifi and most things seem to work. If you like Cinnamon, this is a pretty good choice for running a debian based distribution on your XPS 13.

4. The above but converted to Debian. There are some instructions for converting it to raw Debian. For grins I gave it a shot. It was mostly successful except some nagging issues like dual wifi indicators in my panels. I finally gave up on this as the hardware buttons for adjusting volume and brightness stopped working after the conversion.

5. Xubuntu 14.04 beta. This is where I finally ended up. XFCE4 is just a tad heavier than LXDE but I honestly can't notice it. Plus, the xfce4-terminal makes a great replacement for Guake if you add the --drop-down option. (For some reason guake keybindings won't let me set Control anything).

I'll try to post a few articles on how I set my machine up but keep in mind that this isn't a forum so you're best finding a user group or forum you like for technical questions if what I've documented here becomes outdated.

TL;DR: Tried a bunch of debian based distros on my XPS13 and ended up on Xubuntu. Other than an iffy trackpad, all else seems to work just fine!

Keep on keeping on.

PS: If you're looking to get the additional drivers that Dell shipped you can grab them here. Full warning, these might not be necessary and may even ruin your setup.
Read on...

Oct 8, 2013

Quick Tip, export from rails console to CSV

This is an ugly solution but one that can come in handy if you just need to get some sample data out of your rails application. My particular use case was exporting data from various tables into a CSV file so I could use a 3rd party email service. We have users in a multi-tenant app so it's not quite so simple as just exporting a single table. This is something you almost certainly don't need to use if your SQL-fu is strong. For the rest of us, here we go:

require 'csv'

file = "#{Rails.root}/public/users.csv"

userrefs = UserReference.where(:tenant_id => 7)

CSV.open( file, 'w' ) do |writer|
  userrefs.each do |ur|
    next unless ur.user.present?
    writer << [ur.user.username, ur.user.email]

So what's going on here? Well, first things first we require the CSV library since we'll be manipulating a CSV file.

Next, we create a string that points to that file (make sure the file is created first). The userrefs variable grabs the top level data you need and from there we cycle though them adding records to our CSV file based on any associations we have. Done!

Pretty straight-forward but handy to have in a pinch!
Read on...

May 17, 2013

Quick Tip: Fix Sidekiq-Web with asset pipeline

For those still struggling to figure out why the HTML won't render with Sidekiq web, here's a quick tip:

Old way:

# routes.rb
require 'sidekiq/web'
# ...
mount Sidekiq::Web, at: '/sidekiq'

New way

# config.ru
require 'sidekiq/web'

run Rack::URLMap.new(
    "/" => Rails.application,
    "/sidekiq" => Sidekiq::Web
Read on...

Mar 9, 2013

Music without Device Lock-in

Recently I took the plunge into figuring out a solution to play music in my apartment. I tried a number of solutions but the deciding factor for me ended up being setup and the type of apps available for the hardware platform.

My building offers free WiFi (hooray!) but no dedicated ethernet port (boo!). Here are the 3 things I tried before succeeding.

The Nexus Q is pretty simple to set up. Joining my existing network was a snap and didn't require any special cables, a monitor, etc. It did require that I download the Nexus Q app for my Android phone though. Once it was up and running I noticed a number of inconveniences.

  1. 1. Software is a bit spotty. Google is King of Software so I'm sure this will get sorted out soon.
  2. 2. Requires wired speakers. A huge bummer. You have to get wired speakers and physically plug them into the Nexus Q using banana jack plugs. I borrowed a pair of good speakers with the necessary wires and plugs and gave it a go but the whole thing just looked ugly. (It's an apartment and I'm not going to be able to hide those wires easily.)
  3. 3. Vendor lock in. I really expected Google to be bigger than this. I can't understand why I can't control my Nexus Q from my Mac. I also can't figure out why they wouldn't allow Pandora or 3rd party apps.

So at the end of it, I had to put the Nexus Q back in its box. All the hardware is there so I hope a future software update enables bluetooth speaker pairing and 3rd party apps.

I next tried a Raspberry Pi. Building it is a snap but the lack of TV really made setup impossible. I may give this a try someplace else. Raspberry Pi + Music Player Daemon should be a no brainer. There's even a version of MPD that works with Spotify.

The last thing I tried was Sonos. They've got a basic bridge and Play 3 wireless speaker that costs around the same price as the Nexus Q. The only problem here is that the bridge requires Ethernet. Fortunately I didn't have to look far before I figured out the Apple Airport Express offers a client mode which basically transforms WiFi signals into Ethernet. (The Airport Express does much more too but this is the mode I needed!) After setting up client mode and getting my building to authenticate the device by MAC Address, I was cooking with gas.

Sonos setup is really simple and they offer applications for Windows, Mac, Android, and iOS. It's not perfect (hey Sonos, where's my Debian package?!) but it works well. And the best part about Sonos is that there's no vendor lock in at all. I've got Pandora, NPR, Spotify, and Amazon's cloud player all set up and working.

Apple and Google may think they're winning the war by using their Android and iOS platforms to lock in users, but the reality is that for me, it means giving even more power to the independent vendors who just want your stuff to work wherever you want it to. So thank you Amazon, Netflix, Dropbox, Evernote, Pandora, Sonos, and the rest of you letting me use the things I paid for how I want to.

Read on...

Dec 15, 2012

RailFood Evolves: Another pivot

Having a startup is easy. Succeeding is a different story. It's a terribly competitive game and there are lots of ways to fail and no absolute ways to succeed. One of the ideas I've been working on for about 5 years just took a big shift both in features and messaging.

Initially, RailFood was a Parts listing site for the rail industry. We have paying customers but many of those on the supply side deal with verticals other than rail. So we expanded and changed the name to Partsbook.

Partsbook handles spare parts inventory for most heavy industrial verticals - not just locomotives. We're now working with Mining, Oil and Gas, Marine, Helicopters, Fixed wing aircraft, and plan to add a few others as well.

Throwing the site out there has presented some challenges. Mostly: the buyers are quite content dealing with their existing suppliers and don't want to lower pricing where it might increase tangential risk. On the other hand, suppliers are finding it a waste to deal with the same buyers and not increase their sales opportunities.

I've been giving this some thought, and I think the solution is to reposition the site. Right now we are transaction based - like Amazon for heavy industries. Instead, we'd like to be more community based. So in the next few weeks we'll be experimenting with some different positioning -- trying to see if get more traction by saying we are a collaboration portal over purely a place to buy/sell parts. In fact, we've already changed the title of the main page: Organized procurement and sales for Heavy Industries.

What's been your experience with repositioning your startup? Any tips or advice? Read on...