Skip to content

Instantly share code, notes, and snippets.

View skyzh's full-sized avatar
🐱
working

Alex Chi Z. skyzh

🐱
working
View GitHub Profile
@skyzh
skyzh / iptables-playground.sh
Last active August 15, 2018 03:16
Play with iptables in docker
#!/usr/bin/env bash
docker run -it --privileged --network pub_net skyzh/iptables-playground bash
@skyzh
skyzh / bot.js
Created August 22, 2018 03:37
Simple QQ repeat Bot
const {Builder, By, Key, until} = require('selenium-webdriver');
let processed_text = {};
(async function do_fetch() {
let driver = await new Builder().forBrowser('chrome').build();
try {
await driver.get('http://web2.qq.com');
while(true) {
await driver.wait(until.elementLocated(By.id("panelTitle-5")));
@skyzh
skyzh / 8queen.cpp
Created August 25, 2018 13:40
Eight Queen Problem
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 12;
int queen_status[N];
/*
* AAAA
@skyzh
skyzh / maze.cpp
Created August 25, 2018 13:55
Find path of maze
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
struct queue_item {
int x, y;
int step;
@skyzh
skyzh / course_export.js
Last active January 29, 2019 14:21
Read course data
const data = require('./data.json');
const reg = {
time: /星期(.*?)[ ]+第(.*?)节--第(.*?)节/,
header: /行课安排为第(.*?)-(.*?)周?,其中:/,
loc: /(.*?)\((.*?)-(.*?)周\)[ ]+(.*?)\((.*?)-(.*?)周\)/,
loc_unknown: /[ ]*(.*?)[ ]+(.*?)\((.*?)-(.*?)周\)/,
bi_week: /(单|双)周/
};
const fetch_data = {
header: ["week_start", "week_end"],
@skyzh
skyzh / class_generator.js
Last active September 9, 2021 02:58
Use predefined file to generate class table.
const data = require('./data');
const _ = require('lodash');
const moment = require('moment');
const ics = require('ics');
const fs = require('fs');
const timePeriod = (date, from, to) => {
const _from = moment(`${date} ${data.timetable.data[from - 1]}:00`);
const _end = moment(`${date} ${data.timetable.data[to - 1]}:00`).add(data.timetable.length, 'minute');
return [_from, _end];
@skyzh
skyzh / IPv6InCERNET.md
Last active November 1, 2018 11:44
A configuration of IPv6

这是啥?

OpenWRT 的一套配置,用于在教育网宿舍里的路由器上部署,使得子网内的设备可以获取到全球路由的 IPv6 地址。

在什么环境下使用?

上海交通大学闵行校区大部分宿舍。宿舍网络通过 DHCPv6 下发 IPv6 地址(不支持 PD),因而路由器得到的是 /128 地址,无法再次分配给子网内设备。

怎么做到的?

@skyzh
skyzh / bsp_can.c
Last active November 8, 2018 05:50
Dajiang C620 PID from official website
/******************************************************************************
/// @brief
/// @copyright Copyright (c) 2017 <dji-innovations, Corp. RM Dept.>
/// @license MIT License
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction,including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense,and/or sell
/// copies of the Software, and to permit persons to whom the Software is furnished
/// to do so,subject to the following conditions:
@skyzh
skyzh / liveplot.py
Created October 27, 2018 16:29
Live Plot
import matplotlib.pyplot as plt
from matplotlib import animation
from numpy import random
LINE_NUM = 6
DATA_NUM = 100
LABEL=["ax","ay","az","gx","gy","gz"]
fig = plt.figure()
ax = plt.axes(xlim=(0, DATA_NUM), ylim=(-5000, 5000))
@skyzh
skyzh / barcode_scanner.py
Created November 14, 2018 07:30
Simple barcode scanner
import numpy as np
import cv2
import pyzbar.pyzbar as pyzbar
cap = cv2.VideoCapture(0)
def decode(im) :
# Find barcodes and QR codes
decodedObjects = pyzbar.decode(im)