Skip to content

Instantly share code, notes, and snippets.

View dtoebe's full-sized avatar

Daniel Toebe dtoebe

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dtoebe on github.
  • I am dtoebe (https://keybase.io/dtoebe) on keybase.
  • I have a public key whose fingerprint is 6104 212E E4AE 792F 061F A5E8 FCCC A6A4 DC5D BC1F

To claim this, I am signing this object:

@dtoebe
dtoebe / main.go
Created January 3, 2017 11:25
EMBED OTHER BINARIES IN GOLANG BINARY - main.go - 1
// ./sample-data/main.go
package main
import "fmt"
func main() {
fmt.Println("Hello from the binary")
}
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:30
EMBED OTHER BINARIES IN GOLANG BINARY - main.go - 2
// ./main.go
package main
import "os"
// When we run `go generate` from the cli it will run the
// `go run` command outlined below
// **Important: sure to include the comment below for the generator to see**
//go:generate go run generators/generator.go
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:39
GENERATING DATAURI IMAGES WITH GO - main.go -1
//main.go
package main
import (
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"math/rand"
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:41
GENERATING DATAURI IMAGES WITH GO - main.go - 2
//main.go
package main
import (...)
func main() {
// Seed the std random number generator
rand.Seed(time.Now().UTC().UnixNano())
// We will leave out creating the png image file since we
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:43
GENERATING DATAURI IMAGES WITH GO - main.go - 3
//main.go
...
func main() {
...
for ... {...}
// Here we allocate and create a buffer that can easily be
// turned into a []byte
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:47
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 1
// main.go
package main
import (
"fmt"
"os"
"github.com/atotto/clipboard"
"github.com/russross/blackfriday"
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:48
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 2
//main.go
...
func run() error {
engine := qml.NewEngine() //Create the QML engine
engine.On("quit", func() { os.Exit(0) }) //If quit is called from QML the Golang program will gracefully quit
component, err := engine.LoadFile("assets/main.qml") //Load the QML file
if err != nil {
@dtoebe
dtoebe / main.qml
Created January 3, 2017 11:49
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.qml - 1
//assets/main.qml
import QtQuick 2.3 //Needed to import all base QML entities
import QtQuick.Controls 1.4 //Needed for ApplicationWindow and TextArea
import QtQuick.Layouts 1.0 //For the RowLayout
ApplicationWindow { //The base entity so we can set a toolbar later and the layout
width: 640 //Default width
height: 480 //Default height
color: "#f1f1f1" //Background Color
@dtoebe
dtoebe / main.qml
Created January 3, 2017 11:50
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.qml - 2
//assets/main.qml
...
TextArea {
id: mdarea
...
text: mdtxt //A variable name to reference from the Golang code
}
TextArea {
id: rtarea