Skip to content

Commit

Permalink
Snapshotting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandbatey committed Oct 28, 2021
1 parent 50f078e commit 0816528
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
jsbuild/node_modules/
jsbuild/package-lock.json
jsbuild/bundle.js
bundle.js
histogram_timestamps
templates.go

24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

all: histogram_timestamps

histogram_timestamps: templates.go
go build

templates.go: bundle.js index.html external_deps
go-bindata -o templates.go index.html bundle.js

bundle.js:
./jsbuild/build_bundle_for_makefile.sh

.PHONY: external_deps
external_deps:
go get -u github.com/kevinburke/go-bindata/go-bindata

.PHONY: clean
clean:
rm -f ./histogram_timestamps ./bundle.js ./jsbuild/bundle.js templates.go

.PHONY: install
install: all
go install

1 change: 1 addition & 0 deletions application/business_logic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package application
1 change: 1 addition & 0 deletions domain/entities.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package domain
1 change: 1 addition & 0 deletions domain/ports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package domain
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/lelandbatey/histogram_timestamps

go 1.16

require (
github.com/itchyny/timefmt-go v0.1.3 // indirect
github.com/kevinburke/go-bindata v3.22.0+incompatible // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/itchyny/timefmt-go v0.1.3 h1:7M3LGVDsqcd0VZH2U+x393obrzZisp7C0uEe921iRkU=
github.com/itchyny/timefmt-go v0.1.3/go.mod h1:0osSSCQSASBJMsIZnhAaF1C2fCBTJZXrnj37mG8/c+A=
github.com/kevinburke/go-bindata v3.22.0+incompatible h1:/JmqEhIWQ7GRScV0WjX/0tqBrC5D21ALg0H0U/KZ/ts=
github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype HTML5>
<!DOCTYPE html>
<html>
<head>
<title>histogram_timestamps 000</title>
</head>
<body>
<canvas id="myChart" width="400" height="400"></canvas>
<script src="bundle.js"></script>
<script src="jsbuild/bundle.js"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions jsbuild/build_bundle_for_makefile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# File exists to run a command which is hard to express in a Makefile in a way
# that's easy to understand. You can run this file from anywhere and it'll
# always try to output the same thing. However, this script makes some
# assumptions which are:
# 1. This script is located inside of the `jsbuild/` directory which contains
# all the files necessary (main.js, package.json, etc) for node to know how
# to build 'bundle.js'.
# 2. The output directory where 'bundle.js' shall be placed is the parent
# directory to wherever this bash script is stored on disk.

# Find the directory of this bash script, from https://stackoverflow.com/a/246128
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ORIGINAL_DIR="${PWD}"

cd "${SCRIPT_DIR}"

$(npm bin)/browserify main.js -o ../bundle.js

echo "bundle.js has been successfully written to the directory '${SCRIPT_DIR}/../'"
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"
"io"
"os"

_ "github.com/itchyny/timefmt-go"
isatty "github.com/mattn/go-isatty"
)

func main() {
fmt.Printf("Is stdin a terminal?: %t\n", isatty.IsTerminal(os.Stdin.Fd()))
if !isatty.IsTerminal(os.Stdin.Fd()) {
all, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Printf("Error reading stdin: %v\n", err)
os.Exit(2)
}
fmt.Printf("Read the following data:\n%s\n", string(all))
}
// 1. read stdin for lines of text
// 2. Attempt to parse lines of text into dates then into epoch_ms formats
// 3. Bin each timestamp by the interval
// 4. Assemble the JSON data to be graphed
// 5. Render the HTML/JS+JSON data to a tmp file
// 6. Serve the tmp file from a port
// 7. Launch a web-browser to view the localhost port
fmt.Printf("hello world")
}
1 change: 1 addition & 0 deletions tbin/tbin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package tbin

0 comments on commit 0816528

Please sign in to comment.