Author: johayek
-
Bash: [[…]]: the pattern, quoting, …
- https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html — look for the very helpful xxx.txt example!
I was tempted to put the entire pattern in (double) quotes. But that’s not Bash style. You can “certainly” put literal parts in quotes, but regexp parts do not belong in quotes — quotes are good for protecting, amongst other aspects: protecting against interpretation as regular expression. That’s different to usual programming languages. Usually you do sort of put your entire regular expression in “borders” — in Bash you don’t.
This example resp. advice is actually quite wrong (but I am not able to comment there — I have not earned enough reputation on stackoverflow.com yet):
- https://stackoverflow.com/a/13542845/3119172 – the pattern shown there must not be put in quotes
-
Stack Overflow: find and restore a deleted file in a Git repository
Amongst all the suggestions there I had to find something, that fits my scenario.
First find the commit ID, that includes the deletion of the resp. file (use either
--summaryor --raw!) (git logdisplays its output through $PAGER, presumably the utilityless):$ git log --summary # find the file and the commit ID (in the pager) $ git log --raw # find the file and the commit ID (in the pager)
Now use the
commit_IDto specify, that you are interested in a commit to that file but before thatcommit_ID, therefore the “^” aftercommit_ID:$ git checkout commit_ID^ THE_FILE
…
-
Btu (British thermal unit), Joule, Watt hours
- https://en.wikipedia.org/wiki/British_thermal_unit
- https://de.wikipedia.org/wiki/British_thermal_unit
- 1 J = 1 Ws
- 3600 MJ (megajoules) = 1 MWh
thm …Btu …joules Ws Wh kWh Mwh 1 J 1 3.6 MJ 1 0.001 3,600 MJ 1 1 Btu 1.05505585257348 kJ 0.293,071,070,159,3 1 MBtu 1,055.05585257348 kJ 1 thm 100 MBtu 105.505585257348 MJ 10 thm 1 MMBtu 1,055.05585257348 MJ 293,071.070,159.3 0.293,071,070,159,3 -
Git SCM: diff between two given tags
A couple of interesting variants …
-
.htaccess and URL rewriting
- https://en.wikipedia.org/wiki/.htaccess
- https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
- https://en.wikipedia.org/wiki/Rewrite_engine – URL rewriting
I want to get my WordPress blog paths rewritten as always intended. Where can I acquire the needed competence?
-
extracting fields from a Jira “issue” (like a very nice and useful description)? how to get the markup source of the issue description?
No, Jira does not let you read (“per se“) the markup source of an “issue” – that’s why I went this way in the first place 🙄
- http://Jochen.Hayek.name/wp/blog-en/2015/12/02/jira-rest-api/ – using Jira’s REST API: a “…/rest/api/2/issue/…” URL
- http://Jochen.Hayek.name/wp/blog-en/2015/12/22/jq-json-processor/ – how to use
jqfor json-tidying
jq . X.json > X.pretty.json
- http://Jochen.Hayek.name/wp/blog-en/2018/01/17/json-extract-structure/ – extract the structure tree of your JSON data using
jqand a nice command line
jq -c 'path(..)|[.[]|tostring]|join("/")|"."+.' X.pretty.json- the field we are interested in is
fields/description
jq ".fields.description" X.json > X.description.txt
- save the value of that field to a separate file!
- remove the leading and trailing double-quotes!
- replace all
\"with ordinary double-quotes! - remove
\r! - replace
\nwith ordinary new-lines!
jq ".fields.description" X.json | perl -pe 's/^"(.*)"$/$1/; s/\\"/"/g; s/\\r//g; s/\\n/\n/g' > X.description.txt
- …
- looks good, doesn’t it?
-
another nice JSON file: how to extract its structure using jq
$ jq -c 'path(..)|[.[]|tostring]|join("/")|"."+.'The idea is to use one of the output lines in order to access the respective field on your next
jqcommand line:$ jq ".fields.description" X.json
-
Oracle SQL scripts: how to use a variable for the table name
There is a “test table” and there is a “serious table” – use a variable name for the table(s) in question!