Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -e
# -----------------------------------------------------------------------------
# Open a bastion host connection
# -----------------------------------------------------------------------------
usage="$0 [region] [ssh args]"
# this variable could be "DC" (data center) instead.
REGION=$1
shift
fs.readFile path, (error, buffer) ->
unless error?
doSomethingWithContents buffer.toString()
else
handleError error
try
buffer = yield readFile path
doSomethingWithContents buffer.toString()
catch error
handleError error
github = resource "https://api.github.com/",
repo: (resource) ->
resource "repos/{owner}/{repo}/",
issues: (resource) ->
resource "issues",
create:
method: "post"
headers:
accept: "application/vnd.github.v3.raw+json"
expect: 201
try
{response, data} = yield github
.repo owner: "pandastrike", repo: "shred"
.list()
for issue in (JSON.parse yield data)
console.log issue
catch error
console.error error
do (data="") ->
response.on "data", (chunk) -> data += chunk
response.on "end" ->
try
for issue in (JSON.parse data)
console.log issue
catch error
console.error error
context.test "Using a full URL for a nested resource", (context) ->
{data} = yield github
.repo
.issues("https://api.github.com/repos/pandastrike/shred/issues")
.list()
assert.equal type(yield data), "array"
parallel = require "when/parallel"
resource = require "shred"
module.exports = (urls...) -> parallel (resource(url) for urls in url)
curl https://raw.githubusercontent.com/creationix/nvm/v0.17.3/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 0.11
nvm use 0.11