Skip to content

Instantly share code, notes, and snippets.

View simt2's full-sized avatar
🐔
magic is bad

Simon Tesar simt2

🐔
magic is bad
View GitHub Profile
@simt2
simt2 / Vagrantfile
Last active December 23, 2021 05:31
Adding an additional disk to a VirtualBox machine in Vagrant via the experimental disks feature
# Enable the experimental disks feature via environment variable, requires Vagrant >=2.2.8.
ENV["VAGRANT_EXPERIMENTAL"] = "disks"
Vagrant.configure(2) do |config|
config.vm.disk :disk, name: "storage", size: "4GB"
end
@simt2
simt2 / keybase.md
Created April 24, 2018 06:46
Keybase verification

Keybase proof

I hereby claim:

  • I am simt2 on github.
  • I am simt (https://keybase.io/simt) on keybase.
  • I have a public key ASCxDYTJYyvtoY5dVaK0_xDmeqBwg30JFN0zXLbmaQM4JQo

To claim this, I am signing this object:

@simt2
simt2 / mesh-go-example.md
Created February 21, 2017 09:32
mesh-go-example blogpost

Combining the Gopher with the API-first CMS Gentics Mesh

Go is a rising multi-purpose programming language, widely used for mostly server-side applications because of its speed, concurrency and ease of use. It has a built-in and production-ready template engine and http server, which also makes it a excellent choice for web applications. This example shows how to create a small web application with Go, using Gentics Mesh as backend to manage all the data for us.

Getting ready

Make sure you have Go installed or set it up as described here. Now get and start the example from Github:

# Download example and change to directory
go get github.com/gentics/mesh-go-example
cd $GOPATH/src/github.com/gentics/mesh-go-example
@simt2
simt2 / SessionCookie.go
Created February 21, 2017 08:17
mesh-go-example SessionCookie.go
// MeshLogin logs into the mesh backend and sets the session id
func MeshLogin(username string, password string) {
body := map[string]string{
"username": USERNAME,
"password": PASSWORD,
}
payload, _ := json.Marshal(body)
r, _ := http.Post(BASEURL+"auth/login", "application/json", bytes.NewBuffer(payload))
for _, cookie := range r.Cookies() {
if cookie.Name == "mesh.session" {
@simt2
simt2 / LoadChildren.go
Created February 21, 2017 08:16
mesh-go-example LoadChildren.go
// LoadChildren takes a nodes uuid and returns its children.
func LoadChildren(uuid string) *[]gjson.Result {
r := MeshGetRequest("demo/nodes/" + uuid + "/children?expandAll=true&resolveLinks=short")
defer r.Body.Close()
bytes, _ := ioutil.ReadAll(r.Body)
json := gjson.ParseBytes(bytes).Get("data").Array()
return &json
}
@simt2
simt2 / productList.html
Created February 21, 2017 08:16
mesh-go-example productList.html
{{define "content"}}
<div>
<h1>{{ .Category.Get "fields.name" }}</h1>
<div class="row products">
{{range $product := .Products}}
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="panel panel-default">
<div class="panel-body">
<h3>
@simt2
simt2 / productDetail.html
Created February 21, 2017 08:15
mesh-go-example productDetail.html
{{define "content"}}
{{with $product := index .Products 0}}
<div>
<h1>{{ $product.Get "fields.name" }}</h1>
<div class="row">
<div class="col-md-6">
<form name="productForm">
@simt2
simt2 / welcome.html
Created February 21, 2017 08:14
mesh-go-example welcome.html
{{define "content"}}
<div class="jumbotron">
<div class="row">
<div class="col-sm-3 text-right">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" style="max-width: 150px;" viewBox="0 0 500.000000 579.000000" preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,579.000000) scale(0.100000,-0.100000)" fill="#00a0d2" stroke="none">
<path class="gtx-logo-main" d="M2417 5780 c-21 -6 -52 -17 -70 -26 -24 -13 -2014 -1184 -2183 -1285 -43 -26 -108 -98 -136 -151 l-23 -43 -3 -1362 -2 -1362 21 -56 c44 -119 20 -102 1213 -805 598 -353 1109 -652 1135 -663 65 -30 197 -30 262 0 34 15 1874 1096 2205 1294 43 26 108 98 136 151 l23 43 3 1362 c2 1355 2 1362 -18 1417 -61 163 -257 260 -425 211 -41 -12 -278 -145 -765 -432 -774 -455 -786 -463 -829 -578 -28 -75 -28 -184 0 -260 27 -72 104 -156 176 -191 75 -37 185 -44 263 -17 30 10 240 127 466 261 227 133 414 242 418 242 3 0 5 -383 4 -851 l-3 -851 -888 -524 c-488 -288 -892 -524 -897 -524 -5 0 -409 236 -897 524 l-888 524 0 1067
@simt2
simt2 / navigation.html
Created February 21, 2017 08:14
mesh-go-example navigation.html
{{define "navigation"}}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a href="/" class="navbar-brand">Home</a>
</div>
<ul class="nav navbar-nav">
{{range $node := .Breadcrumb}}
@simt2
simt2 / base.html
Created February 21, 2017 08:13
mesh-go-example base.html
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css">
<meta charset="UTF-8">
<title>Gentics Mesh Demo</title>
<style>
.row.products > div {
height: 500px
}