<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Patrick Van Stee on Medium]]></title>
        <description><![CDATA[Stories by Patrick Van Stee on Medium]]></description>
        <link>https://medium.com/@vanstee?source=rss-fd005a814ab0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IDPq-zYXdzsjVRtX.jpeg</url>
            <title>Stories by Patrick Van Stee on Medium</title>
            <link>https://medium.com/@vanstee?source=rss-fd005a814ab0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:02:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vanstee/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From CLI to Chat command in 5 minutes]]></title>
            <link>https://medium.com/operable-news/from-cli-to-chat-command-in-5-minutes-5b12f6af3a09?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b12f6af3a09</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[chatops]]></category>
            <category><![CDATA[chat-command]]></category>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Fri, 17 Feb 2017 19:06:01 GMT</pubDate>
            <atom:updated>2017-02-17T19:25:23.270Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2FKP2HPTYc8yunkw17DQw.jpeg" /></figure><p>I’m sure some of you heard about ChatOps and immediately thought, <em>“That sounds really cool. But, our team already built a bunch of command line tools to manage our infrastructure. You mean we have to rewrite all of those just to run them from chat?”</em> Well, for the most part, you’re not wrong. But, because <a href="https://github.com/operable/cog">Cog</a> lets you write commands in any language and commands can specify a docker container to run in, you can quickly wrap your existing tooling in a simple bash script in less than five minutes. To prove it, I’ll take dig, the DNS lookup command we&#39;re all familiar, and turn it into a chat command.</p><h3>Starting with the basics</h3><p>Let’s start with a simple invocation that passes a single name argument for our query. Here’s what that looks like on the command line:</p><pre>dig operable.io</pre><p>and from chat we want to be able to run:</p><pre>@cog dig operable.io</pre><p>If you’ve written a command-line script before, writing a Cog command should feel familiar with two main differences: command invocations from chat are parsed by Cog and all arguments and options are passed down to the executable as environment variables, and STDOUT can be specified as JSON or left as raw text and automatically converted to a list of strings. For all the details of how Cog commands work, you can take a look at <a href="http://docs.operable.io/sections/writing_a_command_bundle.html">Cog’s command documentation</a>, but that’s all you should need to know to get started.</p><p>So let’s write that command. We just want to take a single argument and pass that directly to dig as-is. To do that we&#39;ll need a simple wrapper bash script that takes the value of COG_ARGV_0 and passes it to dig. Open up dig.sh and paste the following:</p><pre>#!/usr/bin/env bash</pre><pre>dig &quot;$COG_ARGV_0&quot;</pre><p>Now, to install and run this command, we need to define a bundle config. Create a file named config.yaml and add the following:</p><pre>cog_bundle_version: 4<br>name: dig<br>version: &quot;0.1.0&quot;<br>description: DNS lookup utility<br>docker:<br>  image: dig<br>  tag: &quot;0.1.0&quot;<br>commands:<br>  dig:<br>    executable: &quot;/dig.sh&quot;<br>    description: DNS lookup utility<br>    rules:<br>    - allow</pre><p>This defines the dig bundle with a single command, also named dig. It also includes a docker image to run each command in. Let&#39;s build that next by creating a Dockerfile.</p><pre>FROM alpine:latest</pre><pre>RUN apk -U add bind-tools bash<br>COPY dig.sh /<br>RUN chmod +x /dig.sh</pre><p>All we’re doing here is installing dig (via the bind-tools package) and bash, copying over our newly created bash script named dig.sh and making that executable. Now the only thing we have left is to build this image and use the tag specified in our bundle config.</p><pre>docker build -t dig:0.1.0 .</pre><p>Ok, we’re ready to install it with cogctl assuming you’ve already got Cog up and running. (If not, do that real quick by following our <a href="http://docs.operable.io/sections/installation_guide.html">Installation Guide</a>)</p><pre>cogctl bundle install config.yaml --enable --relay-group default</pre><p>To check that everything worked. You should be able to run the command and see the following response in chat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*sw6VV3hH-wEzYQ5fhF6dxw.png" /></figure><h3>Adding options</h3><p>Ok now that we have the basics working, let’s add a couple of command options. We want to be able to set the name server and the type of record we’re querying for. You could use positional arguments instead but options give us a nice place to hang extra documentation and allow us to write rules against these values more easily (for instance we could only allow users with the admin permission to query for axfr records). To do this we’ll need to make changes to our script and bundle config.</p><p>Since Cog parses options for us, we don’t need to use getopts or anything, but we do need to transpose some environment variables into positional arguments that dig exepects; COG_OPT_SERVER to the first argument if it exists and COG_OPT_TYPE to the last argument if it exists. Our new dig.sh should look like this:</p><pre>#!/usr/bin/env bash</pre><pre>declare -a arguments</pre><pre>if [ &quot;$COG_OPT_SERVER&quot; != &quot;&quot; ]; then<br>  arguments+=(&quot;@${COG_OPT_SERVER}&quot;)<br>fi</pre><pre>if [ &quot;$COG_ARGV_0&quot; != &quot;&quot; ]; then<br>  arguments+=(&quot;$COG_ARGV_0&quot;)<br>fi</pre><pre>if [ &quot;$COG_OPT_TYPE&quot; != &quot;&quot; ]; then<br>  arguments+=(&quot;$COG_OPT_TYPE&quot;)<br>fi</pre><pre>dig &quot;${arguments[@]}&quot;</pre><p>We also need to tell Cog about these options in our bundle config.</p><pre>...<br>commands:<br>  dig:<br>    executable: &quot;/dig.sh&quot;<br>    description: DNS lookup utility<br><strong>    options:<br>      server:<br>        type: string<br>        required: false<br>      type:<br>        type: string</strong><br><strong>        required: false<br>    </strong>rules:<br>    - allow</pre><p>I’d recommend you always include a description and short_flag attribute for options, but I&#39;ve omitted them here to keep this short.</p><p>Now, we just need to reinstall our bundle and we can run our new command from chat.</p><pre>cogctl bundle install config.yaml --force</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*rmS1O-w7J2_63V7E_AdpRA.png" /></figure><h3>Emitting JSON</h3><p>To really make a Cog command useful, it needs to emit JSON data rather than strings. That way, you can use it in a pipeline and other commands can work with the data it outputs. For example, imagine you wanted to run a health check for all the IP addresses returned from a dig query. If dig returned JSON, we could pipe the output to a curlcommand to perform the healthcheck.</p><pre>dig operable.io | curl --write-out &quot;%{http_code}&quot; &quot;http://$ip&quot;</pre><p>Seems pretty useful, so let’s make our bash script print out some JSON. All we have to do is print “JSON” (and a newline) to STDOUT followed by a JSON list and Cog will do the rest. But, the output dig gives us is mostly tabular, which would be pretty annoying to parse, even if you&#39;ve memorized the sed manpage. Instead let&#39;s limit the output dig gives us with some extra options and parse the remaining table of answer data with jq.</p><p>Oh and first, well need to add jq to our Dockerfile real quick.</p><pre>RUN apk -U add bind-tools bash<strong> jq</strong></pre><p>And now for the command bits:</p><pre>#!/usr/bin/env bash</pre><pre>declare -a arugments</pre><pre><strong>arguments+=(&quot;+noall&quot;)<br>arguments+=(&quot;+answer&quot;)</strong></pre><pre>if [ &quot;$COG_OPT_SERVER&quot; != &quot;&quot; ]; then<br>  arguments+=(&quot;@${COG_OPT_SERVER}&quot;)<br>fi</pre><pre>if [ &quot;$COG_ARGV_0&quot; != &quot;&quot; ]; then<br>  arguments+=(&quot;$COG_ARGV_0&quot;)<br>fi</pre><pre>if [ &quot;$COG_OPT_TYPE&quot; != &quot;&quot; ]; then<br>  arguments+=(&quot;$COG_OPT_TYPE&quot;)<br>fi</pre><pre><strong>read -r -d &#39;&#39; filter &lt;&lt;&#39;EOF&#39;<br>split(&quot;\n&quot;) |<br>  .[0:-1] |<br>  map(split(&quot;\t&quot;)) |<br>  map({&quot;name&quot;: .[0], &quot;type&quot;: .[4], &quot;ip&quot;: .[5]})<br>EOF</strong></pre><pre><strong>echo &quot;JSON&quot;</strong></pre><pre><strong>dig &quot;${arguments[@]}&quot; |<br>  jq --raw-input --slurp &quot;$filter&quot;</strong></pre><p>That jq filter is a little intense, but now when you run your command, you should see glorious JSON. And only after a pretty conservative 30 lines of bash, we have dig in chat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*mkqnkdwvjCl9DsZgSSf5-w.png" /></figure><h3>Where to go from here</h3><p>There are a few things I didn’t have time for in this post: <a href="http://docs.operable.io/sections/writing_a_command_bundle.html#logging">logging from and debugging commands</a>, <a href="http://docs.operable.io/sections/permissions_and_rules.html">applying rules to command options and arguments</a>, and <a href="http://docs.operable.io/sections/templates.html">formatting JSON output with templates</a> just to start. But, we cover those in detail in our full-featured command walkthrough. So, check that out and let us know what commands you’ve ported over to Cog, or even upload them to <a href="https://warehouse.operable.io/">Warehouse</a> so the community can give them a shot.</p><h4>More ways to follow Cog:</h4><p><a href="http://operable.io/">Operable</a> | <a href="http://cog-book.operable.io/">Documentation</a> | <a href="http://twitter.com/operableinc">Twitter</a> | <a href="http://slack.operable.io/">Slack</a> | <a href="http://eepurl.com/ce6Sr1">Newsletter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b12f6af3a09" width="1" height="1" alt=""><hr><p><a href="https://medium.com/operable-news/from-cli-to-chat-command-in-5-minutes-5b12f6af3a09">From CLI to Chat command in 5 minutes</a> was originally published in <a href="https://medium.com/operable-news">Operable News</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bringing Unix classics, tee and cat, to chat]]></title>
            <link>https://medium.com/operable-news/bringing-unix-classics-tee-and-cat-to-chat-c377d3003175?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c377d3003175</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[chatops]]></category>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[unix-pipeline]]></category>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Fri, 03 Feb 2017 15:36:47 GMT</pubDate>
            <atom:updated>2017-02-03T15:47:52.139Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a2bf-szT-eFmr7GG5rxykQ.jpeg" /></figure><p>If you’re familiar with Unix I know you’ve used the cat command to read a file at the start of a pipeline. And, if you’ve ever typo’d something at the end of a pipeline and have had to rerun it only to wait another 3 hours for it to complete, you probably swear by tee. If you haven’t encountered it yet, <a href="https://en.wikipedia.org/wiki/Tee_(command)">take a second and read about the </a><a href="https://en.wikipedia.org/wiki/Tee_(command)">tee command</a>. I’m sure it’ll save you some angry up-arrow keypresses in the future.</p><p>So, tee and cat. Useful right? But they were both built to deal with files, on a disk… which we don’t have in chat. So how is this useful as a chat command?</p><p>Since <a href="https://github.com/operable/cog">Cog</a> was built to run commands in pipelines just like Unix, it’d still be nice to be able to save and retrieve intermediate pipeline output. But you’re right; we don’t have files in chat. However, Cog does have a <a href="http://docs.operable.io/sections/services.html?highlight=memory#memory-service">Memory Service</a>, a built-in key-value store for use by commands. So, instead, the tee and cat commands use that and take a key as an argument. Here’s a simple example to show you what that looks like:</p><pre>@cog ec2:instance search &quot;instance-state-name=running&quot; | tee instances | table instance_id instance_type</pre><pre>@cog cat instances | ec2:instance reboot $instance_id</pre><p>Above we’re getting a list of currently running instances, saving that list with the key instances, and then reviewing them in a table. Once we’re sure everything is safe to reboot, we retrieve that list of instances to start our pipeline and reboot each instance.</p><p>But, wait there’s more. We can also use cat to append or modify previously saved output. As an example, let’s say we want to build up a list of instances to reboot across multiple commands. We can list and store all instances from the us-east-1 region just as before. Then, we can list and <strong>append </strong>all instances from the us-west-1 region before storing the output under the instances key again.</p><pre>@cog ec2:instance list --region us-east-1 | tee instances</pre><pre>@cog ec2:instance list --region us-west-1 | cat --append instances | tee instances</pre><pre>@cog cat instances | ec2:instance reboot $instance_id</pre><p>Depending on how you need to construct your output data, cat has flags for --append, --merge, and --insert. Read more about how to use them and more examples by running @cog help cat and @cog help tee including tips on constructing rules for authorizing access teeing and cating specific keys.</p><p>Also, if you’ve found a clever use for these commands in one of your workflows, leave a comment here or tweet <a href="https://twitter.com/operableinc">@OperableInc</a>.</p><h4>More ways to follow Cog:</h4><p><a href="http://operable.io/">Operable</a> | <a href="http://cog-book.operable.io/">Documentation</a> | <a href="http://twitter.com/operableinc">Twitter</a> | <a href="http://slack.operable.io/">Slack</a> | <a href="http://eepurl.com/ce6Sr1">Newsletter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c377d3003175" width="1" height="1" alt=""><hr><p><a href="https://medium.com/operable-news/bringing-unix-classics-tee-and-cat-to-chat-c377d3003175">Bringing Unix classics, tee and cat, to chat</a> was originally published in <a href="https://medium.com/operable-news">Operable News</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reusable, Repeatable CloudFormation with Cog]]></title>
            <link>https://medium.com/operable-news/reusable-repeatable-cloudformation-with-cog-e736f608da19?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e736f608da19</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[chatops]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Thu, 01 Dec 2016 19:29:54 GMT</pubDate>
            <atom:updated>2017-03-08T18:19:49.557Z</atom:updated>
            <content:encoded><![CDATA[<p>We <a href="https://blog.operable.io/quick-interview-4-cog-chatops-at-kickstarter-3b2450f7a054">recently helped Kickstarter move their CloudFormation workflow over to Cog</a>. Our initial focus was on making the same sorts of commands that are available via the AWS command line utility available in <a href="https://github.com/operable/cog">Cog</a>. Moving existing CloudFormation commands to chat immediately provided some improvements: team visibility, shared configuration, and fine-grained permissions, just to name a few.</p><p>We always knew that duplicating the functionality in chat was only the first step and after using these commands in practice, <a href="https://medium.com/u/5b612cf36224">Kevin Smith</a> and <a href="https://medium.com/u/ae2630ddde1a">Mark Imbriaco</a> optimized the workflow for chat by introducing some new concepts. The main problem was that requiring users to provide all inputs when creating stacks quickly becomes cumbersome, even for only moderately complex CloudFormation templates. The solution was to decouple stack specification from stack creation through two new abstractions: default sets and stack definitions.</p><p>Before we get into the details of how to manage stack definitions, here’s what creating a stack now looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*7SJLgUaCarobVpiKxXvcMg.png" /><figcaption>Creating a definition and stack using the cfn bundle</figcaption></figure><h4>Stack Definitions</h4><p>Instead of providing the template, parameters, and tags all directly to the stack create command, we bundle all of these up into a definition, which can then be used and reused with stack create and changeset create commands. This allows your team to split up the responsibilities of defining stacks and creating them. You could even only grant the permission to create stacks to a small subset of users, but allow anyone to define a stack.</p><h4>Default Sets</h4><p>Even with stack definitions, it would still be fairly tedious to define each parameter and tag as arguments to the definition create command, especially when many of these parameters like VPC IDs are often shared between stacks. To simplify this we created default sets, named sets of parameters and tags which can be reused across stack definitions. They’re meant to provide a base set of parameters as you can easily override specific parameters and tags when creating the definition or even when creating the stack.</p><h4><strong>Versioning Your Infrastructure</strong></h4><p>One thing we haven’t touched on is where these definitions and default sets are stored. We strongly believe that ChatOps must fit into your workflow, not be another silo. With this firmly in mind, we designed the cfn bundle to integrate with the place where engineers already store configuration and automation artifacts: Git repositories.</p><p>We allow you to configure a git repository which will be the canonical store for all of your templates, defaults files, and stack definitions. Best of all, the integration goes both ways. Not only are files you edit and commit outside of chat available to the chat commands, when you create a definition or default set in chat it is also committed to the repository.</p><p>And taking it a step further, stack definitions are intended to be immutable. Rather than updating a definition, you create a new one with the same name that gets its own timestamped directory which includes a point in time snapshot of the template, all parameters and tags from defaults, any override parameters and tags, and a finalized set of parameters. You can be confident that you know exactly what has been deployed to production, which should also make auditing and debugging much more straightforward.</p><h4>Learn More</h4><p>If you’d like to hear more about the AWS CloudFormation bundle for Cog, Mark Imbriaco put together a 6 minute screencast which demonstrates the basics of the bundle in action.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FbYb-Z52oCT0%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbYb-Z52oCT0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbYb-Z52oCT0%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3808042b36502bd7c512ff3837f8bd11/href">https://medium.com/media/3808042b36502bd7c512ff3837f8bd11/href</a></iframe><p>We intend to publish additional content about ways to make use of the bundle in practice, tips for managing access control and delegating access to specific stacks via Cog rules, and more over the coming weeks.</p><p>All of this is now available in the <a href="https://bundles.operable.io/bundles/cfn/latest">0.5.0 version</a> of the cfn bundle. We’ll be continuing to add to and improve this workflow as well. So let us know what is working for you and what aspects of using CloudFormation are still a pain.</p><p>If you’d like to know more about using Cog with CloudFormation or are interested in exploring ways that Operable can help you be successful with ChatOps, please <a href="/service/mailto:info@operable.io">get in touch</a>!</p><h4>More ways to follow Cog:</h4><p><a href="http://operable.io/">Operable</a> | <a href="http://cog-book.operable.io/">Documentation</a> | <a href="http://twitter.com/operableinc">Twitter</a> | <a href="http://slack.operable.io/">Slack</a> | <a href="http://eepurl.com/ce6Sr1">Newsletter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e736f608da19" width="1" height="1" alt=""><hr><p><a href="https://medium.com/operable-news/reusable-repeatable-cloudformation-with-cog-e736f608da19">Reusable, Repeatable CloudFormation with Cog</a> was originally published in <a href="https://medium.com/operable-news">Operable News</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-Language ChatOps With Cog]]></title>
            <link>https://medium.com/operable-news/multi-language-chatops-with-cog-e91e53902e6d?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e91e53902e6d</guid>
            <category><![CDATA[chatops]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Wed, 16 Nov 2016 16:31:57 GMT</pubDate>
            <atom:updated>2016-11-16T16:31:57.284Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve read through the Cog Book chapter <a href="https://cog-book.operable.io/#_building_command_bundles">“Building Command Bundles”</a> you already know that you can write Cog commands in any language. All you need is the ability to read environment variables, read from STDIN, and write to STDOUT. We’ve even joked around the office about writing one in FORTRAN, or worse, INTERCAL. But let’s do something a bit more useful and run through building a simple echo command in each language from the book <a href="https://pragprog.com/book/btlang/seven-languages-in-seven-weeks">“Seven Languages in Seven Weeks”</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Qgr_gVW55EEgwdeoumQuQ.png" /></figure><h4><a href="https://github.com/operable/seven-bundles/tree/master/ruby">Ruby</a></h4><pre>#!/usr/bin/env ruby</pre><pre>argc = ENV[&quot;COG_ARGC&quot;].to_i<br>argv = argc.times.map { |i| ENV[&quot;COG_ARGV_#{i}&quot;] }<br>puts argv.join(&quot; &quot;)</pre><h4><a href="https://github.com/operable/seven-bundles/tree/master/io">Io</a></h4><pre>#!/usr/bin/env io</pre><pre>Range</pre><pre>argc := System getEnvironmentVariable(&quot;COG_ARGC&quot;) asNumber<br>args := 0 to(argc — 1) map(argv, System <br>  getEnvironmentVariable(&quot;COG_ARGV_#{argv}&quot; interpolate))<br>args join(&quot; &quot;) println</pre><h4><a href="https://github.com/operable/seven-bundles/tree/master/prolog">Prolog</a></h4><pre>#!/usr/bin/env swipl</pre><pre>:- initialization main.</pre><pre>argc(Argc) :-<br>  getenv(&#39;COG_ARGC&#39;, ArgcAtom),<br>  atom_number(ArgcAtom, Argc).</pre><pre>range(N, Range) :-<br>  N1 is N - 1,<br>  findall(M, between(0, N1, M), Range).</pre><pre>argAtom(N, ArgAtom) :-<br>  format(atom(ArgAtom), &#39;COG_ARGV_~d&#39;, [N]).</pre><pre>argAtoms(Range, ArgAtoms) :-<br>  maplist(argAtom, Range, ArgAtoms).</pre><pre>args(ArgAtoms, Args) :-<br>  maplist(getenv, ArgAtoms, Args).</pre><pre>main :-<br>  argc(Argc),<br>  range(Argc, Range),<br>  argAtoms(Range, ArgAtoms),<br>  args(ArgAtoms, Args),<br>  atomic_list_concat(Args, &#39; &#39;, ArgsString),<br>  write(ArgsString),<br>  nl,<br>  halt.</pre><h4><a href="https://github.com/operable/seven-bundles/tree/master/scala">Scala</a></h4><pre>#!/usr/bin/env scala</pre><pre>import scala.sys</pre><pre>object Echo extends App {<br>  val argc = sys.env(&quot;COG_ARGC&quot;).toInt<br>  val argv = (0 to argc — 1).map(i =&gt; sys.env(s&quot;COG_ARGV_$i&quot;))<br>  println(argv.mkString(&quot; &quot;))<br>}</pre><h4><a href="https://github.com/operable/seven-bundles/tree/master/erlang">Erlang</a></h4><pre>#!/usr/bin/env escript</pre><pre>argv(0, Argv) -&gt;<br>  [os:getenv(&quot;COG_ARGV_0&quot;)|Argv];</pre><pre>argv(N, Argv) -&gt;<br>  Arg = os:getenv(io_lib:format(&quot;COG_ARGV_~p&quot;, [N])),<br>  argv(N — 1, [Arg|Argv]).</pre><pre>main(_) -&gt;<br>  {Argc, []} = string:to_integer(os:getenv(&quot;COG_ARGC&quot;)),<br>  Argv = argv(Argc — 1, []),<br>  io:fwrite(&quot;~s~n&quot;, [string:join(Argv, &quot; &quot;)]).</pre><h4><a href="https://github.com/operable/seven-bundles/tree/master/clojure">Clojure</a></h4><pre>#!/usr/bin/env java -cp clojure.jar clojure.main</pre><pre>(def argc<br>  (System/getenv &quot;COG_ARGC&quot;))</pre><pre>(defn argv [n]<br>  (System/getenv (str &quot;COG_ARGV_&quot; n)))</pre><pre>(def args<br>  (map argv (range (Integer/parseInt argc))))</pre><pre>(println (clojure.string/join &quot; &quot; args))</pre><h4><a href="https://github.com/operable/seven-bundles/tree/master/haskell">Haskell</a></h4><pre>#!/usr/bin/env runhaskell</pre><pre>import System.Environment<br>import Text.Printf<br>import Control.Monad</pre><pre>main = do<br>  argcIO &lt;- getEnv &quot;COG_ARGC&quot;<br>  let argc = read argcIO :: Integer</pre><pre>  argv &lt;- forM [0..argc — 1] $ \n -&gt; do<br>    getEnv (printf &quot;COG_ARGV_%d&quot; n)</pre><pre>  putStrLn (unwords argv)</pre><h4>Recap</h4><p>That was actually pretty fun to work on. Although, my Prolog is super rusty and I had never written Haskell before. Hopefully, that’s not too obvious. But, either way, this should give you a good idea of how straight forward it is to write a command in any language you’re familiar with. Now, not every language is best suited for Cog commands. Keep in mind that Cog will run your program for each item in a pipeline. So, the slow startup time of a Clojure program, for example, can really hurt performance. Also, it might be easy to write an echo command in any language, but for most commands that need to be used in a pipeline, you’re going to want to return JSON. That means languages with built-in map data types and a JSON library handy are going to be far easier to work with. But, if you do decide to write something in a crazy language we’d love to hear about it.</p><p>Oh, and if you’re just now learning about how Cog commands work and want to learn more, read through our chapter on <a href="https://cog-book.operable.io/#_building_command_bundles">“Building Command Bundles”</a> which will walk you through wrapping up a simple Bash script as a command all the way to writing your own Twitter bundle in Ruby.</p><p>Also, for anyone who wants to take a look at the Dockerfile and config.yaml for each of these commands and try to install them, here you go: <a href="https://github.com/operable/seven-bundles">https://github.com/operable/seven-bundles</a></p><p><em>PS: Ok, I had to give </em><a href="https://github.com/operable/seven-bundles/tree/master/fortran"><em>FORTRAN</em></a><em> a try.</em></p><pre>      PROGRAM echo<br>        CHARACTER(LEN=1) argc_string<br>        CHARACTER(LEN=10) argv_name<br>        CHARACTER(LEN=255) argv<br>        INTEGER argc, i</pre><pre>        CALL GET_ENVIRONMENT_VARIABLE(&quot;COG_ARGC&quot;, argc_string)<br>        READ(argc_string, &quot;(I1)&quot;) argc</pre><pre>        DO i = 0, argc<br>          WRITE(argv_name, &quot;(A9, I1)&quot;) &quot;COG_ARGV_&quot;, i<br>          CALL GET_ENVIRONMENT_VARIABLE(argv_name, argv)<br>          WRITE(*, &quot;(A)&quot;, ADVANCE=&quot;NO&quot;) TRIM(argv)<br>          WRITE(*, &quot;(A)&quot;, ADVANCE=&quot;NO&quot;) &quot;&quot;<br>        END DO</pre><pre>        WRITE(*, &quot;(A)&quot;) &quot;&quot;<br>      END PROGRAM echo</pre><p>Well, that wasn’t half bad. I really hope you didn’t end up here from a Google search of “Write Cog commands in FORTRAN”, but at least now you know it’s possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e91e53902e6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/operable-news/multi-language-chatops-with-cog-e91e53902e6d">Multi-Language ChatOps With Cog</a> was originally published in <a href="https://medium.com/operable-news">Operable News</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pumpkin Spice Cog]]></title>
            <link>https://medium.com/operable-news/pumpkin-spice-cog-4b0d29f2fb76?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b0d29f2fb76</guid>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[psl]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[chatops]]></category>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Tue, 11 Oct 2016 16:14:22 GMT</pubDate>
            <atom:updated>2016-10-11T16:14:22.791Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uuMY8adsBhRFjcleywcuzA.png" /></figure><p>It’s time for another Cog release! Cog 0.15 is chock full of goodness including support for updating config.yaml in-place for faster bundle development, documentation updates, and a slew of bug fixes. HipChat support also returns in this release, with a completely rebuilt adapter that is fully supported. As always, see the <a href="https://github.com/operable/cog/blob/v0.15.0/CHANGELOG.md">changelog</a> for all the details.</p><p>We’re also proud to announce the debut of <a href="https://bundles.operable.io/">Warehouse</a>, the easiest way to find and install Cog bundles.</p><h3>What is Warehouse?</h3><p>Have you been looking for bundles from other Cog users? Or maybe you’ve wanted to share a bundle you’ve written? That’s why we created <a href="https://warehouse.operable.io/">Warehouse</a>, a centralized directory for Cog bundles.</p><h3>Cog Integration</h3><p>We also taught Cog about Warehouse so installing bundles is a snap either from cogctl or from the bundle command right in chat.</p><p>Want to use PagerDuty from chat?!bundle install pagerduty Done!</p><p>Need to manage your Heroku deployments from chat? !bundle install heroku and you’re ready to go.</p><h3>Check It Out</h3><p>Head over to <a href="https://warehouse.operable.io/">Warehouse</a>, log in with your Github account, and upload the bundles you’ve been working on. We have more features planned for for future releases, so keep an eye out for updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NPpSlgQoCNS4JK53JOtz5A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b0d29f2fb76" width="1" height="1" alt=""><hr><p><a href="https://medium.com/operable-news/pumpkin-spice-cog-4b0d29f2fb76">Pumpkin Spice Cog</a> was originally published in <a href="https://medium.com/operable-news">Operable News</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[… and that’s why you should always ask for an email address]]></title>
            <link>https://medium.com/@vanstee/and-that-s-why-you-should-always-ask-for-an-email-address-6a2deecd2d46?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a2deecd2d46</guid>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Wed, 25 Mar 2015 14:30:57 GMT</pubDate>
            <atom:updated>2015-03-25T14:32:36.440Z</atom:updated>
            <content:encoded><![CDATA[<h2>…and that’s why you always ask for an email</h2><p>Had a great time launching <a href="http://firesize.com/">Firesize</a> over the weekend, which was built by the community on <a href="https://assembly.com/firesize">Assembly</a>. We were well received on <a href="https://news.ycombinator.com/item?id=9243085">HackerNews</a> and <a href="http://www.producthunt.com/posts/firesize">ProductHunt</a>, which lead to a bunch of really great feedback and a decent bit of traffic. Here’s what almost 12,000 sessions in our Google Analytics account looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*FO12RNYDUbfZ4owlaW-HKQ.png" /></figure><p>It seemed like people really liked the idea and that it fit a real need. But, as I was watching visits come in, barely any of them we’re converting into signups. Out of the 10,000 users that visited <a href="http://firesize.com/">firesize.com</a>, we only had 40 Heroku accounts try out the addon. I knew something was wrong, and quickly realized the mistake. <strong>We launched only as a Heroku add-on, without our own signup form. </strong>In efforts to cut scope and ship as soon as possible, I lowered the priority of the signup and login forms in favor of just being an addon.</p><p>First, I’d like to point out that being a Heroku add-on is great. It’s the perfect distribution channel for developer services. Users don’t have to type in their payment details for yet another subscription service. And, we don’t have to worry about account signups or payments. But launching <strong>only</strong> as a Heroku add-on was a problem for a lot of potential users. They wanted to use our service, but couldn’t. I watched over 20 emails come through our <a href="https://helpful.io/">Helpful</a> inbox, all asking for access. Here were the two main reasons:</p><ol><li>They weren’t Heroku users.</li><li>They used Heroku in the EU region (we were only available in the US)</li></ol><p>Ok so that was a failed experiment. <strong>Tough lesson learned.</strong> We should have spent time building our own login and subscription handling code or at least made the add-on available in Europe.</p><p>But what’s worse is that now, even if we do add our own signup form, <strong>we have no way re-engaging people who wanted to use our product</strong> but bailed once they realized they had to be a Heroku user. If 20 users took the time and effort to send me an email asking for access, I’m guessing we lost at least 200 potential signups.</p><blockquote><strong><em>So, no matter what you’re launching, </em>always<em> let people give you their email address. Never turn away interested users.</em></strong></blockquote><p>Oh and if were one of those bummed-out, non-Heroku users, I added a signup form to Firesize just for you. So, <a href="http://firesize.com/signup">go signup</a> and check it out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*k2qEl-Y0HQiPiwW1JRBk5Q.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a2deecd2d46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unix Directories]]></title>
            <link>https://medium.com/software-craftsmanship/unix-directories-89cc3dd2e29e?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/89cc3dd2e29e</guid>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Thu, 18 Apr 2013 01:16:44 GMT</pubDate>
            <atom:updated>2013-04-18T01:16:44.832Z</atom:updated>
            <content:encoded><![CDATA[<h3>If you&#39;ve spent any time on a Unix system, you&#39;ve probably come across a directory name that you didn&#39;t understand.</h3><p>Here&#39;s the list of most common directory names and a little bit about each of them.</p><h3>/bin Binaries</h3><p>All the very basic commands used by all users on the system. This is where ls, cat, and sh live.</p><h3>/boot Boot</h3><p>Unsurprisingly contains everything needed to boot.</p><h3>/dev Device</h3><p>Special, device related files. This is where file descriptors, nulland urandom live.</p><h3>/etc Etcetera</h3><p>Configuration files and should not include any executable programs. This is where motd, passwd, and profile live.</p><h3>/home Home</h3><p>User home directories, used for user specific configuration and documents.</p><h3>/lib Library</h3><p>Shared libraries need for booting and running system commands.</p><h3>/mnt Mount</h3><p>Mount points for other file systems.</p><h3>/opt Optional</h3><p>Add-on software packages.</p><h3>/sbin System Binaries</h3><p>Commands like /bin which are only used by administrators. This is where ifconfig, mount, and shutdown live.</p><h3>/tmp Temporary</h3><p>Files that are temporarily used by other programs. Files in this directory are not required to be preserved after the program that created them has finished executing.</p><h3>/usr User or User System Resources</h3><p>Executables, libraries, configuration files, and C header files which are not necessary to the operating system. These files are organized in a hierarchy with names similar to those in the root file system. Historically, this was where the user home directories lived, hence the name.</p><h3>/var Variable</h3><p>Variable data files. This is where you should put lock files, log files, and temporary files that need to be preserved.</p><p>To find out more about the specific directory structure on your file system, checkout the hier manpage. You can also read through the <a href="http://www.pathname.com/fhs/pub/fhs-2.3.pdf">Filesystem Hierarchy Standard</a> for more information.Type your post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89cc3dd2e29e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/software-craftsmanship/unix-directories-89cc3dd2e29e">Unix Directories</a> was originally published in <a href="https://medium.com/software-craftsmanship">Notes on Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[History of the Text Editor]]></title>
            <link>https://medium.com/software-craftsmanship/history-of-the-text-editor-6f144e7681b2?source=rss-fd005a814ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f144e7681b2</guid>
            <dc:creator><![CDATA[Patrick Van Stee]]></dc:creator>
            <pubDate>Wed, 17 Apr 2013 18:34:21 GMT</pubDate>
            <atom:updated>2013-04-17T18:34:21.753Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writing software today is nothing like it was back in the 70&#39;s, when using an &quot;on-line&quot; editor meant viewing one line of a program at a time.</h3><p>Since even today&#39;s editors borrowed ideas from the very first ones, here&#39;s a quick overview of the origins of the text editor and how the idea of editing text has evolved since punch cards.</p><p>Both the popularity of time-sharing and the teletype made editing a program possible for the first time. Instead of feeding in punch cards, you could use an electromechanical typewriter-printer combo to communicate with a computer directly, in realtime. But, with limited memory and slow feedback, the first text editors were still pretty close to punching holes in cards.</p><h3>1965</h3><p>The &quot;Quick Editor&quot;, qed for short, was one of the very first line based editors. Ken Thompson, who helped write the Unix operating system, ended up writing his own version that made significant improvements like searching with regular expressions, text buffers, and macros when he started working at Bell Labs.</p><h3>1971</h3><p>As qed because increasingly complex and as new hardware needed new implementations, Ken eventually created a simplified version named ed, which shipped with the first version of Unix. It kept the basic line editing paradigm but cut down on supported regular expressions and removed the use of multiple buffers. Even though it was simplified, the commands were still difficult to remember which spurred a few modified versions, most importantly: em and ex.</p><h3>1976</h3><p>With the increasing popularity of cheaper CRT displays, most terminals had enough real estate to display more than one line at a time. Bill Joy, borrowing ideas from em and Bravo, added a screen mode to ex which later became vi.</p><p>The same year the first version of emacs, was released, with functionality similar to vi, but was actually based on the Eeditor and not a descendant of ed.</p><p>The early versions of emacs had more powerful macros and unified commands, but the use of vi spread quicker, most likely due to Bill&#39;s involvement in Unix.</p><h3>1985</h3><p>As the first GNU project, Richard Stallman wrote his own free version of emacs with a full LISP implementation. It was eventually ported to Unix and other operating systems, making it the most popular implementation. It&#39;s still actively maintained today.</p><h3>1991</h3><p>Written by Bram Moolenaar, vim, short for Vi Improved, was originally released for the Amiga and then later released on almost all Unix distributions. It included a wide number of enhancements like plugins, syntax highlighting, better macro support, and a help module. The last major release was in 2010, while new plugins and add-ons are still being developed.</p><h3>Today</h3><p>Since then, editors got a lot fancier with GUI windows, integrated compilers and built-in debugging support. However, these older text based editors are popular among developers, which, while harder to learn, are still more efficient at navigating source code.</p><p>It has been over 20 years since the youngest of these editors was released, but you would be surprised by how many places emacs shortcut keys still work, and how many developers still use an 80-character line limit now that we&#39;re no longer limited by the number of columns on a punch card.Type your post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f144e7681b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/software-craftsmanship/history-of-the-text-editor-6f144e7681b2">History of the Text Editor</a> was originally published in <a href="https://medium.com/software-craftsmanship">Notes on Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>