Skip to content

Instantly share code, notes, and snippets.

View xlab's full-sized avatar
:octocat:
Hacking

Max Kupriianov xlab

:octocat:
Hacking
View GitHub Profile
1. Founder has all permissions.
2. Everyone in the chatroom can verify that public key X is indeed founder's key, it's a property of the chatroom and no peer stores it i.e. the chatroom itself contains that information somewhere, presumably in its ID (we don't rely on chatroom peers storing that data because they can came up with whatever they want i.e. say that the key X is not founder's key; we want that verification to be 100% exact and to work with even 1 peer in the chatroom).
3. To give permissions to user A, founder gives user A data which tells what permission level does A have (if we are going to have permission levels in tox at all). The data is signed by founder's private key.
4. Now A can show anyone that signed by founder data from the step (3) as a proof of her having permissions (anyone can verify that it was indeed signed by founder by (2)), so A can exercise her rights over everyone in the chatroom.
5. If A gives permissions to B, 1) A sends her founder-signed data to B to show that she i
@xlab
xlab / Makefile
Created July 24, 2015 22:30
A Makefile for Golang projects (via @cznic)
.PHONY: all clean cover cpu editor internalError later mem nuke todo
grep=--include=*.go --include=*.l --include=*.y
all: editor
go vet
golint
make todo
clean:
@xlab
xlab / main.go
Created July 27, 2015 10:47
golang closer with manners webserver
package main
import (
"io"
"log"
"net/http"
"time"
"github.com/braintree/manners"
"github.com/xlab/closer"
@xlab
xlab / util.go
Last active August 29, 2015 14:26
CGO util from Go-SQLite
// Copyright 2013 The Go-SQLite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite3
/*
#include "sqlite3.h"
*/
import "C"
@xlab
xlab / HOWTO
Last active August 29, 2015 14:26
$ go run main.go
@xlab
xlab / test.h
Last active August 29, 2015 14:26
#pragma once
enum Options {
One, Two, Three
};
const char *hello = "hello world!";
@xlab
xlab / gist:e21f535ac45a42cb937c
Last active August 29, 2015 14:27 — forked from davecheney/gist:6740651
gccgo on armv7
localhost(~/src) % gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/opt/libexec/gcc/arm-linux-gnueabihf/4.8.2/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../gccgo/configure --prefix=/opt --enable-languages=c,c++,go --with-ld=/usr/bin/ld --enable-shared --without-included-gettext --enable-threads=posix --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --with-system-zlib --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.8.2 20130927 (prerelease) (GCC)
localhost(~/src) % go run -compiler gccgo helloworld.go
Hello gccgo
@xlab
xlab / cgo_multi_arrays.c
Last active August 25, 2015 22:52
How CGO sees muti arrays when used as vars and as function params.
char a1; // type of a1 is C.char
char *a2; // type of a2 is *C.char
char a3[1]; // type of a3 is [1]C.char
char a4[1][2]; // type of a4 is [1][2]C.char
char a5[1][2][3]; // type of a5 is [1][2][3]C.char
char *a6[1][2][3]; // type of a6 is [1][2][3]*C.char
char **a7[1][2][3]; // type of a7 is [1][2][3]**C.char
char ***a8[1][2]; // type of a8 is [1][2]***C.char
char *a9[1][2]; // type of a9 is [1][2]*C.char
char **a10[1]; // type of a0 is [1]**C.char
@xlab
xlab / GoWithC.go
Last active September 2, 2015 20:31 — forked from 17twenty/GoWithC.go
Cross Compiling and Language Interop oh my!
package main
import (
"./binding"
"fmt"
)
func main() {
binding.PrintHello()
binding.Seed(1)
fmt.Println(binding.Random())
Говорил Керниган Пайку: Ты погодь язык свой писать, покамест три книжки со мной в соавторстве не напишешь!
Написал Роб Пайк один язык с каналами, отнес его Кернигану, а тот лишь в бороду ухмыляется
Рассстроился молодой Роб, но виду не подал.
Пошел писать терминал графический и вышел он у него краше некуда. Да только к тому времени люди про терминалы уже и думать забыли (edited)
Тогда решил уже повзрослевший Пайк второй язык написать, да не просто написать а в наикрутейшем редакторе
А так как такого не было, написал свой
А потом написал в нем второй свой язык.
И пошел гордый собой свой язык, написанный в новом супер редакторе Кернигану показывать
А тот как увидел – стал языком цокать, да только не на язык глядючи, а на редактор.
Хорош у тебя редактор вышел, говорит. Молодец!