No commits in common. 'e68fa1a1a78902185bca6450c91397c1156edb3c' and '2c883d2e122739bb81d7ecfa4142d5689a310d13' have entirely different histories.

  1. 84
      b56.go
  2. 32
      static/b56.css
  3. 24
      static/b56.js
  4. 130
      static/flip.css
  5. 8
      static/flip.min.css
  6. 12
      static/flip.min.js
  7. 42
      static/index.html

84
b56.go

@ -1,42 +1,42 @@
package main
import (
"bytes"
"io"
"log"
"math/rand"
"net/http"
"time"
)
func main() {
fs := http.FileServer(http.Dir("./static"))
nextId := func(w http.ResponseWriter, _ *http.Request) {
next := base56Id3()
//log.Printf("Generating ID: %s", next)
io.WriteString(w, next+"\n")
}
http.Handle("/", fs)
http.HandleFunc("/next", nextId)
log.Println("Listening on :8080...")
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}
func base56Id3() string {
//Base56 alphabet with "ambiguous" characters removed: [0oOIl1]
alphabet := "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
//Initialize rand with the time - this is a problem with multiple requests in the same ns
r := rand.New(rand.NewSource(time.Now().UnixNano()))
var b bytes.Buffer
for i := 0; i < 3; i++ {
n := r.Intn(len(alphabet))
char := alphabet[n]
b.WriteByte(char)
}
return b.String()
}
package main
import (
"bytes"
"io"
"log"
"math/rand"
"net/http"
"time"
)
func main() {
fs := http.FileServer(http.Dir("./static"))
nextId := func(w http.ResponseWriter, _ *http.Request) {
next := base56Id3()
//log.Printf("Generating ID: %s", next)
io.WriteString(w, next+"\n")
}
http.Handle("/", fs)
http.HandleFunc("/next", nextId)
log.Println("Listening on :8080...")
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}
func base56Id3() string {
//Base56 alphabet with "ambiguous" characters removed: [0oOIl1]
alphabet := "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
//Initialize rand with the time - this is a problem with multiple requests in the same ns
r := rand.New(rand.NewSource(time.Now().UnixNano()))
var b bytes.Buffer
for i := 0; i < 3; i++ {
n := r.Intn(len(alphabet))
char := alphabet[n]
b.WriteByte(char)
}
return b.String()
}

32
static/b56.css

@ -1,16 +1,16 @@
html,
body {
background-color:#ccc;
}
.wrapper {
width:500px;
height:500px;
margin:0 auto;
background:#ccc;
position:absolute;
left:50%;
top:50%;
margin-left:-250px;
margin-top:-250px;
}
html,
body {
background-color:#ccc;
}
.wrapper {
width:500px;
height:500px;
margin:0 auto;
background:#ccc;
position:absolute;
left:50%;
top:50%;
margin-left:-250px;
margin-top:-250px;
}

24
static/b56.js

@ -1,12 +1,12 @@
function handleTickInit(tick) {
// each 3 seconds we'll update the billboard
Tick.helper.interval(function () {
fetch('/next')
.then(response => response.text())
.then(data => {
console.log(data)
next = data.trim()
tick.value = next
});
}, 3000);
}
function handleTickInit(tick) {
// each 3 seconds we'll update the billboard
Tick.helper.interval(function () {
fetch('/next')
.then(response => response.text())
.then(data => {
console.log(data)
next = data.trim()
tick.value = next
});
}, 3000);
}

130
static/flip.css

@ -1,66 +1,66 @@
.tick {
font-size: 1rem;
white-space: nowrap;
font-family: monospace;
}
.tick-flip,
.tick-text-inline {
font-size: 2.5em;
}
.tick-label {
margin-top: 1em;
font-size: 1em;
}
.tick-char {
width: 1.5em;
}
.tick-text-inline {
display: inline-block;
text-align: center;
min-width: 1em;
}
.tick-text-inline+.tick-text-inline {
margin-left: -.325em;
}
.tick-group {
margin: 0 .5em;
text-align: center;
}
body {
background-color: #fff !important;
}
.tick-text-inline {
color: #595d63 !important;
}
.tick-label {
color: #595d63 !important;
}
.tick-flip-panel {
color: #fff !important;
}
.tick-flip {
font-family: monospace !important;
}
.tick-flip-panel-text-wrapper {
line-height: 1.45 !important;
}
.tick-flip-panel {
background-color: #3c3e3c !important;
}
.tick-flip {
border-radius: 0.12em !important;
.tick {
font-size: 1rem;
white-space: nowrap;
font-family: monospace;
}
.tick-flip,
.tick-text-inline {
font-size: 2.5em;
}
.tick-label {
margin-top: 1em;
font-size: 1em;
}
.tick-char {
width: 1.5em;
}
.tick-text-inline {
display: inline-block;
text-align: center;
min-width: 1em;
}
.tick-text-inline+.tick-text-inline {
margin-left: -.325em;
}
.tick-group {
margin: 0 .5em;
text-align: center;
}
body {
background-color: #fff !important;
}
.tick-text-inline {
color: #595d63 !important;
}
.tick-label {
color: #595d63 !important;
}
.tick-flip-panel {
color: #fff !important;
}
.tick-flip {
font-family: monospace !important;
}
.tick-flip-panel-text-wrapper {
line-height: 1.45 !important;
}
.tick-flip-panel {
background-color: #3c3e3c !important;
}
.tick-flip {
border-radius: 0.12em !important;
}

8
static/flip.min.css
File diff suppressed because it is too large
View File

12
static/flip.min.js
File diff suppressed because it is too large
View File

42
static/index.html

@ -1,21 +1,21 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>A static page</title>
<link rel="stylesheet" href="flip.min.css">
<link rel="stylesheet" href="flip.css">
<link rel="stylesheet" href="b56.css">
<script src="b56.js"></script>
</head>
<body>
<div class="wrapper">
<div class="tick" data-did-init="handleTickInit" data-value="---">
<div data-repeat="true" data-layout="horizontal fit">
<span data-view="flip" class="tick-char"></span>
</div>
</div>
</div>
<script src="flip.min.js"></script>
</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>A static page</title>
<link rel="stylesheet" href="flip.min.css">
<link rel="stylesheet" href="flip.css">
<link rel="stylesheet" href="b56.css">
<script src="b56.js"></script>
</head>
<body>
<div class="wrapper">
<div class="tick" data-did-init="handleTickInit" data-value="---">
<div data-repeat="true" data-layout="horizontal fit">
<span data-view="flip" class="tick-char"></span>
</div>
</div>
</div>
<script src="flip.min.js"></script>
</body>
</html>
Loading…
Cancel
Save