Skip to content

Instantly share code, notes, and snippets.

View dtoebe's full-sized avatar

Daniel Toebe dtoebe

View GitHub Profile
cargo build [16:54:54]
Compiling restapi v0.1.0 (file:restapi)
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> src/main.rs:57:62
|
55 | let path = String::from("/path/to/data.json");
| ---- captured outer variable
56 | server::new(|| {
57 | App::with_state(AppState::new(AppState::collect_data(path).unwrap()))
| ^^^^ cannot move out of captured variable in an `Fn` closure
@dtoebe
dtoebe / examplequery
Created October 8, 2017 15:04
trying to find the person with the most paths
{
var(func: anyofterms(title, "first")) {
ticket as _uid_
}
tickets(func: uid(ticket)) {
title
desc
tag {
~can_do {
@dtoebe
dtoebe / initdata.json
Created October 8, 2017 15:03
Trying to find person with the most paths
mutation {
  schema {
    name: string @index(exact, term) .
    can_do: uid @reverse @count .
    title: string @index(exact, term) .
    desc: string .
    tag: uid @reverse @count .
  }
  set {
    _:javascript <name> "javascript" .
@dtoebe
dtoebe / main.go
Created January 3, 2017 12:02
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 7
//main.go
...
type HTMLText struct { //Already created, just a point of reference
...
}
func (h *HTMLText) CopyToClip(txt string) { //A method of the HTMLText pointer that takes a raw markdown string
formatted := blackfriday.MarkdownCommon([]byte(txt)) //We've seen this before
@dtoebe
dtoebe / main.qml
Created January 3, 2017 12:00
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.qml - 5
//assets/main.qml
...
ApplicationWindow {
...
toolBar: ToolBar { //Create a toolbar and set it as the ApplicationWindow's toolBar
//This will create the space and auto adjust the other children of ApplicationWindow down
RowLayout { //This formats the toolbar to move the buttons side by side
@dtoebe
dtoebe / main.qml
Created January 3, 2017 11:59
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.qml - 4
//assets/main.qml
...
TextArea {
id: rtarea
...
onActiveFocusChange: { //Signal if you leave or enter the focus of rtarea
if(!activeFocus) { //if you are not in the TextArea
@dtoebe
dtoebe / main.qml
Created January 3, 2017 11:58
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.qml - 3
//assets/main.qml
import QtQuick 2.3
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.0
import TextConverter 1.0 //The import name is the string from the first param in the qml.RegisterTypes then the number 1 is from the next param, then dot third param
ApplicationWindow {
...
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:56
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 6
//main.go
...
func run() error {
qml.RegisterTypes("TextConverter", 1, 0, []qml.TypeSpec{{
// Above creates a importable type with an array of Type (qml.Objects) specifications
Init: func (h *HTMLText, obj qml.Object) { // Initializes the object and creates a pointer for HTMLText that we can reference from QML in the method we just created
h.Text = "Rich Text" //Sets default value... Could be anything
},
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:55
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 5
//main.go
...
type HTMLText struct {
...
}
func (h *HTMLText) SetHTMLText(txt string) {
//As you can see this is a method of HTMLText that uses a pointer that we will initialize after we write this code
formattedTxt := blackfriday.MarkdownCommon([]byte(txt)) //blackfriday takes a byte array so we have to convert the txt string to a []byte
@dtoebe
dtoebe / main.go
Created January 3, 2017 11:54
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.go - 4
//main.go
import {
...
}
type HTMLText struct {
qml.Object
Text string
}