jq is useful to slice, filter, map and transform structured json data.
brew install jq
| #!/bin/sh | |
| set -e | |
| ### Configuration ### | |
| SERVER=luca@example.com | |
| REMOTE_FOLDER=my_folder | |
| REMOTE_RESULTS=results | |
| EXCLUDE_FILES="--exclude=.*\ | |
| --exclude=build/" |
| package enum_example | |
| import ( | |
| "bytes" | |
| "encoding/json" | |
| ) | |
| // TaskState represents the state of task, moving through Created, Running then Finished or Errorred | |
| type TaskState int |
| #!/usr/bin/env bash | |
| # | |
| # Author: Stefan Buck | |
| # License: MIT | |
| # https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 | |
| # | |
| # | |
| # This script accepts the following parameters: | |
| # | |
| # * owner |
| get_latest_release() { | |
| curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api | |
| grep '"tag_name":' | # Get tag line | |
| sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value | |
| } | |
| # Usage | |
| # $ get_latest_release "creationix/nvm" | |
| # v0.31.4 |
| # Simple No-ip.com Dynamic DNS Updater | |
| # | |
| # By Nathan Giesbrecht (http://nathangiesbrecht.com) | |
| # | |
| # 1) Install binary as described in no-ip.com's source file (assuming results in /usr/local/bin) | |
| # 2) Run sudo /usr/local/bin/noip2 -C to generate configuration file | |
| # 3) Copy this file noip2.service to /etc/systemd/system/ | |
| # 4) Execute `sudo systemctl daemon-reload` | |
| # 5) Execute `sudo systemctl enable noip2` | |
| # 6) Execute `sudo systemctl start noip2` |
| // Traverses an arbitrary struct and translates all stings it encounters | |
| // | |
| // I haven't seen an example for reflection traversing an arbitrary struct, so | |
| // I want to share this with you. If you encounter any bugs or want to see | |
| // another example please comment. | |
| // | |
| // The MIT License (MIT) | |
| // | |
| // Copyright (c) 2014 Heye Vöcking | |
| // |