-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev/moul/examples
- Loading branch information
Showing
14 changed files
with
251 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Start a local faucet | ||
|
||
## Step1: | ||
|
||
Make sure you have started gnoland | ||
|
||
../../gno.land/build/gnoland start -lazy | ||
|
||
## Step2: | ||
|
||
Start the faucet. | ||
|
||
./build/gnofaucet serve -chain-id dev -mnemonic "source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast" | ||
|
||
By default, the faucet sends out 10,000,000ugnot (10gnot) per request. | ||
|
||
## Step3: | ||
|
||
Make sure you have started website | ||
|
||
../../gno.land/build/gnoweb | ||
|
||
Request testing tokens from following URL, Have fun! | ||
|
||
http://localhost:8888/faucet |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package printfdebugging | ||
|
||
// consts copied from https://github.com/fatih/color/blob/main/color.go | ||
|
||
// Attribute defines a single SGR Code | ||
type Attribute int | ||
|
||
const Escape = "\x1b" | ||
|
||
// Base attributes | ||
const ( | ||
Reset Attribute = iota | ||
Bold | ||
Faint | ||
Italic | ||
Underline | ||
BlinkSlow | ||
BlinkRapid | ||
ReverseVideo | ||
Concealed | ||
CrossedOut | ||
) | ||
|
||
const ( | ||
ResetBold Attribute = iota + 22 | ||
ResetItalic | ||
ResetUnderline | ||
ResetBlinking | ||
_ | ||
ResetReversed | ||
ResetConcealed | ||
ResetCrossedOut | ||
) | ||
|
||
// Foreground text colors | ||
const ( | ||
FgBlack Attribute = iota + 30 | ||
FgRed | ||
FgGreen | ||
FgYellow | ||
FgBlue | ||
FgMagenta | ||
FgCyan | ||
FgWhite | ||
) | ||
|
||
// Foreground Hi-Intensity text colors | ||
const ( | ||
FgHiBlack Attribute = iota + 90 | ||
FgHiRed | ||
FgHiGreen | ||
FgHiYellow | ||
FgHiBlue | ||
FgHiMagenta | ||
FgHiCyan | ||
FgHiWhite | ||
) | ||
|
||
// Background text colors | ||
const ( | ||
BgBlack Attribute = iota + 40 | ||
BgRed | ||
BgGreen | ||
BgYellow | ||
BgBlue | ||
BgMagenta | ||
BgCyan | ||
BgWhite | ||
) | ||
|
||
// Background Hi-Intensity text colors | ||
const ( | ||
BgHiBlack Attribute = iota + 100 | ||
BgHiRed | ||
BgHiGreen | ||
BgHiYellow | ||
BgHiBlue | ||
BgHiMagenta | ||
BgHiCyan | ||
BgHiWhite | ||
) |
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,3 @@ | ||
module gno.land/p/demo/printfdebugging | ||
|
||
require gno.land/p/demo/ufmt v0.0.0-latest |
19 changes: 19 additions & 0 deletions
19
examples/gno.land/p/moul/printfdebugging/printfdebugging.gno
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,19 @@ | ||
// this package is a joke... or not. | ||
package printfdebugging | ||
|
||
import ( | ||
"strings" | ||
|
||
"gno.land/p/demo/ufmt" | ||
) | ||
|
||
func BigRedLine(args ...string) { | ||
println(ufmt.Sprintf("%s[%dm####################################%s[%dm %s", | ||
Escape, int(BgRed), Escape, int(Reset), | ||
strings.Join(args, " "), | ||
)) | ||
} | ||
|
||
func Success() { | ||
println(" \033[31mS\033[33mU\033[32mC\033[36mC\033[34mE\033[35mS\033[31mS\033[0m ") | ||
} |
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,14 @@ | ||
package counter | ||
|
||
import "strconv" | ||
|
||
var counter int | ||
|
||
func Increment() int { | ||
counter++ | ||
return counter | ||
} | ||
|
||
func Render(_ string) string { | ||
return strconv.Itoa(counter) | ||
} |
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,22 @@ | ||
package counter | ||
|
||
import "testing" | ||
|
||
func TestIncrement(t *testing.T) { | ||
counter = 0 | ||
val := Increment() | ||
if val != 1 { | ||
t.Fatalf("result from Increment(): %d != 1", val) | ||
} | ||
if counter != val { | ||
t.Fatalf("counter (%d) != val (%d)", counter, val) | ||
} | ||
} | ||
|
||
func TestRender(t *testing.T) { | ||
counter = 1337 | ||
res := Render("") | ||
if res != "1337" { | ||
t.Fatalf("render result %q != %q", res, "1337") | ||
} | ||
} |
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 @@ | ||
module gno.land/r/demo/counter |
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
Oops, something went wrong.