Skip to content

Instantly share code, notes, and snippets.

View winrey's full-sized avatar

Winrey winrey

  • Founder of Weight Wave
  • Cyber Space
  • 08:42 (UTC +08:00)
View GitHub Profile
@winrey
winrey / change-source.sh
Created January 1, 2020 16:31
Auto change source in china
#!/usr/bin/env sh
echo "Checking whether Chinese Environment...";
echo "ENV \$IN_CHINA: $IN_CHINA"
if [ $IN_CHINA ]; then
echo "Detected Chinese Environment." ;
if (command -v apk); then
echo "Detected apk package manager." ;
VERSION_NUM="v3.10" ;
echo -e "https://mirrors.aliyun.com/alpine/$VERSION_NUM/main\nhttps://mirrors.aliyun.com/alpine/$VERSION_NUM/community" > /etc/apk/repositories ;
fi
@winrey
winrey / replace.py
Created August 5, 2019 07:21
Replace all the CRLF in files under one folder to LF on Windows by Python3
import os
def traverse(f):
fs = os.listdir(f)
for f1 in fs:
tmp_path = os.path.join(f,f1)
if not os.path.isdir(tmp_path):
print('Detected File: %s'%tmp_path)
f1 = open(tmp_path, "r")
@winrey
winrey / a-svg-flag.html
Last active February 18, 2019 14:44
A SVG flag
<html>
<head>
<title>旗帜SVG演示</title>
<meta charset="UTF-8">
<style>
body{
background-color: #334b6c;
}
@winrey
winrey / tsp.py
Last active May 15, 2018 12:03
由python实现的基于动态规划原理的TSP问题求解
def input_data():
num = 4 # 城市数量
c_map = [[0, 1, 10],
[1, 3, 25],
[2, 3, 30],
[0, 2, 15],
[1, 2, 35]]
def trans_map_to_mat(num, map):
mat = [[float("inf")] * num for i in range(num)]