-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/num: Add num tool which displays the binary, octal, decimal and h…
…exadecimal representation of numbers.
- Loading branch information
Showing
15 changed files
with
220 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,26 @@ | ||
gitsync | ||
======= | ||
# gitsync | ||
|
||
This tool keeps forked git repositories in sync with their parents. It does so | ||
by locating the repositories of provided usernames and organizations. Then it | ||
creates a shell script which will clone all repository forks, pull changes from | ||
their parens and push those changes to the forked repository. | ||
|
||
Installation | ||
------------ | ||
## Installation | ||
|
||
go get github.com/mewmew/playground/cmd/gitsync | ||
|
||
Usage | ||
----- | ||
## Usage | ||
|
||
gitsync USER... | ||
|
||
Examples | ||
-------- | ||
## Examples | ||
|
||
gitsync mewbak > sync.sh | ||
chmod +x sync.sh | ||
./sync.sh | ||
|
||
public domain | ||
------------- | ||
## Public domain | ||
|
||
This code is hereby released into the *[public domain][]*. | ||
The source code and any original content of this repository is hereby released into the [public domain]. | ||
|
||
[public domain]: https://creativecommons.org/publicdomain/zero/1.0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,24 @@ | ||
metagps | ||
======= | ||
# metagps | ||
|
||
This tool outputs the GPS coordinates of provided images. | ||
|
||
Installation | ||
------------ | ||
## Installation | ||
|
||
go get github.com/mewmew/playground/cmd/metagps | ||
|
||
Usage | ||
----- | ||
## Usage | ||
|
||
metagps PATH... | ||
|
||
Examples | ||
-------- | ||
## Examples | ||
|
||
metagps "2013-02-17 - 09.09.37.jpg" | ||
// Output: | ||
// path: 2013-02-17 - 09.09.37.jpg | ||
// coord: N 13.410758 E 103.85964 | ||
|
||
public domain | ||
------------- | ||
## Public domain | ||
|
||
This code is hereby released into the *[public domain][]*. | ||
The source code and any original content of this repository is hereby released into the [public domain]. | ||
|
||
[public domain]: https://creativecommons.org/publicdomain/zero/1.0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# num | ||
|
||
The `num` tool displays the binary, octal, decimal and hexadecimal representation of numbers. | ||
|
||
## Installation | ||
|
||
go get github.com/mewmew/playground/cmd/num | ||
|
||
## Usage | ||
|
||
num BIN|OCT|DEC|HEX | ||
|
||
## Examples | ||
|
||
```bash | ||
$ num 0b111101101 | ||
bin: 0b111101101 | ||
oct: 0o755 | ||
dec: 493 | ||
hex: 0x1ED | ||
``` | ||
|
||
```bash | ||
[~]$ num 0o755 | ||
bin: 0b111101101 | ||
oct: 0o755 | ||
dec: 493 | ||
hex: 0x1ED | ||
``` | ||
|
||
```bash | ||
$ num 493 | ||
bin: 0b111101101 | ||
oct: 0o755 | ||
dec: 493 | ||
hex: 0x1ED | ||
``` | ||
|
||
```bash | ||
$ num 0x1ED | ||
bin: 0b111101101 | ||
oct: 0o755 | ||
dec: 493 | ||
hex: 0x1ED | ||
``` | ||
|
||
## Public domain | ||
|
||
The source code and any original content of this repository is hereby released into the [public domain]. | ||
|
||
[public domain]: https://creativecommons.org/publicdomain/zero/1.0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//go:generate usagen num | ||
|
||
// num is a tool which displays the binary, octal, decimal and hexadecimal | ||
// representation of numbers. | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func usage() { | ||
const use = ` | ||
Usage: num BIN|OCT|DEC|HEX | ||
Examples: | ||
num 0b111101101 | ||
num 0o755 | ||
num 493 | ||
num 0x1ED | ||
` | ||
fmt.Fprint(os.Stderr, use[1:]) | ||
} | ||
|
||
func main() { | ||
// Parse command line arguments. | ||
flag.Usage = usage | ||
flag.Parse() | ||
if flag.NArg() != 1 { | ||
flag.Usage() | ||
os.Exit(1) | ||
} | ||
s := flag.Arg(0) | ||
|
||
n, err := parseNum(s) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
const format = ` | ||
bin: 0b%b | ||
oct: 0o%o | ||
dec: %d | ||
hex: 0x%X | ||
` | ||
fmt.Printf(format[1:], n, n, n, n) | ||
} | ||
|
||
// parseNum parses the given string as a binary, octal, decimal or hexadecimal | ||
// number based on its prefix; with "0b", "0o", no prefix, and "0x" | ||
// respectively. | ||
func parseNum(s string) (n uint64, err error) { | ||
var base int | ||
switch { | ||
case strings.HasPrefix(s, "0b"): | ||
// Binary | ||
base = 2 | ||
s = s[len("0b"):] | ||
case strings.HasPrefix(s, "0o"): | ||
// Octal | ||
base = 8 | ||
s = s[len("0o"):] | ||
case strings.HasPrefix(s, "0x"): | ||
// Hexadecimal | ||
base = 16 | ||
s = s[len("0x"):] | ||
default: | ||
// Decimal | ||
base = 10 | ||
} | ||
return strconv.ParseUint(s, base, 64) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// generated by `usagen num`; DO NOT EDIT | ||
|
||
// Usage: num BIN|OCT|DEC|HEX | ||
// | ||
// Examples: | ||
// num 0b111101101 | ||
// num 0o755 | ||
// num 493 | ||
// num 0x1ED | ||
package main |
Oops, something went wrong.