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 / deps.go
Created December 26, 2017 00:18
Collect Go package dependency file tree (an overkilled version with multiple packages per file).
package main
func findDeps(p *build.Package, includes, excludes []string, debug bool) (map[string]map[string]struct{}, error) {
excludeRxs, err := compileRxs(excludes)
if err != nil {
return nil, err
}
deps := make(map[string]map[string]struct{}, len(p.Imports))
addDeps := func(parent, dep *build.Package) {
if !containsPrefix(dep.ImportPath, includes) {
/* Copyright (C) 1989-2014 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
#ifndef STDBOOL_H
#define STDBOOL_H
typedef int bool;
#define true 1
#define false 0
#endif // STDBOOL_H
@xlab
xlab / parse_json_number.go
Created February 2, 2017 20:17
JSON Number parsing for Go, ported from C version in cJSON
package parseFloat
import "math"
func Parse(num []byte) (n float64) {
var (
sign float64 = 1
scale int
subscale int
signsubscale int = 1
@xlab
xlab / tls_cert_management.go
Created January 10, 2017 13:00
A TLS Cert management example for Go server. For different domains.
package main
import (
"crypto/tls"
"flag"
"log"
"net/http"
"os"
"path/filepath"
"strings"
@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 / pump.go
Created November 10, 2016 22:06
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
type stopPumping struct{}
// pump returns a channel src such that sending on src will eventually send on
// dst, in order, but that src will always be ready to send/receive soon, even
// if dst currently isn't. It is effectively an infinitely buffered channel.
//
@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;