Skip to content

Instantly share code, notes, and snippets.

View futurist's full-sized avatar

James Yang futurist

  • China
View GitHub Profile
@thomaspoignant
thomaspoignant / Makefile
Last active April 30, 2024 10:55
My ultimate Makefile for Golang Projects
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=example
VERSION?=0.0.0
SERVICE_PORT?=3000
DOCKER_REGISTRY?= #if set it should finished by /
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
GREEN := $(shell tput -Txterm setaf 2)
@niklaskorz
niklaskorz / goroutines.go
Last active May 5, 2023 09:51
Threading Performance Comparison
package main
import (
"fmt"
"os"
"runtime"
"sync"
"time"
)
@tsidea
tsidea / spawn_ws_conn.rs
Last active September 14, 2022 04:22
spawn task to handle websocket connection
use hyper::upgrade;
use tokio_tungstenite::WebSocketStream;
use futures::stream::StreamExt;
...
tokio::spawn(async move {
//using the hyper feature of upgrading a connection
match upgrade::on(&mut request).await {
//if successfully upgraded
@snoyberg
snoyberg / main.rs
Created December 29, 2020 16:33
HTTP reverse proxy in Rust, from December 29, 2020 livestream
use hyper::{Client, Server, Request, Response, Body};
use anyhow::*;
use std::net::SocketAddr;
use hyper::service::{make_service_fn, service_fn};
use std::sync::{Arc, RwLock};
fn mutate_request(req: &mut Request<Body>) -> Result<()> {
for key in &["content-length", "transfer-encoding", "accept-encoding", "content-encoding"] {
req.headers_mut().remove(*key);
}
@bassem-mf
bassem-mf / GettingStartedTutorial1Commands.txt
Last active October 9, 2023 19:58
Getting Started With Graph Databases, Apache TinkerPop, and Gremlin - Tutorial 1
// Create an instance of the "Modern" toy graph
graph = TinkerFactory.createModern()
// Create the traversal source
g = graph.traversal()
// Get all vertices
@kalepail
kalepail / boilerplate-contract.js
Last active August 25, 2023 04:11
A really easy way to get started with smart contracts on Turing Sign Servers is to upload the code below changing the `hostname` to link to an endpoint where your actual contract logic lives. This allows you to change and modify your contract logic freely. Great for testing before locking in a more immutable contract state.
const { request } = require('https')
module.exports = (body) =>
new Promise((resolve, reject) => {
try {
body = JSON.stringify(body)
const options = {
hostname: 'contract-logic-endpoint.io', // runkit and glitch are my goto services
port: 443,
@estesp
estesp / ctr-snapshot-mounts-example.md
Last active December 12, 2023 13:36
example of using ctr snapshot mounts

pull an image

root@ubu1804vm:~# ctr image pull docker.io/library/redis:latest
docker.io/library/redis:latest:                                                   resolved       |+++++++++++++++++++++++++++++++docker.io/library/redis:latest:                                                   resolved       |++++++++++++++++++++++++++++++++++++++|
index-sha256:ddf831632db1a51716aa9c2e9b6a52f5035fc6fa98a8a6708f6e83033a49508d:    done           |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:780f7dacdc133e899fba9ff09c099828b469030acefe6f3bbc16197b55800cfd: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:75797de34ea7abaf8ebd484896a21f5bda63ffbcade7217dad0be0b8b8333bde:    done           |++++++++++++++++++++++++++++++++++++++|
config-sha256:f0453552d7f26fc38ffc05fa034aa7a7bc6fbb01bc7bc5a9e4b3c0ab87068627:   done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:68ced04f60ab5c7a5f1d0b0b4e7572c5a4c8cce44866513d30d9df1a15277d6b:    done           |+++++++++++++++++++++
@CodyKochmann
CodyKochmann / deb-install-podman.sh
Created February 18, 2020 14:29
install podman on debian 10 and kali linux
echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_10/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_10/Release.key -O- | apt-key add -
apt update
apt install podman
@undernewmanagement
undernewmanagement / docker-compose.yml
Created January 29, 2020 01:07
Pristine config for Traefik 2.0, Docker, and LetsEncrypt with sample container. Includes a HTTP to HTTPS redirect
version: '3'
services:
traefik:
container_name: traefik
image: traefik:v2.0
command:
- "--api.insecure=true"
- "--providers.docker=true"
@bantya
bantya / setup-mysql-8.md
Created October 16, 2019 11:56
Setup MySQL 8
  1. Install MySQL-8.0 from [here].

  2. Open Terminal and go to /MySQL-8.0/bin directory.

  3. Run mysqld --initialize.

    This will initialize the mysql data directory at location specified in /MySQL-8.0/my.ini file; if not, it will initialize the data directory inside /MySQL-8.0/data.

  4. Run mysqld --console command.