Multiple Search Keys in CouchDB

I work quite a bit with CouchDB (Cloudant, a hosted CouchDB solution, is part of Bluemix, IBM’s cloud platform – and I work for IBM so I get to use this as much as I like) and today I found a feature I hadn’t seen before. I struggled to find the docs, so I thought I’d post my working example here in case anyone else is solving a similar problem: wanting to use more than one set of key ranges when filtering a CouchDB view. Continue reading

One OpenWhisk Action Calls Another

Working with openwhisk, it’s easy to create many isolated actions and build them up into sequences; the output of one action is passed to the next action in the sequence. In my case, I wanted one action to spawn potentially many other actions. I had to look up how to do it and here it is so I can look it up more quickly next time! Continue reading

Alexa Project Name Generator on OpenWhisk

I’m having lots of fun with my Amazon echo and echo dots, creating skills for them. Initially I used Amazon’s lambda platform since that’s a very easy way to get started – but I’m an advocate for IBM and was looking for an excuse to play with OpenWhisk (an open source serverless offering that Bluemix has a hosted version of) anyway so this was a great opportunity!

Configuring Skills

There are a bunch of good resources around for setting up skills, picking the name, configuring the “invocation” which is what to say to make the code happen, and so on. I’ll skip this section and instead just share a couple of tutorials that I rely on a lot:

Once your skill is configured, it’s time to write the code (note: UK users need to pick English (UK) and not English (US) as otherwise your skill will mysteriously fail in your home region. Guess how I learned that??) Continue reading

Working With Sorted Sets in Redis

I work with a bunch of datastores and I probably shouldn’t have favourites – but if I did, Redis would be one of them! I used the sorted sets in something I was building and remembered how much I liked the feature so here’s a quick primer on what it is and when it can be handy. Continue reading

One-Line Command For Newest OpenWhisk Logs

One of my current project uses OpenWhisk, which is an open source serverless technology stack. IBM has it on their Bluemix platform, and since I work there, I get to play with it as much as I like! One thing that did seem clunky is that it takes more than one step to get the logs of the most recent function run via commandline – first you list the activations, then you request the logs of the activation you’re interested in. Of course, when you’re developing, that’s usually the most recent one so here’s my shortcut for that:

wsk activation list -l1 | tail -n1 | cut -d ' ' -f1 | xargs wsk activation logs

From left to right, sections separated by the pipe | character, this is what happens:

  • get a list of activations, limited to just one activation (it sorts the newest one first by default)
  • grab only the last line of that output (there’s some extra titles and stuff in there)
  • use the `cut` command with the space character as a field delimiter, and use only the first field (this gets the ID of the activation)
  • get the logs of that activation

Of course it’s wrapped up in a script so I just run that from the commandline and check where I went wrong this time …

Exclude a Directory when Grepping

As a developer-of-another-discipline who is now transitioning into a bunch of NodeJS projects, I grep a LOT. However I am usually only interested in the code in the project at hand, and not the dependencies – of course grep has a switch for that! To grep your project and not the dependencies in the node-modules folder, try this:

grep -R --exclude-dir node_modules [what to search for] * 

If you’re using a different tech stack you may want to exclude a different directory (for PHP, the directory would be called vendor), but this is a very handy tip and a bit nicer than the older approach I was using which did the whole search and then used a second grep to eliminate things by using the -v switch.

Sewing Machine Cover

I don’t blog about craft projects all that often, if you have this post in your feed and didn’t want it, then try my “tech” feed specifically rather than all of the blog posts (recommended as I will be blogging a few non-tech things in the coming months). Anyway, I love to make things, code or otherwise, and since I’m not travelling a lot at the moment, I have time to make things AND to write about them. Today: my new sewing machine cover!

New Sewing Machine Cover

Continue reading

cfenv for Easier NodeJS on Cloud Foundry

Now I’m working at IBM I am making extensive use of their Bluemix Platform, which is based on Cloud Foundry. The way that Cloud Foundry is set up is actually very neat, with everything you need contained in JSON structures within environment variables. Parsing out those values can be a pain however, so I thought I’d share the library that’s helping me the most with this: cfenv. Continue reading

Using NPM Link to Develop Dependent Projects

Right now I’m working on a javascript project that relies on another module for some of its functionality. I’m making fairly major changes that affect both projects, and since the dependency is pulled in via npm, initially I was committing and pushing to a repo so that npm could pull in the dependency from GitHub – on every update. Well that gets tedious really quickly so I’m now using the npm link command which is pretty handy. I hadn’t seen it before so this blog post is basically the cheat sheet I wrote when I started using it… Continue reading