Skip to content

Instantly share code, notes, and snippets.

View gasparian's full-sized avatar
👾

Andrey Gasparyan gasparian

👾
View GitHub Profile
package main
import (
"log"
"runtime"
)
// PrintMemUsage __
func PrintMemUsage() {
var m runtime.MemStats
func generateCreateTableQueryByModel(t interface{}) string {
var queryBuilder strings.Builder
queryBuilder.WriteString("CREATE TABLE IF NOT EXISTS ")
val := reflect.TypeOf(t)
queryBuilder.WriteString(fmt.Sprintf("%s (", strings.ToLower(val.Name())))
n := val.Field(0).Name
tp := val.Field(0).Type.String()
queryBuilder.WriteString(fmt.Sprintf("%s %s PRIMARY KEY,", strings.ToLower(n), sqliteTypesMap[tp]))
for i := 1; i < val.NumField(); i++ {
n = val.Field(i).Name
// Serialize dumps object to byte array via gob encoder
func Serialize(obj interface{}) ([]byte, error) {
buf := &bytes.Buffer{}
enc := gob.NewEncoder(buf)
err := enc.Encode(obj)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
@gasparian
gasparian / sources.list
Created March 19, 2021 09:33 — forked from malikalichsan/sources.list
/etc/apt/sources.list for ubuntu 19.10
# deb cdrom:[Ubuntu 19.10 _Eoan Ermine_ - Release amd64 (20191017)]/ eoan main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
# deb-src http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan-updates main restricted
@gasparian
gasparian / sources.list
Created March 17, 2021 18:08 — forked from rhuancarlos/sources.list
Ubuntu 18.04 Bionic default /etc/apt/sources.list
#deb cdrom:[Ubuntu 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)]/ bionic main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
@gasparian
gasparian / dump_load_bytes.go
Last active December 28, 2020 11:22
Golang code snippet to write and load bytearray on disk
import (
"io"
"os"
"bytes"
)
// DumpBytesToFile writes byte array to the file
func DumpBytesToFile(inp []byte, path string) error {
f, err := os.Create(path)
if err != nil {
@gasparian
gasparian / context_cancellation.go
Last active December 16, 2020 07:36
Small go server example which describes stopping the request processing which was canceled by the client
package main
import (
"context"
"net/http"
"log"
"time"
)
func getDbHelper() <-chan bool {

Install wine:

https://wiki.winehq.org/Ubuntu

Create game folder and copy installer there:

mkdir ./heroes_wine
mkdir ./heroes_wine/heroes
cp /home/user/Downloads/HotA_1.6.1_setup.exe /home/user/Documents/heroes_wine
@gasparian
gasparian / get_poses.py
Last active April 28, 2020 15:55
kitti_raw_imu
import os
import re
import sys
import shutil
import argparse
from tqdm import tqdm
parser = argparse.ArgumentParser(description='')
parser.add_argument("--path", type=str, required=False, default="./data")