Skip to content

Instantly share code, notes, and snippets.

View randsina's full-sized avatar

Roman Vakulchik randsina

  • Studytube
  • Amsterdam, Netherlands
View GitHub Profile
@randsina
randsina / sorting-aws-cli-describe-images-output.md
Created August 3, 2021 17:28 — forked from michalstala/sorting-aws-cli-describe-images-output.md
How to sort AWS CLI describe-images output using jd

As an example query AWS for a list of all NAT Instance AMIs:


aws ec2 describe-images --filter Name="owner-alias",Values="amazon" --filter Name="name",Values="amzn-ami-vpc-nat*" --region us-west-2 | jq '.Images | sort_by(.CreationDate)'

If only specific fields are required to print into output:

[#<Book id: 5811, name: "Concepts of Biology | Interactive Edition 2017-08...", school_id: nil, user_id: 14282>,
#<Book id: 6167, name: "Introducing Marketing", school_id: 484, user_id: 14696>,
#<Book id: 5787, name: "Managing Money 2017-08-10", school_id: 521, user_id: nil>,
#<Book id: 5786, name: "Contending With Change 2017-08-10", school_id: 521, user_id: nil>,
#<Book id: 5788, name: "Dealing With Data 2017-08-10", school_id: 521, user_id: nil>,
#<Book id: 5789, name: "Conquering Quantity 2017-08-10", school_id: 521, user_id: nil>,
#<Book id: 5793, name: "Concepts Of Biology 2017-08-13", school_id: nil, user_id: 2>,
#<Book id: 5794, name: "Introductory Business Statistics 2017-08-13", school_id: nil, user_id: nil>,
#<Book id: 5795, name: "Introductory Business Statistics 2017-08-13", school_id: nil, user_id: 13749>,
#<Book id: 5796, name: "Psychology | Interactive Edition 2017-08-13", school_id: nil, user_id: 2>,
{
"data_feed_items" : {
"aliases" : { },
"mappings" : {
"data_feed_item" : {
"dynamic" : "strict",
"_all" : {
"enabled" : false
},
"properties" : {
{
"bennett_test_data_feed_5" : {
"aliases" : { },
"mappings" : {
"data_feed_item" : {
"properties" : {
"brand" : {
"type" : "string"
},
"category" : {
curl -XPUT 'http://localhost:9200/bennett_test_data_feed_4' -d '{
"settings" : {
"index" : {
"refresh_interval" : "-1",
"number_of_shards" : "3",
"query" : {
"default_field" : "offer_title"
},
"analysis" : {
"filter" : {
[2017-10-16 13:50:21,117][DEBUG][action.search ] [node3-231-17] [bennett_test_data_feed_4][2], node[9X0mCp7oQHCkHP_jG7akYg], [P], v[2], s[STARTED], a[id=BTt2_SGjTLSXmkPh2x3VOQ]: Failed to execute [org.elasticsearch.action.search.SearchRequest@1dc190c2] lastShard [true]
RemoteTransportException[[node3-231-17][10.0.0.17:9300][indices:data/read/search[phase/query]]]; nested: SearchParseException[failed to parse search source [{"query":{"bool":{"should":[{"match":{"offer_description":{"query":"slipped jeans derp dubstep il zerg ie che no clothing strictly per modding ikke craigslist snap sliding dresses toe pants i7 wear damnit dress fanbase tanky pull remix playstyle mobo bottom esque outfits :\\ slide un cunts imgur reposts fuckin inbox","boost":10}}},{"match":{"field":{"query":"ollieroo-50-300pk-non-slip-velvet-clothes-hangers-purple-300pk","boost":5}}},{"match":{"field":{"query":".","boost":5}}}]}},"aggregations":{"manufacturers":{"terms":{"field":"manufacturer.raw"}},"merchants":{"terms":{"field":
settings(index: {
refresh_interval: '-1',
number_of_shards: '3',
number_of_replicas: '0',
query: {
default_field: 'offer_title'
}
},analysis: {
filter: {
stemming: {
aggregations(manufacturers: {
terms: {
field: 'manufacturer.raw'
}
}, merchants: {
terms: {
field: 'merchant.raw'
}
}, categories: {
terms: {
209.126.136.4 - - [27/Sep/2017:09:46:44 +0000] "GET / HTTP/1.1" 401 597 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
185.69.69.81 - - [27/Sep/2017:10:06:31 +0000] "GET / HTTP/1.1" 401 195 "-" "curl/7.17.1 (mips-unknown-linux-gnu) libcurl/7.17.1 OpenSSL/0.9.8i zlib/1.2.3"
169.54.233.125 - - [27/Sep/2017:11:53:48 +0000] "GET / HTTP/1.0" 401 195 "-" "Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0"
60.191.38.77 - - [27/Sep/2017:13:24:44 +0000] "GET / HTTP/1.1" 401 195 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0"
185.70.187.189 - - [27/Sep/2017:15:21:15 +0000] "\x03\x00\x00*%\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Test" 400 173 "-" "-"
185.70.187.189 - - [27/Sep/2017:15:21:16 +0000] "\x03\x00\x00*%\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Test" 400 173 "-" "-"
180.97.106.39 - - [27/Sep/2017:19:10:43 +0000] "HEAD http://180.163.113.82/check_proxy HTTP/1.1" 401 0 "-" "-"
170.150
> let a = {'b': '1'}
undefined
> let k = 'c'
undefined
> let b = a[key] || 'def'
ReferenceError: key is not defined
at repl:1:11
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:73:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)