Skip to content

Instantly share code, notes, and snippets.

View yjlcoder's full-sized avatar

Yang Liu yjlcoder

View GitHub Profile
@yjlcoder
yjlcoder / nginx_reverse_proxy_443
Created August 1, 2017 04:09
Nginx config in HTTPS for reverse proxy
server {
listen 80;
server_name yourdomain
# location / {
# proxy_pass https://localhost:10001;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Client-Verify SUCCESS;
# proxy_set_header X-Client-DN $ssl_client_s_dn;
@yjlcoder
yjlcoder / add_entry.sh
Created September 24, 2017 02:16
Add Windows 10 entry in archlinux grub and UEFI
# You could use `sudo os-prober` to determine the specific paramters
efibootmgr --create --disk /dev/sda --part 2 --loader /EFI/Microsoft/Boot/bootmgfw.efi --label "Windows 10"
efibootmgr --create --disk /dev/sda --part 2 --loader /EFI/Arch/grubx64.efi --label "Arch Linux"
grub-mkconfig -o /boot/grub/grub.cfg
@yjlcoder
yjlcoder / wpa_supplicant.sh
Created September 24, 2017 02:20
Solve the WiFi problem on Arch Linux with Intel 7265/7260
sudo echo "p2p_disabled=1" >> /etc/wpa_supplicant/wpa_supplicant.conf
@yjlcoder
yjlcoder / setup.sh
Created September 25, 2017 05:12
Script to setup megatools
printf "Email Address: "
read USERNAME
printf "Password: "
read PASSWORD
printf "Need Proxy?[y/n]: "
read PROXY
if [[ $PROXY == 'y' ]] || [[ $PROXY == 'Y' ]]; then
printf "Proxy Address(default=socks5://127.0.0.1:1080): "
read PROXY_ADDRESS
@yjlcoder
yjlcoder / fonts.conf
Created October 15, 2017 23:39
Fontconfig like macOS (~/.config/fontconfig/fonts.conf)
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hinting">
@yjlcoder
yjlcoder / get_grade.js
Last active November 9, 2017 11:37
Get students who don't submit homeworks
var table = $("#main_content").children("table").children("tbody");
var grade = {};
var grade_length = table.children().first().children().length - 3;
var children_number = table.children().length;
var number_index = 1;
table.children().each(function(index){
var grade_str = "";
var base = 3;
var i = 0;
@yjlcoder
yjlcoder / url_parser.py
Last active November 14, 2017 17:55
URL parser to parse json to literal sentences
#! /usr/bin/env python3
import argparse
import json
import os
import sys
def get_parser():
parser = argparse.ArgumentParser(description='Parse json to text file.')
@yjlcoder
yjlcoder / problem.md
Last active December 2, 2017 13:12
Discussion problems of Data structure class

Problem 1

Description

在卡卡的房子外面,有一棵苹果树。每年的春天,树上总会结出很多的苹果。卡卡非常喜欢吃苹果,所以他一直都精心的呵护这棵苹果树。我们知道树是有很多分叉点的,苹果会长在枝条的分叉点上面,且不会有两个苹果结在一起。卡卡很想知道一个分叉点所代表的子树上所结的苹果的数目,以便研究苹果树哪些枝条的结果能力比较强。

卡卡所知道的是,每隔一些时间,某些分叉点上会结出一些苹果,但是卡卡所不知道的是,总会有一些调皮的小孩来树上摘走一些苹果。

于是我们定义两种操作:

@yjlcoder
yjlcoder / cms-trace-spider.py
Last active January 21, 2018 06:38
cms-trace-spider
#!/usr/bin/env python
import json
from multiprocessing import Pool
import requests
def get_all_users():
resp = requests.get("http://dashb-cms-job.cern.ch/dashboard/request.py/listusers-api",
@yjlcoder
yjlcoder / generator.cpp
Created January 24, 2018 09:49
Mininet random topology generator
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#define True 1
#define False 0
#define SWITCH_NUM 10