Jonathan's Pancheria

dotcom Thousandaire

technical

Important step if you want to use the chef database cookbook with postgresql

I ran across this today while trying to use the chef community database cookbook.  If you want to use it along with a postgresql database to e.g. create databases and create and assign roles to users, then you may need to do the following, at least with the chef 11.04 client running against a 10.18.2 server, which is my setup:




  • You will need to have your role have recipe[postgresql::ruby] in its run list before the database cookbook in the role file that uses database, or otherwise set up your chef environment have it run earlier in the order


  • In your recipe where you do your postgresql setup work, include the command chef_gem 'pg' before you use any of the database cookbook commands

Published on 18/03/2013 at 10:15PM under . Tags , , , , ,

Helpful Vagrant bash functions/tab completions

I am doing a bunch of work in VMs managed with Vagrant+chef, and I have several different VMs configured for different projects/roles so that I can do dev work on a VM that has just the set of things on it that a QA or production box will have.  To make it easier, I put together some bash functions and a tab completion setup in my .bash_profile to make it easier to work with vagrant and multiple VMs.  I will describe what I wanted to accomplish and how I did it.

Rationale

What I wanted was to be able to have multiple VMs and have it be easy to run a command against any of them without having to cd (change directory) to the correct directory for a server and then do what I needed. The idea is that the following commands should behave as follows:

  • vag server_a up: bring server_a up via vagrant up in server_a’s directory
  • vag server_name vagrant_command …: in general, run the vagrant command vagrant_command for the server server_name
  • firevm server_name: this is the one special command addition I made. I find it useful when I’m doing work on a server to bring it up from a suspended state, ssh into it, do my thing, then suspend the server when I log out of the ssh session. firevm is the name of the command I wanted to do that
  • Tab completion should work on the vag AND firevm command, so that if I tab-complete where server_name should be I should see a list of the servers available. For vag I also want it so that if I tab-complete on vagrant_command I get auto-complete against the list of vagrant subcommands

How I Did It

Where the Vagrant-powered VMs have to live

To make the scripting easy, I decided that all the Vagrant setups would live in one directory.

Setting Up the .bash_profile file

I put the following code in my ~/.bash_profile file (also available in this gist): 

The vag function

The vag function takes care of the vag server_name vagrant_sub-command ….

Implementing tab completion

The _vagrant_servers() function and the complete -F … command that follows it handles the tab completion. For the first argument to the commands it completes for, it shows the list of servers (directory names) in the common directory that your vagrant servers live in. If you are using the vag command, it will provide tab completion on the second argument with the list of vagrant sub-commands available. The list of subcommands was scraped out of the invocation of the vagrant command line with no arguments earlier in the script where VAGRANT_SUBCMDS is defined. No other arguments past those supported get any tab completion.

The firevm special command

Finally, the firevm shell function takes care of the special handling to resume the vm, ssh into it, and then suspend it.

Published on 11/01/2013 at 12:31AM under . Tags , , , , , ,

Fixing Android SDK Manager When Packages Appear To Be Missing

Ran across this today, and didn’t find anything while googling for it so figured I would capture it for posterity and in case it happens to me again.



I went to update Android SDK to the latest version today and it was not appearing after pulling down the latest manifests from the web.  It was stuck on the last version released (in this case, version 21 was the latest released, but 20 was the version installed on my machine).  Even worse, some parts of API version 17 showed up in my list of installable packages, but not all of them and not Android SDK Tools or the main SDK Platform.



Solution: go to the Android SDK Manager menu→Preferences.  In the Manifest Cache section on the preferences screen there is a button on the right that says “Clear Cache”.  Clicking that button, then closing preferences and selecting Package→Reload from the app menu and all the latest package manifests show up.



 

Published on 16/11/2012 at 04:52PM under .

Excited to be speaking at devFestDC today

I am one of the panelists for devFestDC today, on the mobile apps panel at 11am.  There’s a good chance, though, if you’re reading this that you may have arrived here based on that fact.  I’m just now dusting this blog back off, but in the meantime, here’s one more source of information about the things that are attracting my interest at the moment: my pinboard bookmarking links at http://pinboard.in/u:jonathana/.  I think you can find out a lot about certain people–I certainly put myself in that category–by seeing what they bookmark.

 

Published on 28/09/2012 at 04:44AM under . Tags , , ,

100x100 Challenge: January 30, Day 2-150 lines

Summary

I did not think I would actually make today one of the 100 days, but I pushed through. I guess the incentive of challenging myself is working ;-)

Accomplishments

  • Finished debugging the last part of adding the second controlled list admin table. Add and remove working
  • Added the third and final admin table
  • Committed

Issues

Ready to move on past admin page. Data for the main part of the application can now be entered and things are ready to move to building the main part of the app now.

LOC counts are harder if you don’t commit your code every day. I will have to figure out how I can reconcile committing the done LOCs versus not breaking the build, as it were. I believe using git’s staging capability will be important for doing that, or I might have to go to trunk and a stable branch, or I can use git clone and keep unstable local and my remote repos stable. Any way will teach me more about git, but it will be easier to manage the tasks of this challenge and the requirements of good codebase hygiene to figure one of them out.

Published on 31/01/2009 at 06:32AM under . Tags , ,

100x100 Challenge: January 29, Day 1-119 lines

Summary

After having to make the day I thought up the idea be my Prologue, January 29 turned out to be fairly easy to make 100 lines of code. Not every day will be this easy, I bet. I also know that I opted for get things done over polish things to perfection. There is definitely some code that should be factored out and made common, but the pattern hasn’t emerged to my brain yet. But the functionality has definitely moved forward

Accomplishments

So here are the accomplishments today:

  • Moved a little forward on getting Google App Engine SDK debuggable in NetBeans. I’m pretty sure what I’ve done is leading me down a blind alley and will end up being scrapped, but I can now start up my app in the Google App Engine SDK from inside NetBeans. But breakpoints clearly don’t work, and I am pretty sure it has to do with the execution model of Google App Engine and so the only way to get it working right would be to delve into the internals of the SDK to fix
  • Got the major admin page for my app moving significantly forward. There are 3 “control table” models that provide the inventory in this application, and there’s what I hope is a nice AJAX-y admin page from which I want users to be able to manage those lists. First of 3 lists is done, so you can add and remove items. Made good progress on the second list supporting add and remove

Issues

Code is not in a completely stable state: second list’s table for add/remove is not adding quite correctly yet. That will be tomorrow’s work. I should probably put a bit of effort into understanding more about how to debug Google App Engine SDK by either getting it in an interpreter/debugger where I can see breakpoints, or learning how to do printf/stderr/console type logging in it. I am sure it can be done, and answer is probably a google search away. But I’m making progress without it, so it is not the biggest issue.

Published on 30/01/2009 at 05:11AM under . Tags , ,

100x100 Challenge: January 28, Prologue-25 lines

So I decided to start blogging my experience the day after I started actually doing the 100×100 challenge. Therefore, I get the benefit of hindsight, especially since I ended up well short of the mark. However, I would have to say the prologue was still fruitful.

Accomplishments

Here’s the accomplishments for the day:

  • Automated mounting of the truecrypt drive I keep most of my data on on my laptop (I’ve had a laptop stolen, the idea somebody had my data even though I knew the thieves would wipe the drive bothered me more than I thought). 5 lines of code
  • Installed Google App Engine SDK on my new laptop. Since I last touched my Google App Engine app, I got a new laptop and still hadn’t put the SDK on it
  • Got gitosis running on my re-imaged Joyent Accelerator. I beta-tested their latest image so I’ve installed it about 6 times now: I’m fast at it, but it still needed to be done. 5 lines of code
  • git clone-ed the repository from my home server to the Joyent Accelerator and to the new laptop
  • Installed KomodoEdit and NetBeans 6.5 with jvi and python environment. Decided to try NetBeans as my programming environment
  • Got past the roadblock that arose over 6 months ago when I put this app aside! 15 lines of code

Issues

Not too many really. I should probably figure out how to run Google App Engine in the NetBeans debugger.

Thoughts

NetBeans is pretty good. The python environment works fairly well. Like I said, it would be interesting to see if I can debug Google App Engine from inside it.

Published on 28/01/2009 at 11:56PM under . Tags , ,

100x100 Challenge

So I am going to set myself out a hopefully fun little challenge: 100 lines of code in 100 coding days. It’s my challenge (and if this catches on, my meme ;-)), so I get to define my groundrules. Of course, someone else who wants to quibble with these is free to come up with their own groundrules for their own challenge, publish them, and see how they do on their own ground rules. Point of this, however, isn’t to have a flame war on the ground rules. It’s to write code, have fun, and see where doing something this regimented leads.

Ground Rules

  • There will be 100 coding days. I am going to exclude certain days from the 100 day count like:
    • Any day I’m away skiing
    • Vacation by default, although if I feel like coding on a vacation day I reserve the right to make it a coding day
    • Operational crises at work, although hopefully those are going to be at a comparative minimum these days
    • Sick days, with the same caveat as vacation days
    • One weekend day a week, choice of which one each week
  • For each of the 100 coding days, either:
    • Write 100 lines of code
    • Remove 100 lines of code by refactoring
  • Lines of code are counted as any non-comment, non-blank code that has any alphanumeric symbol, constant, value, etc. Here are some things I will or wll not count as a line of code:
    • Do not count: comments
    • Do not count: blank lines (zero or more whitespace characters)
    • Do not count: closing lexical scope symbols like } in C/C++/Ruby etc
    • Count: closing HTML/XML tags. They have identifiers on them, so I’m counting them. And remember, these are my rules
  • Blog about each day’s experience: how many lines, what was accomplished, what issues were resolved or came up; any other thoughts about the day’s effort
  • Publish the code: put the code out there for people to see at some point when it gets done. I will probably use my github account

Why I Am Doing It

I have a whole pile of interesting hobby projects that have been sitting around, not getting very far. There is some tangential work application to some of them, but some of them are just brain stretchers: play with something new, learn it, figure out some paradigms and programming models.

I am tired of not forcing myself past roadblocks in these hobby projects and letting them just languish. So this is a way to force myself to work on finishing at least one of them up. It is also an experiment in writing things that are just good enough. By pushing to finish them, I am hoping I won’t get into bouts of perfectionism of making sure every single artifact in my code utilizes the cleanest, most elegant paradigm in the toolkit I’m working on, since a major part of the goal of this is intellectual mastery of the subject matter. Going back to refactor, I may clean things up and make them more elegant. But this may force me to get things done instead of polish them to perfection. If I want to clean something up, I’ll go back and do it after I’m done with a first cut.

What Am I Coding?

I have been playing with a Google App Engine application since right after their initial limited beta got expanded the first time and I got my invite. The app has been sitting stuck on a particular error for over 6 months now. So I am going to finish the application.

One goal with the app, besides learning Google App Engine, is to build myself a modern, ajax-y web application using new shiny toolkits on the server and browser. As of right now I am using Google App Engine on the back end, and YUI for the DHTML/Ajax stuff.

I may post more about the actual experiences with the toolkits as additional posts when there is a longer topic. DHTML toolkits is a very possible start. YUI is definitely an “accomodation” choice: there are reasons I’m using it here that are very specific to this project’s situation that I’d like to explore.

After Google App Engine?

Another goal is to play with “cloud”-type apps. That was the interest in Google App Engine when it came out. Given that, if I actually finish the Google App Engine app, some other things I’d like to attack would be to see what challenges I face trying to port the app to different platforms, for example:

  • Heroku, where I also have a beta account languishing
  • A different python framework like TurboGears2 or Django, running on my Joyent Accelerator and maybe even Amazon EC2
  • The Nitrogen Erlang framework, again hosted on my Joyent Accelerator or Amazon EC2 (or both!)

There has been lots of discussion about portability, vendor lock-in, OSGi stack-level mismatches between various cloud offerings. By taking a sample app that is small enough to be written reasonably easily, but has enough breadth of functionality to tickle enough parts of a modern AJAX web app, maybe I’ll provide some interesting data points about writing for the cloud.

Published on 28/01/2009 at 11:41PM under , . Tags , ,

The Mainstream realizes SOA is going the way of WS-*

So I disagree with the way the argument in this post is framed, but I am glad to see the “mainstream” tech press realizing there’s a better way to get to SOA:

A growing number of companies are finding that lower-visibility Web-oriented architecture (WOA) developments, spawned through grassroots movements, are a better route to the service-oriented architecture. WOA, like SOA, is an architectural approach to system design, though WOA is resource-oriented rather than service-oriented. What’s the difference? While the core SOA design unit is a reusable service that fulfills a distinct business function, resource-oriented services are more limited and data-focused.

SOA and WOA work at different layers of abstraction. SOA is a system-level architectural style that tries to implement new business capabilities so that they can be consumed by many applications. WOA is an interface-level architectural style that focuses on the means by which these service capabilities are exposed to consumers. Governance, quality of service, security, and management are of equal importance, whether the functionality is being delivered via SOA or WOA.

I think the delineation between SOA design units as a service fulfilling a distinct business function and WOA as a resource-oriented service being more limited and data-focused is so much dissembling for SOA being an attempt to force a top-down, waterfall-based model on what services you offer in your architecture versus an iterative or even agile strategy of building the individual services and then gluing them together.

I think SOA was also overblown in the framework for tying them together, which is the root of this problem, and leads to the conclusion I made up above. Put a bunch of webservices out there that handle orthogonal responsibilities, make it easy to access them (personally, preferably with easy HTTP/POX or a light SOAP layer), rather than a huge management stack that services have to a priori fit into, with the up-front design and overhead that comes with it.

Published on 11/08/2008 at 07:21PM under . Tags , , , , , ,

Good point about *any* Web Services != RPC

So ordinarily, this post would have gone up as a link in del.icio.us, but the interesting part of it is actually a single quote that flows in the article but is not the main point. So I will just crib the interesting part here. It is worth reading the entire post as it is interesting, but what I want to call out is:

bq.IMO the real underlying problem is that as long as programmers expect to write a class and flip a switch to get a service or one or more RESTful resources then we have nothing really but RPC masquerading as something else. Both resource and service advocates would be well-off in trying to move the developer community to get past the “class is all I need” stage. If REST is successful in getting developers to get their hands dirty more power to it.

Published on 25/07/2008 at 03:44PM under .

Powered by Typo – Thème Frédéric de Villamil | Photo L. Lemos