Skip to content

Instantly share code, notes, and snippets.

@danopia
Created March 3, 2018 03:22
Show Gist options
  • Save danopia/5e71b13518caf833ceffa35d228c740a to your computer and use it in GitHub Desktop.
Save danopia/5e71b13518caf833ceffa35d228c740a to your computer and use it in GitHub Desktop.
fish functions that integrate with stardust
function pizza_tracker --description "pizza_tracker <orderNum> <subId>"
set orderNum $argv[1]
set subId $argv[2]
set apiBase "https://papajohns-api-prod.apigee.net"
set apiUri "$apiBase/api/v1/orders/$orderNum/status?subId=$subId"
set state 'None'
while [ "$state" != "Completed" ]
set newState ( curl -s $apiUri | jq -r '.orderStatus' )
set estimatedDeliveryTimeHuman ( curl -s $apiUri | jq -r '.estimatedDeliveryTimeHuman' )
if [ "$state" != "$newState" ]
starnotify -irc-channel '##danopia' --stardust-base ws://apt:32031/~~export/ws -message "Pizza order #$orderNum is $newState - ETA $estimatedDeliveryTimeHuman"
end
set state "$newState"
sleep 1m
end
end
function sky-build-js
set origin (pwd)
cd /tmp/starshit; and rm -rf js-core /mnt/stardust/n/redis-ns/app-suite/js-core/combined.js; and starcp --stardust-base wss://stardust.apt.danopia.net/~~export/ws --src sd:/n/redis-ns/app-suite/js-core --dest js-core; and cd js-core; and rm -f combined.js; and echo **/*.js *.js; and cat **/*.js *.js > combined.js; and cp combined.js /mnt/stardust/n/redis-ns/app-suite/js-core/; and wc -l combined.js
cd $origin
end
# sky-checkout-directory 15efq2k7gdd devmode.cloud
function sky-checkout-directory
set dirId $argv[1]
set svc $argv[2]
cd /tmp/starshit; and rm -rf $svc; and starcp --stardust-base wss://stardust.apt.danopia.net/~~export/ws --src sd:/n/redis-ns/data/skychart/directories/$dirId --dest $svc; and cd $svc
end
function sky-checkout
set svc $argv[1]
cd /tmp/starshit; and rm -rf $svc; and starcp --stardust-base wss://stardust.apt.danopia.net/~~export/ws --src sd:/n/redis-ns/$svc --dest $svc; and cd $svc
end
function sky-upload
set path $argv[1]
cp $path /mnt/stardust/n/redis-ns/data/skychart/directories/i82t7se2f/blobs/uploads/
echo https://devmode.cloud/~dan/blobs/uploads/(basename $path)
end
function starop --description "starop <operation> [<extras...>]"
set op $argv[1]
set json "\"Op\":\"$op\""
if [ (count $argv) -gt 1 ]
for arg in $argv[2..-1]
set argName (echo $arg | cut -d '=' -f 1)
set argVal (echo $arg | cut -d '=' -f 2-)
switch $argName
case depth input
set json "$json,\"$argName\":$argVal"
case input-string
set json "$json,\"input\":{\"Name\":\"str\",\"Type\":\"String\",\"StringValue\":\"$argVal\"}"
case shapes
set list (echo $argVal | cut -d ',' --output-delimiter '","' -f 1-)
set json "$json,\"$argName\":[\"$list\"]"
case '*'
set json "$json,\"$argName\":\"$argVal\""
end
end
end
echo ">>> {$json}"
set response (curl -s -XPOST "$SKYLINK_URI" --data "{$json}" -H "Content-Type: application/json")
if [ (echo $response | jq '.Ok') = "true" ]
echo $response | jq '.Output'
else
echo "<<< operation failed"
echo $response | jq '.Output'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment