Skip to content

Instantly share code, notes, and snippets.

@ThePredators
Last active October 1, 2023 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThePredators/5b5e3e88715fbac180239b9be7b04caa to your computer and use it in GitHub Desktop.
Save ThePredators/5b5e3e88715fbac180239b9be7b04caa to your computer and use it in GitHub Desktop.

🔥 Query tools (CheatSheet)

HTML

Instal

brew install htmlq

Usage

Use Case 1:

<div id="button"><a href="http://google.com">Test Google</a></div>

Usage 1:

echo "<div id="button"><a href="http://google.com">Test Google</a></div>" | htmlq --attribute href a

Result :

http://google.com

CSS Selector :

Yaml

Install

brew install yq

Usage

Use Case 1:

Set runtime environment variables on a scheme in Xcode 

Usage 1:

XCSCHEME_PATH=.swiftpm/xcode/xcshareddata/xcschemes/$1.xcscheme
XML_PATH=.swiftpm/xcode/xcshareddata/xcschemes/generatedXML.xml
yq '.Scheme.LaunchAction.EnvironmentVariables.EnvironmentVariable |= [{"+key" : "DEBUG_LOG", "+value": "", "+isEnabled": "YES"}]' "$XCSCHEME_PATH" -p=xml  -o=xml > $XML_PATH && rm "$XCSCHEME_PATH" && mv $XML_PATH "$XCSCHEME_PATH"

JSON

Install

brew install jq

Usage

Use Case 1:

[{"name":"foo"},{"name":"bar"}]

Usage 1:

echo '[{"name":"foo"},{"name":"bar"}]' | jq -c '.[].name'

Result :

"foo"
"bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment