Rocket fuel: HydroxylAmmonium Nitrate

NASA tested in 2019 in mission GPIM so called green fuel. Here is chemical composition of this substance called hydroxylammonium nitrate or hydroxylamine nitrate with the chemical formula [NH3OH+][NO3-]. It is a colorless hygroscopic solid usually handled as an aqueous solution.

H N O +

Posted in workday | Leave a comment

Some git commands to practice

Here are few git commands to practice. And don’t forgot to edit github source by hitting DOT (.)!

*Stashing
git stash                             #changes to default stash
git stash pop                         #put back default stash

git stash save 'change description 1' #changes to labeled stash
git stash list                        #list all stashes
git stash apply 0                     #put back stash listed with index 0

*Three ways to add changes
git commit -a
git commit -am "describe here"

git add dir1/file1
git status
git reset

git add -p #prompt to all small changes

*Push more explicitly
git push origin my_branch --set-upstream #if for the first time

*Undoing commit
git commit -m "change 1 description"
git reset --soft HEAD~1               #commit undone

*Stash between branches
git stash                   #changes to default stash in current branch           
git checkout -b new_branch
git stash pop               #put back default stash to new_branch

*Log
git log --oneline
git log --graph

*
git commit --amend -m "new message"
git log
git revert f252a4ccee329c60fd8c01ae216c6e48f857a482

*$ git log
commit f252a4ccee329c60fd8c01ae216c6e48f857a482 (HEAD -> master)
Author: User <user@gmail.com>
Date:   Thu Sep 29 08:34:45 2022 -0500

    PROJECT 2022-0929

commit 201fbe8333be0640b2b606128b5d2195bdc8866c
Author: User <user@gmail.com>
Date:   Wed Sep 28 18:50:35 2022 -0500

    PROJECT 2022-0928

commit 49eca59f883b96eb92fa51552cdc36672a2c2ceb
Author: User <user@gmail.com>
Date:   Mon Sep 26 21:30:14 2022 -0500

    PROJECT 2022-0927
Posted in workday | Leave a comment

GO lang installation on FreeBSD

Working mostly on Windows 11 I found that cross compilation for FreeBSD does not work. I’ve got error message
go: unsupported GOOS/GOARCH pair FreeBSD/AMD64

Good solution is actually install it on FreeBSD itself. So here are commands from FreeBSD terminal.



#curl https://go.dev/dl/go1.19.3.freebsd-amd64.tar.gz -O
#cat go1.19.3.freebsd-amd64.tar.gz
<a href="https://dl.google.com/go/go1.19.3.freebsd-amd64.tar.gz">Found</a>.

#curl https://dl.google.com/go/go1.19.3.freebsd-amd64.tar.gz -O
#tar xvf go1.19.3.freebsd-amd64.tar.gz
#mv go /usr/local/.

$vi ~/.profile 
#add 3 env vars: export GOROOT=/usr/local/go export GOPATH=$HOME/goprojects export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
$ go version go version go1.19.3 freebsd/amd64 $ go env #to show go related env vars ... $ mkdir -p ~/goprojects/hello1 $ cd ~/goprojects/hello1 $ vi hello1.go
package main func main() { println("Hello One!") }
$go build hello1.go $./hello1 Hello One!
Posted in golang, workday | Tagged | Leave a comment

Display portion of an image

Let’s say there is a smaller version of the image on an HTML page with a link providing a full scale version of the image. you would like to display several detailed parts of that image. Here is color coded code how it can be done on a blog, where one does not have the option to have own style sheet.

<p>Detailed parts of Moon image:<br>
<span style="display:inline-flex; padding:0px; position:relative; no-repeat;height:180px;">
<span style="width:140px;margin:4px;background: url('/wp-content/uploads/2022/10/comp.8066.jpg') -2958px -420px;"></span>
<span style="width:199px;margin:4px;background: url('/wp-content/uploads/2022/10/comp.8066.jpg') -2200px -1160px;"></span>
<span style="width:280px;margin:4px;background: url('/wp-content/uploads/2022/10/comp.8066.jpg') -1970px -2620px;"></span>
</span></p>

Detailed parts of Moon image:

Credit: NASA Scientific Visualization Studio
Posted in workday | Tagged , | Leave a comment

Some git commands

In recent years git became versioning system of choice. Here are few commands to review and practice.

*Stashing
git stash                             #changes to default stash
git stash pop                         #put back default stash

git stash save 'change description 1' #changes to labeled stash
git stash list                        #list all stashes
git stash apply 0                     #put back stash listed with index 0

*Three ways to add changes
git commit -a
git commit -am "describe here"

git add dir1/file1
git status
git reset

git add -p #prompt to all small changes

*Push more explicitly
git push origin my_branch --set-upstream #if for the first time

*Undoing commit
git commit -m "change 1 description"
git reset --soft HEAD~1               #commit undone

*Stash between branches
git stash                             #changes to default stash in current branch           
git checkout -b new_branch
git stash pop                         #put back default stash to new_branch

*Log
git log --oneline
git log --graph

*
git commit --ammend -m "new message"
git log
git revert f252a4ccee329c60fd8c01ae216c6e48f857a482

*$ git log
commit f252a4ccee329c60fd8c01ae216c6e48f857a482 (HEAD -> master)
Author: User <user@gmail.com>
Date:   Thu Sep 29 08:34:45 2022 -0500

    PROJECT 2022-0929

commit 201fbe8333be0640b2b606128b5d2195bdc8866c
Author: User <user@gmail.com>
Date:   Wed Sep 28 18:50:35 2022 -0500

    PROJECT 2022-0928

commit 49eca59f883b96eb92fa51552cdc36672a2c2ceb
Author: User <user@gmail.com>
Date:   Mon Sep 26 21:30:14 2022 -0500

    PROJECT 2022-0927


Editing on github.com ?
Hit single character . (dot) and you will get VS online editor!

Posted in workday | Tagged | Leave a comment

Go: False positive virus detection

Recently to my surprise antivirus software detected virus in my freshly build golang program. Doing research I found interesting article from Melle Boudewijns. So I created simple golang program hello_flags.go:

package main

func main() {
  print("Hello: go build -race -ldflags \"-s -w\" hello_flags.go")
}

Then I compiled this source file with flags and execute it and again without flags and execute it. Here is output:

G:\hello_flags>go build -race -ldflags "-s -w" hello_flags.go

G:\hello_flags>.\hello_flags.exe
Hello: go build -race -ldflags "-s -w" hello_flags.go
G:\hello_flags>go build hello_flags.go

G:\hello_flags>.\hello_flags.exe
Access is denied.

G:\hello_flags>

Online tool VirusTotal.com for executable compiled with flags detected Trojan/Malicious/Malware by 16 antivirus programs. Avast did not detect it.

It looks like antivirus machine learning software should learn about simple golang program like above to avoid false positive detection.

Posted in golang, workday | Leave a comment

Text file to json array with jq

Lets say we need convert a text file into json array a process it. More information about jq itself can be found in the manual. First of all let’s create a test file with the first four Greek alphabet letters:

$ cat > greek.txt <<END
Alpha
Beta
Gamma
Delta
END

Each line can be converted to the element of an array. Tool jq is invoked with options --raw-input/-R (each line of text is passed to the filter as a string) and --compact-output / -c (no pretty output, each object is on a single line):

$ jq -cR 'split("\n")' greek.txt
["Alpha"]
["Beta"]
["Gamma"]
["Delta"]

Array brackets can be removed:

$ jq -cR 'split("\n") | .[]' greek.txt
"Alpha"
"Beta"
"Gamma"
"Delta"

Now we may search in similar way like in tool grep. Lets print all lines, for example, with letter “e”:

$ jq -cR 'split("\n") | .[] | select(test(".*e"))' greek.txt
"Beta"
"Delta"
Posted in workday | Leave a comment

Wordle helper

Wordle is nice single webpage game at https://www.powerlanguage.co.uk/wordle/ There is a page with list of the many 5 letter words at https://7esl.com/5-letter-words/ Here is how to create a plain text file with 660 5 letter words:

$ curl https://7esl.com/5-letter-words -O
$ grep "^<li>.....<" < 5-letter-words | sed 's|<li>\(.....\)</li>|\1|' > 5-letter-words.txt

Then one can grep the file 5-letter-word.txt to eliminate some options and list promising words.

There is also webpage https://eslforums.com/5-letter-words/ with 2498 words which can be processed into flat file 5-letter-wordsx2498.txt. Or even better option at file wordle-answers-alphabetical.txt by github user cfreshman with 2315 words.

Here is an example such helpful pipe. The first command lists words with known letter position, the second one eliminates words for letters which are not there

 $ grep ..o.. 5-letter-wordsx2498.txt | grep -vi -E "a|d|i|e|u|s|n|t|f|l"
Posted in workday | Tagged , , | Leave a comment

SVG: color-keywords with colors

At the World Wide Web Consortium (W3C) document SVG Color 1.2, Part 2: Language there are defined color-keywords. Here is that part of the definition updated with horizontal rectangle with color for all 147 color-keywords.

color-keyword ::= ~”aliceblue” | ~”antiquewhite” | ~”aqua” | ~”aquamarine” | ~”azure” | ~”beige” | ~”bisque” | ~”black” | ~”blanchedalmond” | ~”blue” | ~”blueviolet” | ~”brown” | ~”burlywood” | ~”cadetblue” | ~”chartreuse” | ~”chocolate” | ~”coral” | ~”cornflowerblue” | ~”cornsilk” | ~”crimson” | ~”cyan” | ~”darkblue” | ~”darkcyan” | ~”darkgoldenrod” | ~”darkgray” | ~”darkgreen” | ~”darkgrey” | ~”darkkhaki” | ~”darkmagenta” | ~”darkolivegreen” | ~”darkorange” | ~”darkorchid” | ~”darkred” | ~”darksalmon” | ~”darkseagreen” | ~”darkslateblue” | ~”darkslategray” | ~”darkslategrey” | ~”darkturquoise” | ~”darkviolet” | ~”deeppink” | ~”deepskyblue” | ~”dimgray” | ~”dimgrey” | ~”dodgerblue” | ~”firebrick” | ~”floralwhite” | ~”forestgreen” | ~”fuchsia” | ~”gainsboro” | ~”ghostwhite” | ~”gold” | ~”goldenrod” | ~”gray” | ~”grey” | ~”green” | ~”greenyellow” | ~”honeydew” | ~”hotpink” | ~”indianred” | ~”indigo” | ~”ivory” | ~”khaki” | ~”lavender” | ~”lavenderblush” | ~”lawngreen” | ~”lemonchiffon” | ~”lightblue” | ~”lightcoral” | ~”lightcyan” | ~”lightgoldenrodyellow” | ~”lightgray” | ~”lightgreen” | ~”lightgrey” | ~”lightpink” | ~”lightsalmon” | ~”lightseagreen” | ~”lightskyblue” | ~”lightslategray” | ~”lightslategrey” | ~”lightsteelblue” | ~”lightyellow” | ~”lime” | ~”limegreen” | ~”linen” | ~”magenta” | ~”maroon” | ~”mediumaquamarine” | ~”mediumblue” | ~”mediumorchid” | ~”mediumpurple” | ~”mediumseagreen” | ~”mediumslateblue” | ~”mediumspringgreen” | ~”mediumturquoise” | ~”mediumvioletred” | ~”midnightblue” | ~”mintcream” | ~”mistyrose” | ~”moccasin” | ~”navajowhite” | ~”navy” | ~”oldlace” | ~”olive” | ~”olivedrab” | ~”orange” | ~”orangered” | ~”orchid” | ~”palegoldenrod” | ~”palegreen” | ~”paleturquoise” | ~”palevioletred” | ~”papayawhip” | ~”peachpuff” | ~”peru” | ~”pink” | ~”plum” | ~”powderblue” | ~”purple” | ~”red” | ~”rosybrown” | ~”royalblue” | ~”saddlebrown” | ~”salmon” | ~”sandybrown” | ~”seagreen” | ~”seashell” | ~”sienna” | ~”silver” | ~”skyblue” | ~”slateblue” | ~”slategray” | ~”slategrey” | ~”snow” | ~”springgreen” | ~”steelblue” | ~”tan” | ~”teal” | ~”thistle” | ~”tomato” | ~”turquoise” | ~”violet” | ~”wheat” | ~”white” | ~”whitesmoke” | ~”yellow” | ~”yellowgreen”

Posted in workday | Tagged | Leave a comment

SVG: Circular arc

The arc command (a or A) of the element <path> is used to define an elliptical path. The special case is the circular path. Contrary to the element <circle>, where the center of the circle and radius has to be defined, the circular (actually elliptical) command defines start and end points of the path, radius and flag with value 0 or 1 depending on angle lower or greater than 180°.

Let’s say SVG viewBox is centered at 0,0 coordinates and we would like to create a circular path with center at 0,0 with radius r from start angle to the end angle:
x1 = r * cos(startAngle) y1 = - r * sin(startAngle)
x2 = r * cos(endAngle) y2 = - r * sin(endAngle)

With radius 100 from start angle 30° to end angle 60° coordinates looks like:
x1 = 100 * cos(30°) y1 = - 100 * sin(30°)
x2 = 100 * cos(60°) y2 = - 100 * sin(60°)

Here are an examples with absolute and relative commands:
<path          d=”M50,-86.6025 A100,100 0 0,1  86.6025,-50″ />
<path d=”M0,0 m50,-86.6025 a100,100 0 0,1 36.6025,36.6025 ” />

With rotation angle always 0 and sweep flag 1, both in blue, it could be described like this with red variables:
<path id=”absolute_path” d=”Mx1,y1 Ar,r 0,largeFlag,1 x2,y2” />
Let’s say path is already at point x1,y1:
<path id=”relative_path” d=”ar,r 0,largeFlag,1 x2-x1,y2-y” />
Large arc flag has value 0 for arc angle less than 180° and value 1 for angle greater than 180°.

Example of the circular arc from start angle 30° to the end angle 60°.

There is a tool available to create circular arc at https://tools.minetlab.com/svg/circular-arc/

Posted in workday | Tagged | Leave a comment