Skip to content

Instantly share code, notes, and snippets.

View barthr's full-sized avatar
🎯
Focusing

Bart barthr

🎯
Focusing
View GitHub Profile
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
var items = []string{}
@barthr
barthr / errors.go
Last active November 17, 2016 13:16
Persit errors golang
package errorstore
import "github.com/boltdb/bolt"
var (
errName = []byte("error")
)
type ErrorPersistance interface {
SetError(key, value string)
@barthr
barthr / Interpreter.fs
Created April 16, 2017 21:23
Interpreter of small Assembly machine
module SVM.Interpreter
type ProgramState =
{
ProgramCounter:int
Memory: list<(int * SVMAST.Literal)>
Registers: Map<string, SVMAST.Literal>
Labels: Map<string, int>
}
// Exercise 1
let isLeap (year:int) :bool =
year % 4 = 0 && year % 100 <> 0 || year % 400 = 0
// Exercise 3
let rec map mapFn list =
match list with
| [] -> []
| x::xs -> [mapFn x] @ map mapFn xs
@barthr
barthr / vector.go
Last active May 1, 2017 10:30
Vector class for golang
package statistic
import "math"
type Vector []float64
func (v Vector) Equal(other Vector) bool {
if other == nil || v == nil {
return false
}
@barthr
barthr / main.c
Created May 6, 2017 15:45
Merge sort in C
#include <stdio.h>
#include <stdlib.h>
void merge(int *c, int *left, int *right, size_t leftL, size_t rightL)
{
int i = 0;
int j = 0;
int k = 0;
while (i < leftL && j < rightL)
{
@barthr
barthr / wordcount-histogram.c
Last active June 1, 2017 18:25
Wordcount with histogram written in C
#include <stdio.h>
#include <stdlib.h>
#define MAXWORDLEN 20 // Maximum length of a word
#define IN 1 // Inside a word
#define OUT 0 // Outside a word
int main(void)
{
int c;
@barthr
barthr / strrindex.c
Created June 4, 2017 14:49
Exercise 4.1 from K&R C book
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int strrindex(char *s, char *t);
int main(void)
{
char items[] = "bartbartbart";
char items2[] = "rt";
@barthr
barthr / GUI.cs
Created June 25, 2017 13:52
test
using System;
namespace GUIapp
{
public abstract class GuiMenuCreator
{
public abstract GuiManager Instantiate(string option, System.Action exit);
}
@barthr
barthr / backup.go
Created June 5, 2017 19:55
Backup all your github repositories
package main
import (
"context"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"