Skip to content

Instantly share code, notes, and snippets.

View bojand's full-sized avatar
💭
I may be slow to respond.

Bojan bojand

💭
I may be slow to respond.
View GitHub Profile
@bojand
bojand / main.rs
Created July 17, 2020 01:54
Rust Struct Lifetime
#![allow(unused)]
use std::fmt;
#[derive(Copy, Clone)]
pub struct Type<'a> {
mime_type: &'a str,
}
impl<'a> Type<'a> {
@bojand
bojand / code.go
Created January 30, 2019 21:22
gRPC Reflection Client
func TestRunReflection(t *testing.T) {
var cc *grpc.ClientConn
var opts []grpc.DialOption
var mtd *desc.MethodDescriptor
opts = append(opts, grpc.WithInsecure())
dialCtx := context.Background()
cc, err = grpc.DialContext(dialCtx, "host", opts...)
if err != nil {
@bojand
bojand / main.go
Created November 21, 2018 16:54
Functional options
package main
import (
"fmt"
"time"
)
type Config struct {
Secure bool
Timeout time.Duration
@bojand
bojand / patterns.md
Created September 11, 2018 13:31
Go concurrent patterns
@bojand
bojand / limit.go
Created July 7, 2018 22:51
go concurrency
package main
import (
"fmt"
"strings"
"time"
)
func upper(input string) string {
fmt.Println("upper " + input)
@bojand
bojand / README.md
Last active June 29, 2018 12:22
Simple WebAssembly fibonacci performance test

Simple, quick performance demo / test comparing JavaScript and WebAssembly. Uses fibonacci (n = 40) with 31 runs.

Convert fib.wat to wasm using wat2wasm tool and download as fib.wasm.

Use Node.js 10.

Run:

node index.js
@bojand
bojand / data.go
Last active June 14, 2018 17:42
parallel data
package main
import (
"encoding/json"
"fmt"
)
type User struct {
ID int `json:"id"`
Name string `json:"name"`
@bojand
bojand / apex.html
Last active August 8, 2018 22:27
Charts
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Apex chart test</title>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
@bojand
bojand / tags1.go
Created April 20, 2018 12:33
Go Tags
package main
import (
"fmt"
"reflect"
)
type User struct {
FullName string `json:"full_name" binding:"required"`
Age int `json:"age" binding:"required,min=1"`
@bojand
bojand / index.md
Last active May 16, 2022 19:32
gRPC benchmarks Go & Node.js