Skip to content

Instantly share code, notes, and snippets.

View corvofeng's full-sized avatar
Do You Want To Build A Snowman.

corvofeng corvofeng

Do You Want To Build A Snowman.
View GitHub Profile
@corvofeng
corvofeng / main.go
Created June 26, 2022 08:12
github device token
package main
// Refer to:
// https://github.com/golang/oauth2/pull/356/files/7cf8880eb1e002ce6fb90ffadae90b41452462e3
// https://docs.github.com/cn/developers/apps/building-oauth-apps/authorizing-oauth-apps#device-flow
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
@corvofeng
corvofeng / http-unix.go
Last active July 21, 2022 05:36
forward http request to unix socket
package main
import (
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
)
// From: https://stackoverflow.com/a/26224019/5563477
@corvofeng
corvofeng / http_ssh_tunnel.go
Created May 26, 2022 12:58
SSH tunnel to forward http port
package main
// Forward from local port 8001 to remote port 9999, by ssh tunnel
import (
"fmt"
"io"
"log"
"net"
"net/http"
// main
/**
* A golang ssh server which supports vscode remote ssh plugin.
*
* ssh_config:
* Host upterm
* HostName 192.168.101.135
* Port 2224
*
* VSCode remote ssh plugin use this command to setup its server, and use dynamic port fowarding to connect to this server.
@corvofeng
corvofeng / pic.py
Created May 5, 2019 01:42
Python使用matplotlib画图时显示中文
import matplotlib.pyplot as plt
import numpy as np
import math
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
x = np.arange(0, 10, 0.1)
@corvofeng
corvofeng / prod.sh
Last active October 18, 2020 02:29
快速配置自己的工作环境
#!/bin/bash
# 使用方式:
# curl https://gist.githubusercontent.com/corvofeng/f16a1fab54757f32879ae4d326c27518/raw/prod.sh | bash -
# curl -sL https://corvo.myseu.cn/xyz/prod.sh | bash -
sudo apt install -y git htop tmux zsh cscope ranger
function save_env() {
# 必须有两个参数, key, value
[ $# != 2 ] && return
@corvofeng
corvofeng / school_sort.js
Created May 20, 2018 11:08
姐姐托我给外甥女估分选个学校, 看到一个没排序的名单, 遂给其排序
// 基于网站 http://www.cunet.com.cn/gaozhao/HTML/239864.html
// 姐姐托我给外甥女估分选个学校, 看到了下面这个网址, 可是这里面的信息是没有排序的, 所以自己写了一个排序程序
// 可以按照分数进行排序.
var wrap = document.getElementsByClassName('wrap_centerfont');
var tbl = wrap[0].children[2];
var all_tbs = tbl.tBodies[0].children
@corvofeng
corvofeng / clock_test.c
Last active May 20, 2018 01:54
最近在写程序时, 误用clock()函数作为定时器, 导致最后结果出现了问题, 这里, 我贴一下自己的实验过程
/*
*=======================================================================
* Filename:clock_test.c
*
* Version: 1.0
* Created on: May 20, 2018
*
* Author: corvo
*
* gcc clock_test.c -o clock_test -lm
import urllib
import urllib.request
import json
import base64
def init():
res = urllib.request.urlopen('http://w.seu.edu.cn/index.php/index/init')
body = res.read()
@corvofeng
corvofeng / super_fibonacci.cpp
Last active April 21, 2018 02:20
超级斐波那契数列的计算
// 笔试题目的简单实现
// 请看博客: https://corvo.myseu.cn/2018/04/20/2018-04-20-斐波那契数列的Log(n)解法/
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <limits.h>
#include <cstdio>