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

Updating Local Git Repos When Upstream Moves

The scenario: the “main” repository of a git project has changed, either an organisation rebranded, a project got a new maintainer, or a fork became the acknowledged master. In Subversion, this was the svn switch command and git has an equivalent. It’s relatively easy in git to change your upstream – once you know how – so don’t be tempted to just delete your local repo and re-clone! We can do better than that :) Continue reading

Alexa, When’s the Bus?

I got an Amazon Echo for my birthday (from my husband, who took romantic to a new level when he liked my present so much he bought me an Amazon dot a week later so he could use the echo elsewhere in the house!), which is a new gadget for us. Of course I started asking her questions that she couldn’t answer … and you can write your own “skills” so of course I sat down to browse the documentation and ended up creating a working skill for her :) It was a fun process but there were lots of unfamiliar parts to it so I thought I’d blog what I did in case anyone else wants to try out creating skills as well, and in case I ever want to remember some of the stuff I know now!

Continue reading

Lorna’s Bluemix Cheatsheet

I work for IBM which means I get to play with Bluemix, their cloud platform. I use this mostly from the commandline as the tools are great and I find it the easiest way to work – but I keep having to look up the commands I need so here’s my cheatsheet covering the stuff I use the most. It’s here for me to refer to easily but if it’s helpful to you too, then great! Continue reading

Surviving Git Submodules

I’m a fan of submodules in git, but sometimes it seems like I’m the only one! After having worked with this approach on a few projects, I’m coming to the conclusion that, like so many other things, it’s easy when you know how! So, I tried to take my handwavy explanation of how to work with submodules, and turn it into a handy diagram for you … Continue reading