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 / tpo.js
Created December 29, 2018 09:01
Extract TPO tests from "Xiao Zhan TOEFL"
const QUESTIONS = require('./t_question.json');
const ITEMS = require('./t_questionItem.json');
const ANSWERS = require('./t_answer.json');
const _ = require('lodash');
const result = _.map([13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], TPO_CNT => {
let questions = _.filter(QUESTIONS, question => question.app_name_sub == `tpo${TPO_CNT}` && question.passage == 'listening');
let items = _.map(questions, question =>
_.chain(ITEMS)
@skyzh
skyzh / djjoystick.py
Created November 20, 2018 12:31
Dajiang RoboMaster Joystick Integration
import serial
from struct import pack
from crccheck.crc import Crc8, Crc16
from time import sleep
CRC8_TAB = [ 0x00,0x5e,0xbc,0xe2,0x61,0x3f,0xdd,0x83,0xc2,0x9c,0x7e,0x20,0xa3,0xfd,0x1f,0x41,
0x9d,0xc3,0x21,0x7f,0xfc,0xa2,0x40,0x1e,0x5f,0x01,0xe3,0xbd,0x3e,0x60,0x82,0xdc,
0x23,0x7d,0x9f,0xc1,0x42,0x1c,0xfe,0xa0,0xe1,0xbf,0x5d,0x03,0x80,0xde,0x3c,0x62,
0xbe,0xe0,0x02,0x5c,0xdf,0x81,0x63,0x3d,0x7c,0x22,0xc0,0x9e,0x1d,0x43,0xa1,0xff,
0x46,0x18,0xfa,0xa4,0x27,0x79,0x9b,0xc5,0x84,0xda,0x38,0x66,0xe5,0xbb,0x59,0x07,
@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)
@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 / IPv6InCERNET.md
Last active November 1, 2018 11:44
A configuration of IPv6

这是啥?

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

在什么环境下使用?

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

怎么做到的?

@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 / 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 / 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 / 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 / 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