Skip to content

Instantly share code, notes, and snippets.

@optman
optman / main.cc
Created March 26, 2021 08:35
tls and rcu
#include <iostream>
#include <thread>
#include <chrono>
#include <deque>
using Params = std::shared_ptr<int>;
thread_local Params tls_params;
using Queue = std::deque<Params>;
@optman
optman / ytun.go
Created June 25, 2020 08:25
port forwarding with yamux (Go)
package main
import (
"flag"
"github.com/hashicorp/yamux"
"io"
"log"
"net"
"sync"
)
@optman
optman / ytun.rs
Last active June 25, 2020 12:23
port forwarding with yamux (Rust)
use futures::future;
use futures::io::{self, AsyncReadExt, AsyncWriteExt};
use async_std::net::{TcpListener, TcpStream};
use async_std::prelude::*;
use async_std::task;
use std::sync::Arc;
use yamux;
use clap::{Arg, App};
@optman
optman / unbound.conf
Last active December 2, 2019 06:49
unbound + chinadns
server:
interface: 0.0.0.0
access-control: 0.0.0.0/0 allow
verbosity: 1
do-tcp: yes #enable tcp listening
tcp-upstream: no #chinadns not support tcp
module-config: "iterator" #disable dnssec validator
do-not-query-localhost: no #enable forward to localhost
forward-zone:
name: "."
@optman
optman / build_for_edge_router_x
Last active November 26, 2019 07:36
build chinadns and minivtun for edge router x
podman pull docker.io/dockcross/linux-mipsel
podman run -ti --rm -v `pwd`:/work docker.io/dockcross/linux-mipsel bash
git clone chinadns, libressl, minivutn ....
chinadns
./configure --host mipsel-linux-gnu-
make
@optman
optman / .vimrc
Last active September 19, 2019 07:35
gen python tags
au FileType python setlocal tags+=~/.vim/tags/pylibs.tags
@optman
optman / archivemount
Created January 23, 2019 03:33
mount archive file
archivemount mydoc.tar ~/tmp
fusermount -u ~/tmp
or
mc
@optman
optman / sinwave_lstm.py
Created January 18, 2018 07:17
sine wave lstm
#fork from https://github.com/jaungiers/LSTM-Neural-Network-for-Time-Series-Prediction
#minor fix, simpler model and normalize algorithm
import os
import time
import warnings
import numpy as np
from numpy import newaxis
from keras.layers.core import Dense, Activation, Dropout
from keras.layers.recurrent import LSTM
/opt/graphite/conf/storage-schemas.conf
[default]
pattern = .*
retentions = 10s:6h,10min:180d,1h:10y
/opt/graphite/storage/whisper/stats/gauges/..../2.wsp
whisper-info.py 2.wsp
@optman
optman / Dockerfile
Created November 16, 2017 03:34
keras cpu Dockerfile
FROM ubuntu:14.04
RUN sudo apt-get update && apt-get -y install python-dev python-pip libopenblas-dev liblapack-dev libatlas-dev libblas-dev gfortran
RUN sudo pip install keras
RUN sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp27-none-linux_x86_64.whl