How to program more good.

Using PostgreSQL with Cloud9 IDE

December 22, 2013

I’ve become a big fan of Cloud9 IDE as a replacement development environment for when I’m away from my usual development tools. Unfortunately, there’s not a lot of documentation about how to get a workspace up and running with PostgreSQL. Here’s how I got my setup going.

  1. Install PostgreSQL in your workspace. In the terminal type:

    austinkeeley@postgres-test:~ $ c9pm install postgresql-9.2.4

    And you should get the following output:

    grep: postgresql-9.2.4: No such file or directory
    Installing postgresql-9.2.4
    Checking for conflicts
    Adding package files
    Installed postgresql-9.2.4
  2. Create a data directory by typing the following:

    austinkeeley@postgres-test:~ $ initdb ~/postgres-data

    And you should get the following output:

    The files belonging to this database system will be owned by user "52b945a6e0b8cdb08c000042".
    This user must also own the server process.
    The database cluster will be initialized with locale "en_US.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    The default text search configuration will be set to "english".
    creating directory /var/lib/stickshift/52b945a6e0b8cdb08c000042/app-root/data/postgres-data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 32MB
    creating configuration files ... ok
    creating template1 database in /var/lib/stickshift/52b945a6e0b8cdb08c000042/app-root/data/postgres-data/base/1 ... ok
    initializing pg_authid ... ok
    initializing dependencies ... ok
    creating system views ... ok
    loading system objects' descriptions ... ok
    creating collations ... ok
    creating conversions ... ok
    creating dictionaries ... ok
    setting privileges on built-in objects ... ok
    creating information schema ... ok
    loading PL/pgSQL server-side language ... ok
    vacuuming database template1 ... ok
    copying template1 to template0 ... ok
    copying template1 to postgres ... ok
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    Success. You can now start the database server using:
    postgres -D /var/lib/stickshift/52b945a6e0b8cdb08c000042/app-root/data/postgres-data
    pg_ctl -D /var/lib/stickshift/52b945a6e0b8cdb08c000042/app-root/data/postgres-data -l logfile start
  3. Start things up (This will run it in the background, hence the ampersand at the end. You can also run this in a separate window).

    austinkeeley@postgres-test:~ $ postgres -D ~/postgres-data -h $IP &

    And if things worked out, you should see:

    LOG:  could not bind socket for statistics collector: Permission denied
    LOG:  trying another address for the statistics collector
    LOG:  could not bind socket for statistics collector: Permission denied
    LOG:  trying another address for the statistics collector
    LOG:  could not bind socket for statistics collector: Cannot assign requested address
    LOG:  trying another address for the statistics collector
    LOG:  could not bind socket for statistics collector: Cannot assign requested address
    LOG:  disabling statistics collector for lack of working socket
    WARNING:  autovacuum not started because of misconfiguration
    HINT:  Enable the "track_counts" option.
    LOG:  database system was shut down at 2013-12-26 23:23:27 EST
    LOG:  database system is ready to accept connections
  4. Now make sure you can connect to it

    austinkeeley@postgres-test:~ $ psql -U $C9_USER
    FATAL:  role "austinkeeley" does not exist
    psql: FATAL:  role "austinkeeley" does not exist

    Whups. Your username doesn't exist in the database (by the way, Cloud9 keeps track of your username in the $C9_USER environment variable, so you can use that in any scripts you write). Let's add your user.

    austinkeeley@postgres-test:~ $ createuser $C9_USER

    We should also make you a database.

    austinkeeley@postgres-test:~ $ createdb $C9_USER

    Now you should be good to connect and start working with PostgreSQL.

    austinkeeley@postgres-test:~ $ psql -l
                                                             List of databases
               Name           |          Owner           | Encoding |   Collate   |    Ctype    |                   Access privileges                   
    austinkeeley              | 52b945a6e0b8cdb08c000042 | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
    postgres                  | 52b945a6e0b8cdb08c000042 | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
    template0                 | 52b945a6e0b8cdb08c000042 | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/52b945a6e0b8cdb08c000042                          +
                              |                          |          |             |             | 52b945a6e0b8cdb08c000042=CTc/52b945a6e0b8cdb08c000042
    template1                 | 52b945a6e0b8cdb08c000042 | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/52b945a6e0b8cdb08c000042                          +
                              |                          |          |             |             |   52b945a6e0b8cdb08c000042=CTc/52b945a6e0b8cdb08c000042
    (4 rows)
    austinkeeley@postgres-test:~ $ psql -U $C9_USER
    psql (9.2.4)
    Type "help" for help.

Posted by Austin    link   Tagged with: cloud9, postgres

I actually forgot how to login to this thing.

December 21, 2013

The last time I wrote anything here was summer. Wow.

I've been doing more work with Rails and Heroku putting together a portfolio at my other website "": which has a big list of junk I've been up to. I have a few ideas for longer Python writing that might come together. In the meantime, I've been developing a new startup from Startup Weekend D.C.. It's pretty cool.

Posted by Austin    link   Tagged with: random

Freedomhack 2013: A Hackathon for Good

August 8, 2013

I just wrapped up Freedomhack, a weekend-long hackathon in DC with the main goal of creating solutions for people and reporters in violent parts of the world. The Mexican border was the main place of concern. The entire event was sponsored by Amnesty International. I had never done a hackathon before and I spent a lot of time comparing how this one worked as opposed to a Startup Weekend.

We built a software platform called VozLocal (Spanish for "Local Voice"). We basically just redirected ==SMS== texts to a Twitter account while maintaining them in a database. Really, it was a pretty trivial effort. I'm surprised no one has done it before, or maybe they do and the thing just gets shut down due to spammers overloading the Twitter feed.

I was a little frustrated that we spent about an hour talking with activists asking them what kind of software they needed and I don't think we got a definitive answer.

The project that won was a near field communication application. I didn't catch the entire pitch because I was off prepping our presentation.

One refreshing thing about this was that no one wanted to talk about revenue or how to make money on an idea. This kind of talk at Startup Weekend events really gets on my nerves. I'm there to build something cool and people will shut it down because it might not make a profit within the first 6 months. Although, at the end of this, I was actually thinking about how we could monetize our project.

Anyway, lessons learned.

  • We used "Cloud 9":, a "cloud based" ==IDE== which I'd heard of before but honestly when hearing "cloud" anything, I tend to be skeptical and dismissive. Honestly, it's good. Really good. I won't be switching over to it for my everyday dev tools, but if I'm away from my computer and need to code up a quick Rails app, this thing does the job. Basically it acts like a dev tool suite set up on a VM with editing tools in the browser. It really shines when you integrate it with your github account to collaborate. You can share workspaces within the tool, but that's kind of a lousy substitute for a real repo. To make things better, you can run a dev server or deploy the code to a cloud instance. The free version worked well enough for us all weekend. I'm not sure I would use it enough to justify the $12/month premium version, but it's definitely going in the Startup Weekend/hackathon tool bucket.

  • Bootstrap has upped the ante for web design and basically if you suck at doing design you can just use Bootstrap and pull off a good looking page without a lot of effort. The downside is that everyone is using Bootstrap, so there's a good chance your project will look like someone else's. Worse still, if you don't use Bootstrap and present a lousy looking page, it's going to look terrible next to someone's glossy Bootstrap site. I think at one point in time, you could pull win a hackathon without a good looking page. Judges were more forgiving for skipping the cosmetic aspects of a 24 hour code crunch, but now Bootstrap has ruined everything. Oh Bootstrap. I wish I could quit you.

  • The workspace, 1776, was pretty cool. There was a lot of alcohol at this one, so D.C. hackathons have some priorities. It's coworking space in the city and had a fun "let's do things that matter" feel to it. This was a much smaller event than Startup Weekend, so it had fewer people, which was nice because it wasn't as loud. Also, they had lots of tables. If you're going to host a hackathon, provide tables. That seems really basic and dumb, but at the past two Startup Weekends, it feels like there's a shortage of places to work.

  • I was much more productive at home than I was at the venue. I called it a night at 9:30 pm on Saturday and we all went home. Once I got home, I actually cranked out a majority of the project code. Working with other people around a table is fun, but I don't think I actually got much work done. At future hackathons, I might just leave early and communicate with the team over Google hangouts.

Posted by Austin    link   Tagged with: hackathon

More Startup Weekends!

July 24, 2013

I did another Startup Weekend event, this one in Richmond, VA. The pitch I worked on was food truck logistics, which at a first glance, has been done before, but not particularly well (at least not in my limited knowledge of it).

The end result is "":, and it won first place and crowd favorite. A few things that I learned from this one:

  • My Django skills are lame these days. I've been doing a lot of Ruby on Rails development lately and it's messed up my whole perception of how Django "works". I still have the fundamentals down but I learned on Django 1.3. Also, I've never had to use a virtual environment because I'm never really finding myself needing that level of control over my code.
  • My git skills are hilariously svn-like. I have a GitHub account and I've been using that for my personal projects but I'm usually the only one working on them, so I can get away without needing to do a lot of branching. I pretty much just never take advantage of any of the really good features of git.
  • South is a very cool Django app that makes DB migrations not awful.
  • Richmond, VA is a chill place and has some attractive qualities to make it a startup hub. There's plenty of good universities within 2 hours to pull talent from, the cost of living is pretty cheap compared with other parts of the commonwealth, and it has a good urban environment.
  • A lot of pitches were about health care. This is a tricky pitch idea; health care is complicated and controversial. Personally, I would avoid these for a Startup Weekend. Would a health care startup be successful? Absolutely. But 54 hours is a really short time to build up a plan for one.
  • Getting users is a hurdle, and a lot of pitches seem to place a lot of expectations on the user. I think this is a major flaw. They want to make the users serve them instead of providing a service.
  • Having a social media blitz isn't as important as I thought. Our Twitter account ("@StFoodSpotter": had 1 follower on final pitch night and it was me.

Anyway, it was fun and we won coworking space at RVA804 for 6 months. Unfortunately, it's about 2 hours away, but I guess I have an office now in Richmond to work from.

Posted by Austin    link   Tagged with: startup weekend

Startup Weekend Day 2

June 5, 2013

Why no day 1 coverage? Because I was up coding until late.

I signed up for Startup Weekend as a developer. So far, it's been a pretty good experience. The startup idea we're doing is called "FlashThrift":, it's a micro e-commerce site for impulse consignment items. You know how Snapchat lets you take pictures that self destruct? This combines that with online sales that are only available for very short periods of time (think 1 hour).

You go to the site, pick what you want to browse and you are given a constant stream of items for sale, but only a few minutes to consider the offer. You can take the offer, or leave the offer. Once you turn it down, it's gone. Sellers are people who want to just get rid of their stuff and don't want to wait for an eBay auction to end.

We should launch in the next few hours with a prototype with a plan to have a working app up by Sunday afternoon.

Posted by Austin    link   Tagged with: startup weekend

Unless otherwise noted, all content is copyright 2011-2012 The coffee image at the top of the page is titled "Coffee & Splash" and is used under the Creative Commons Attribution-NonCommercial-NoDerivs 2.0 Generic license. Original is attributed to Thomas and is published here. This website uses the Bluprint CSS framework version 1.01. This website also uses SyntaxHighlighter, licenced under the MIT license.