From 2c883d2e122739bb81d7ecfa4142d5689a310d13 Mon Sep 17 00:00:00 2001 From: Ryan Wark Date: Sat, 14 Aug 2021 10:16:53 -0300 Subject: [PATCH] Initial version --- b56.go | 42 +++++++++++++++++++++++++++++ static/b56.css | 16 +++++++++++ static/b56.js | 12 +++++++++ static/flip.css | 66 +++++++++++++++++++++++++++++++++++++++++++++ static/flip.min.css | 5 ++++ static/flip.min.js | 7 +++++ static/index.html | 21 +++++++++++++++ 7 files changed, 169 insertions(+) create mode 100644 b56.go create mode 100644 static/b56.css create mode 100644 static/b56.js create mode 100644 static/flip.css create mode 100644 static/flip.min.css create mode 100644 static/flip.min.js create mode 100644 static/index.html diff --git a/b56.go b/b56.go new file mode 100644 index 0000000..7e5d46a --- /dev/null +++ b/b56.go @@ -0,0 +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() +} diff --git a/static/b56.css b/static/b56.css new file mode 100644 index 0000000..0d4deea --- /dev/null +++ b/static/b56.css @@ -0,0 +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; +} diff --git a/static/b56.js b/static/b56.js new file mode 100644 index 0000000..96e0b18 --- /dev/null +++ b/static/b56.js @@ -0,0 +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); +} diff --git a/static/flip.css b/static/flip.css new file mode 100644 index 0000000..7edc1f8 --- /dev/null +++ b/static/flip.css @@ -0,0 +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; +} \ No newline at end of file diff --git a/static/flip.min.css b/static/flip.min.css new file mode 100644 index 0000000..eec5164 --- /dev/null +++ b/static/flip.min.css @@ -0,0 +1,5 @@ +/* + * @pqina/flip v1.8.0 - A Beautifully Animated Flip Clock + * Copyright (c) 2020 PQINA - https://pqina.nl/flip/ + */ + .tick{box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default;position:relative;z-index:1;line-height:1.4}.tick *{box-sizing:inherit}.tick [data-view]{max-width:100%}.tick span[data-view]{display:inline-block}.tick .tick-credits{position:absolute;right:0;bottom:0;opacity:.4;text-decoration:none;font-size:11px;color:inherit}.tick [data-layout~=pad]{margin:-.25em}.tick [data-layout~=pad]>*{margin:.25em}.tick [data-layout~=horizontal]{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}.tick [data-layout~=horizontal][data-layout~=baseline]{-ms-flex-align:baseline;align-items:baseline}.tick [data-layout~=horizontal][data-layout~=center]{-ms-flex-pack:center;justify-content:center}.tick [data-layout~=horizontal][data-layout~=right]{-ms-flex-pack:end;justify-content:flex-end}.tick [data-layout~=horizontal][data-layout~=left]{-ms-flex-pack:start;justify-content:flex-start}.tick [data-layout~=horizontal][data-layout~=fill],.tick [data-layout~=horizontal][data-layout~=stretch]{-ms-flex-line-pack:stretch;align-content:stretch;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.tick [data-layout~=horizontal][data-layout~=fill]>*,.tick [data-layout~=horizontal][data-layout~=stretch]>*{-ms-flex:1 0 0px;flex:1 0 0;width:100%}.tick [data-layout~=horizontal][data-layout~=multi-line]{-ms-flex-wrap:wrap;flex-wrap:wrap}.tick [data-layout~=horizontal][data-layout~=fit]{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-line-pack:center;align-content:center;white-space:nowrap;-ms-flex-pack:start;justify-content:flex-start}.tick [data-layout~=vertical]{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center}.tick [data-layout~=vertical][data-layout~=top]{-ms-flex-pack:start;justify-content:flex-start}.tick [data-layout~=vertical][data-layout~=bottom]{-ms-flex-pack:end;justify-content:flex-end;min-height:100%}.tick [data-layout~=vertical][data-layout~=middle]{-ms-flex-pack:center;justify-content:center;min-height:100%}.tick [data-layout~=vertical][data-layout~=left]{-ms-flex-align:start;align-items:flex-start}.tick [data-layout~=vertical][data-layout~=right]{-ms-flex-align:end;align-items:flex-end}.tick [data-layout~=vertical][data-layout~=center]{text-align:center}.tick [data-layout~=vertical][data-layout~=fill],.tick [data-layout~=vertical][data-layout~=stretch]{-ms-flex-align:stretch;align-items:stretch;min-height:100%}.tick [data-layout~=vertical][data-layout~=fill]>*,.tick [data-layout~=vertical][data-layout~=stretch]>*{-ms-flex:1 0 0px;flex:1 0 0}.tick [data-layout~=vertical]>*+*{margin-top:.5em}.tick [data-layout~=overlay]{position:relative}.tick [data-layout~=overlay]>*{margin:0}.tick [data-layout~=overlay][data-layout~=center]{text-align:center}.tick [data-layout~=overlay][data-layout~=left]{text-align:left}.tick [data-layout~=overlay][data-layout~=right]{text-align:right}.tick [data-layout~=overlay]>[data-overlay=fill],.tick [data-layout~=overlay]>[data-overlay=stretch]{position:absolute;left:0;right:0;top:0;bottom:0}.tick [data-layout~=overlay]>[data-overlay=center]{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;position:absolute;left:0;right:0;top:0;bottom:0}.tick-flip{position:relative;text-align:center}.tick-flip *{border-radius:inherit;white-space:pre;letter-spacing:inherit;text-indent:inherit}.tick-flip-front{border-bottom-left-radius:0;border-bottom-right-radius:0}.tick-flip-back{border-top-left-radius:0;border-top-right-radius:0}.tick-flip-spacer{display:block;visibility:hidden}.tick-flip-shadow{position:absolute;left:1px;right:1px;top:1px;bottom:1px;color:transparent!important;background:transparent!important}.tick-flip-shadow-top{bottom:calc(50% - 1px)}.tick-flip-shadow-bottom{top:calc(50% + 1px)}.tick-flip-card-shadow{position:absolute;left:.15em;right:.15em;bottom:.125em;height:.5em;background-color:transparent;border-radius:0;opacity:0;transform-origin:0 100%;box-shadow:0 .125em .25em rgba(0,0,0,.5),0 .125em .5em rgba(0,0,0,.75);z-index:0}.tick-flip-card{position:absolute;z-index:1;left:0;top:0;width:100%;height:100%;perspective:4em}.tick-flip-panel-back,.tick-flip-panel-front{position:absolute;left:0;width:100%;height:51%;-webkit-backface-visibility:hidden;backface-visibility:hidden;transform-style:preserve-3d}.tick-flip-panel-back-text,.tick-flip-panel-front-text{position:absolute;left:-1px;top:0;right:-1px;height:100%;overflow:hidden}.tick-flip-panel-text-wrapper{position:absolute;left:0;top:0;right:0;height:100%}.tick-flip-panel-back-text .tick-flip-panel-text-wrapper{height:200%;top:-100%}.tick-flip-panel-front{transform-origin:center bottom;top:0;z-index:2;box-shadow:inset 0 1px hsla(0,0%,100%,.05)}.tick-flip-panel-back{transform-origin:center top;top:50%;z-index:1;box-shadow:inset 0 -1px rgba(0,0,0,.1)}.tick-flip-panel-back:after{z-index:1;content:"";position:absolute;left:0;top:0;width:100%;height:100%;background-image:linear-gradient(180deg,rgba(0,0,0,.3) 1px,rgba(0,0,0,.15) 0,transparent 30%)}.tick-flip-panel-back-shadow{z-index:2}.tick-flip-panel-back-highlight{z-index:3}.tick-flip-panel-back-highlight,.tick-flip-panel-back-shadow{border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}.tick-flip-panel-back-highlight,.tick-flip-panel-back-shadow,.tick-flip-panel-front-shadow{position:absolute;left:0;top:0;right:0;bottom:0;opacity:0}.tick-flip-panel-front-shadow{background-image:linear-gradient(0deg,rgba(0,0,0,.8),rgba(0,0,0,.3))}.tick-flip-panel-back-shadow{background-image:linear-gradient(180deg,rgba(0,0,0,.7),rgba(0,0,0,.5))}.tick-flip-panel-back-highlight{background-image:linear-gradient(180deg,hsla(0,0%,100%,.15),hsla(0,0%,100%,.3))}.tick [data-style*="shadow:inner"],.tick [data-style*="shadow:inner"] .tick-flip-card-shadow,.tick [data-style*="shadow:none"] .tick-flip-card-shadow,.tick [data-style*="shadow:none"] .tick-flip-panel-back,.tick [data-style*="shadow:none"] .tick-flip-panel-front,.tick [data-style*="shadow:none"] .tick-flip-shadow{box-shadow:none}.tick [data-style*="shadow:none"] .tick-flip-back:after,.tick [data-style*="shadow:none"] .tick-flip-panel-back-shadow,.tick [data-style*="shadow:none"] .tick-flip-panel-back-text:after,.tick [data-style*="shadow:none"] .tick-flip-panel-front-shadow{background-image:none}.tick [data-style*="rounded:none"]{border-radius:0}.tick [data-style*="rounded:panels"] .tick-flip-front,.tick [data-style*="rounded:panels"] .tick-flip-shadow-bottom{border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}.tick [data-style*="rounded:panels"] .tick-flip-back,.tick [data-style*="rounded:panels"] .tick-flip-panel-back:after,.tick [data-style*="rounded:panels"] .tick-flip-shadow-top{border-top-left-radius:inherit;border-top-right-radius:inherit}.tick-flip{margin-left:.0625em;margin-right:.0625em;min-width:1.125em;border-radius:.125em;letter-spacing:.25em;text-indent:.25em}.tick-flip-panel{color:#edebeb;background-color:#333232}.tick-flip-shadow{box-shadow:0 .125em .3125em rgba(0,0,0,.25),0 .02125em .06125em rgba(0,0,0,.25)} \ No newline at end of file diff --git a/static/flip.min.js b/static/flip.min.js new file mode 100644 index 0000000..11857c0 --- /dev/null +++ b/static/flip.min.js @@ -0,0 +1,7 @@ +/* eslint-disable */ + +/* + * @pqina/flip v1.8.0 - A Beautifully Animated Flip Clock + * Copyright (c) 2020 PQINA - https://pqina.nl/flip/ + */ +!function(){"use strict";function c(t){return"function"==typeof t||"[object Function]"===e.call(t)}function f(t){var e,n=(e=Number(t),isNaN(e)?0:0!==e&&isFinite(e)?(0>>0,r=arguments[1]>>0,i=r<0?Math.max(n+r,0):Math.min(r,n),o=arguments[2],a=void 0===o?n:o>>0,u=a<0?Math.max(n+a,0):Math.min(a,n);i>>0,r=arguments[1],i=0;i!==n;i++)if(t.call(r,this[i],i,e))return this[i]}}),Array.from||(Array.from=(e=Object.prototype.toString,r=Math.pow(2,53)-1,function(t,e,n){var r=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var i,o=1t.length)for(;r.definitions.length>t.length;){r.definitions.pop().presenter.destroy()}t.forEach(function(t,e){var n=r.definitions[e];n||(n=r.definitions[e]=ie(r.definition),r.update=i(n),n.presenter.appendTo(r.root,"right"===r.align?"first":"last"))}),t.forEach(function(t,e){return r.update(r.definitions[e],t)}),r.views=t,at(r)}function W(t,e){var n=document.createElement(t);return e&&(n.className=e),n}function Y(n,r,i){var t=new MutationObserver(function(e){r.forEach(function(t){e.filter(function(t){return r.includes(t.attributeName)}).length&&i(n.getAttribute(t))})});return t.observe(n,{attributes:!0}),t}function V(t){return t instanceof HTMLElement}function B(t,e,n,r){var i=3window.scrollY+window.innerHeight)}function $(t){return t.trim()}function X(t,e){var n=e.toString();return st[n]||(st[n]={}),st[n][t]||(st[n][t]=e(t)),st[n][t]}function Z(t){return t?parseFloat(t)*(/ms$/.test(t)?1:1e3):0}function J(t){return t.match(/[a-z]+(?:\(.*?\))?\s?(?:origin\(.*?\))?\s?(?:[a-z]+\(.*?\))?[ .a-z-0-9]*/g).map(wt)}function K(t){var e=t.match(/follow-gradient|horizontal-gradient|vertical-gradient/)[0];return{type:e,colors:t.substr(e.length).match(/(?:transparent|rgb\(.*?\)|hsl\(.*?\)|hsla\(.*?\)|rgba\(.*?\)|[a-z]+|#[abcdefABCDEF\d]+)\s?(?:[\d]{1,3}%?)?/g).map(_t)}}function Q(t){return"string"!=typeof t?t:t.match(/([-.\d]+(?:%|ms|s|deg|cm|em|ch|ex|q|in|mm|pc|pt|px|vh|vw|vmin|vmax)?)|[%#A-Za-z0-9,.()]+/g)}function tt(t){return t.trim().split("-").map(function(t,e){return 0=t.destination||t.origin>=t.destination&&t.position<=t.destination)&&(e(),t.velocity=0,t.position=t.destination)})}},Lt=function(e,t){var n=1=t.destination||t.origin>=t.destination&&t.position<=t.destination)&&(e(),t.velocity=0,t.position=t.destination)})}},Ut=function(e,t,n,r){var i=1"===i[o+1]?(c=!0,u.trim().length&&(l.push([u.trim()]),u=""),e+=2):","===f?(c&&u.trim().length&&(l.push([u.trim()]),u="",c=!1),l=Xt(l,r),u=$t(r,u)):u+=f,e++}}return(c&&u.trim().length||!c&&u.trim().length&&!l.length)&&(l.push([u.trim()]),u=""),Xt(l,r),$t(r,u),e}(0,t,e),e}function Jt(a){function u(e,t){e.transform(t,function(t){e.presenter.update(t)},a),n||(n=!0,r())}var n=!1,r=function t(){a.baseDefinition.presenter.draw(),requestAnimationFrame(t)};return function t(e){var n,r,i,o;return e.presenter=(r=t,o=void 0,(n=e).repeat?o=Yt(n.root,n.repeat,r):"string"==typeof n.view?o=Vt(n.view,n.root,n.style):(i=n).children&&i.children.length&&(o=Wt(n.root,n.children,r)),o),e.transform=ue(e.transform,a),u}(a.baseDefinition)}function Kt(i){for(var t=arguments.length,o=Array(1=h.Week-o.idle)return o.wait=!0,o;o.dist=a}else{o.time=f(O(r),o.day);var u=Je(o.time,e);if(u.wait)return o;o.time=O(m(r,o.time)&&u.date?u.date:u.from);var l=o.time-r;l<0&&o.time.setDate(o.time.getDate()+7),o.dist=l}return o.date=O(o.time),o}function je(t,e){return/januari|februari|march|april|may|june|july|august|september|october|november|december/.test(e)?function(n,e){var t=e.match(/januari|februari|march|april|may|june|july|august|september|october|november|december|[\d]+th|\dst|\dnd|first|last|at\s[\d]+(?::[\d]+)?(?::[\d]+)?/g);if(1=h.Day-r.idle?r.wait=!0:(r.dist=i,r.date=O(r.time)),r):/hours|hour|minutes|minute|seconds|second/.test(e)?Je(t,e):null;var n,r,i}function qe(t,e){if(!0===t)return n=function(t){e(t.getTime()-b().getTime())},r=new XMLHttpRequest,i=Date.now(),r.open("HEAD",window.location+"?noCache="+i),r.setRequestHeader("Content-Type","text/html"),r.setRequestHeader("Cache-Control","no-cache"),r.onload=function(){var t=.5*(i-Date.now()),e=new Date(r.getResponseHeader("Date"));n(new Date(e.getTime()+t))},void r.send();var n,r,i;"string"!=typeof t?setTimeout(function(){e(0)},0):setTimeout(function(){e(l(t).getTime()-b().getTime())},0)}function Ge(t){return it({complete:!1,offset:null,value:null,timer:null,onload:function(){},onupdate:function(){}},t)}function We(){var n=0=n.till)return n;if(n.interval>n.till-n.from)return n;var r=t-n.from,i=n.interval-r%n.interval;return null!==n.idle&&i>=n.interval-n.idle?n.wait=!0:(n.dist=i,n.date=new Date(t.getTime()+n.dist)),n},Ke={format:["d","h","m","s"],cascade:!0,server:null,interval:1e3},Qe=function(t,e,n,r){e[t]=n[t],r(Ae(e))},tn={ascii:function(){return function(t,e){return e((t+"").charCodeAt(0))}},char:function(t){var r=1(""+t).length?"left"===r?(""+n+t).slice(-n.length):(""+t+n).substring(0,n.length):t)}},number:function(){var r=0 + + + + A static page + + + + + + +
+
+
+ +
+
+
+ + +