Skip to content

Instantly share code, notes, and snippets.

南浦月 nanpuyue

View GitHub Profile
View tcp-rdhup.c
// date: 2020-07-06
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/epoll.h>
View sha2_constants.rs
// date: 2020-01-10
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
#![feature(generators)]
#![feature(generator_trait)]
use std::ops::{Generator, GeneratorState};
use std::pin::Pin;
View prime_generator.rs
// date: 2019-01-10
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
#![feature(generators)]
#![feature(generator_trait)]
use std::ops::{Generator, GeneratorState};
use std::pin::Pin;
View prime_generator.rs
// date: 2019-01-09
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
#![feature(generator_trait)]
use std::ops::{Generator, GeneratorState};
use std::pin::Pin;
use num_integer::Integer;
View sha2_constants.py
#!/usr/bin/env python3
# date: 2019-01-02
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
def sha2_iv(n: int) -> int:
square_root = pow(n, 1/2)
decimal = square_root - int(square_root)
return int(decimal * 0x100000000)
View crc32sum.rs
use std::env;
use std::fs::File;
use std::io::{stdin, Read};
use crc_all::CrcAlgo;
use lazy_static::lazy_static;
const BUFFER_SIZE: usize = 1024 * 16;
fn crc32sum<R: Read>(r: &mut R) -> u32 {
View openvpn-updown.sh
#!/bin/sh
# date: 2019-08-02
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
MARK=404
TABLE=404
SETNAME="surfing telegram"
VERBOSE=0
@nanpuyue
nanpuyue / main.go
Last active Jul 12, 2019
simple reverse proxy service on gae
View main.go
// date: 2019-07-12
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
package main
import (
"bufio"
"golang.org/x/net/context"
"google.golang.org/appengine"
@nanpuyue
nanpuyue / main.go
Last active Jul 13, 2019
simple reverse proxy service
View main.go
// date: 2019-07-12
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
package main
import (
"log"
"net/url"
"net/http"
View tree.g
// Date: 2010-06-21
// Author: Emden R. Gansner
// From: [graphviz-interest@research.att.com]
BEGIN {
double tw[node_t]; // width of tree rooted at node
double nw[node_t]; // width of node
double xoff[node_t]; // x offset of root from left side of its tree
double sp = 36; // extra space between left and right subtrees
double wd, w, w1, w2;
You can’t perform that action at this time.