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
@xlab
xlab / CryptoUtils.js
Created July 13, 2018 03:16 — forked from nakov/CryptoUtils.js
JS Crypto Utils - secp256k1 EC cryptography and blockchain functions
const CryptoJS = require("crypto-js");
const EC = require('elliptic').ec;
const secp256k1 = new EC('secp256k1');
function publicKeyToAddress(pubKey) {
let address = CryptoJS.RIPEMD160(pubKey).toString();
return address;
}
function privateKeyToPublicKey(privKey) {
@xlab
xlab / main.go
Created December 25, 2016 18:00 — forked from phrozen/main.go
STL reader
package main
import (
"bufio"
"bytes"
"encoding/binary"
"flag"
"fmt"
"github.com/spf13/nitro"
"io"
@xlab
xlab / VkComputeSample
Created November 8, 2016 02:59 — forked from sheredom/VkComputeSample
A simple Vulkan compute sample
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
@xlab
xlab / midiKeyboard64keys.c
Created September 20, 2016 18:44 — forked from codetinkerhack/midiKeyboard64keys.c
midiKeyboard64keys.c
// Pin Definitions
// Rows are connected to
const int row1 = 5;
const int row2 = 6;
const int row3 = 7;
const int row4 = 8;
const int row5 = 4;
const int row6 = 3;
const int row7 = 2;
const int row8 = 1;
@xlab
xlab / midiKeyboard_VelocityAftertouch.c
Created September 20, 2016 18:44 — forked from codetinkerhack/midiKeyboard_VelocityAftertouch.c
Arduino based Velocity sensitive Midi keyboard with Aftertouch
// Pin Definitions
// Rows are connected to Digital
const int rowPin[] = { 6, 7, 8, 5 };
// FSRs connected to Analog
const int fsrPin[] = { 2, 3, 4, 5 };
// The 74HC595 uses a serial communication
// link which has three pins
const int clock = 12;
@xlab
xlab / CGO.md
Created January 4, 2016 21:43 — forked from dwbuiten/CGO.md

Problems & Solutions for Interaction Between C and Go

At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.

Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.

Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.

Table of Contents

@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())
@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
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 / Dockerfile
Last active August 29, 2015 14:08 — forked from lox/Dockerfile
FROM progrium/busybox
ADD https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt /etc/ssl/ca-bundle.pem