https://host/path. tjoho
https://host/path.ext tjoho
// Copyright 2009 The Go Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
// | |
// This is a fork of std/strconv ParseInt/ParseUint with a strict | |
// option to allow trailing invalid characters. | |
package strconvx | |
import ( |
meta: | |
id: mpeg_l3 | |
seq: | |
- id: sync | |
type: b11 | |
- id: mpeg_version | |
type: b2 | |
enum: mpeg_version | |
- id: layer | |
type: b2 |
# "01:02:03.45" -> 3723.45 | |
def from_duration: | |
( reduce (split(":") | reverse[]) as $p ( | |
{m: 1, n: 0}; | |
( .n = .n + ($p | tonumber) * .m | |
| .m *= 60 | |
) | |
) | |
| .n | |
); |
def from_syslog: | |
( split("\n") | |
| map( | |
( capture("^(?<ts>\\w{3}\\s+\\d{1,2} +[\\d:]+) (?<host>\\w+) (?<process>\\w+)\\[(?<pid>\\d+)\\]: (?<message>.*)$") | |
| .ts |= strptime("%b %d %H:%M:%S") | |
| .pid |= tonumber | |
) | |
) | |
); |
https://host/path. tjoho
https://host/path.ext tjoho
def _cvs_named_color_ranges: | |
{ all: [[0,255]] | |
, ascii: [[0,127]] | |
, nonascii: [[128,255]] | |
, null: [[0,0]] | |
, space: [[9,13]] | |
, print: [[32,126]] | |
}; |
# same as fromstream but with a prefix level, outputs [$prefix_path, $json_value], ... | |
# Usage: | |
# cat big | jq -L . --stream -n 'include "stream"; reduce fromstream(inputs; 1) as $pv ({}; $pv as [$p, $v] | .[$v.type] += 1)' | |
def streaks_by(f; g): | |
foreach ((g | ["v", .]), ["end"]) as $o ( | |
{ acc: null | |
, fv: null | |
, emit: null | |
}; |
Was created from https://github.com/wader/vscode-jq/blob/master/syntaxes/jq.tmLanguage.json |
plutil -convert xml1 file.tmLanguage.json -o file.tmLanguage | |
Open file.tmLanguage in Sublime and use Tools / Developer / "New Syntax from file.tmLanguage" | |
A new tab with file.subline-syntax should appear |
echo '[{"a":123, "b":123, "c": 2},' | jq --stream | jq -s 'reduce (.[] | select(.[1])) as $p ({}; setpath($p[0]; $p[1])?)' |