Skip to content

Instantly share code, notes, and snippets.

@tosone
tosone / docker.sh
Created October 11, 2019 07:40
[docker save] #docker
#for not running docker, use save:
docker save <dockernameortag> | gzip > mycontainer.tgz
#for running or paused docker, use export:
docker export <dockernameortag> | gzip > mycontainer.tgz
#load
gunzip -c mycontainer.tgz | docker load
@tosone
tosone / app.go
Last active October 25, 2020 06:42
请完成其中 Tester 的 io.Reader interface 相关函数
package main
import (
"io"
"log"
"os"
"github.com/gin-gonic/gin"
)
@tosone
tosone / Makefile
Created October 25, 2020 06:45
分析其中 data race 问题,并预估输出结果。
TARGET = main.test
CFLAGS += -std=c11 -I. -Os -pthread
LDFLAGS +=
CPPFLAGS += -Wall
all: main.o adding.o
$(CC) -o $(TARGET) $? $(LDFLAGS) $(LDLIBS)
test:
@tosone
tosone / exact.go
Last active October 25, 2020 06:50
exactcover problem
package main
import (
"fmt"
)
func tester(input [9]byte) bool {
return false
}
Go 19 hrs 30 mins ██████████▋░░░░░░░░░░ 50.9%
YAML 12 hrs 38 mins ██████▉░░░░░░░░░░░░░░ 33.0%
Other 2 hrs 1 min █░░░░░░░░░░░░░░░░░░░░ 5.3%
Docker 1 hr 35 mins ▊░░░░░░░░░░░░░░░░░░░░ 4.1%
Bash 55 mins ▌░░░░░░░░░░░░░░░░░░░░ 2.4%
CCFiles := $(wildcard *.cc)
.PHONY: cc
cc: $(CCFiles)
.PHONY: $(CCFiles)
$(CCFiles):
@echo Running `echo $@ | cut -d. -f1`:
@echo
@$(CXX) -std=c++17 -lm -Os -g3 -fsanitize=address,signed-integer-overflow \
@tosone
tosone / genpass.c
Created June 4, 2021 07:42 — forked from fabiomontefuscolo/genpass.c
Password generator
#include <getopt.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void showHelp(char *biname) {
printf("%s [-l length] [-f 'regex'] [-n]\n", biname);
printf(" -l, --length\n");
printf(" Password length\n");
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"io/ioutil"
@tosone
tosone / main.go
Created March 20, 2022 02:36
maven server tutorial
package main
import (
"crypto/sha1"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
@tosone
tosone / pprof.md
Created January 29, 2023 06:19 — forked from slok/pprof.md
Go pprof cheat sheet

Enable profiling

Default http server

import (
    _ "net/http/pprof"
    "net/http"
)