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 / convert.py
Created July 13, 2018 07:38
Embed secret video into another video with FFT and IFFT
import numpy as np
import cv2
from numpy.fft import fft2, ifft2
import numpy as np
cap = cv2.VideoCapture('data.mp4')
cap2 = cv2.VideoCapture('in.mp4')
DENSITY = 10
@skyzh
skyzh / 2017_Gaokao_Data.md
Last active August 9, 2018 03:25
2017 上海市综合评价招生参考数据

数据来源: 阳光高考

上海交通大学 2017 年综合评价物理专业组 已录取考生高考成绩与面试分数的关系

screen shot 2018-06-23 at 3 32 33 pm

上海交通大学 2017 年综合评价物理专业组 已录取考生面试成绩分布

screen shot 2018-06-23 at 3 33 21 pm

上海交通大学 2017 年综合评价所有专业组 已录取考生高考成绩与面试分数的关系

@skyzh
skyzh / money.py
Created June 16, 2018 02:39
Everyone gives one coin to others at a time, iteration 10000 times
import numpy as np
from matplotlib import pyplot as plt
NUM_PEOPLE = 10000
SHUFFLE_SEQ = np.arange(NUM_PEOPLE)
coins = np.ones(NUM_PEOPLE) * 100
for i in range(100000):
@skyzh
skyzh / bsdata.csv
Last active January 29, 2019 14:22
BlueSense Hourly Data Summary (2017)
We can't make this file beautiful and searchable because it's too large.
time,hum,pm01,pm10,pm25,tc,pressure
1496055566.9861677,44.4780655859387,11.685786224350602,15.028218400689576,13.864547438152512,29.63095288049607,
1496059170.883296,48.802584171295166,11.749699074074075,14.9380787037037,13.80851851851852,29.29816748936971,
1496062774.7723284,49.04658399899801,12.923555068226118,16.577614522417157,15.315606725146198,28.989999961853027,
1496067441.328689,51.788095235377014,9.65302374293221,12.148919778310509,11.25103238924606,28.872821715218688,
1496071045.2175376,53.20250063896178,7.9643287037037025,10.032731481481477,9.283449074074074,28.628667157491048,
1496075042.9485977,54.61931124918388,8.610370370370369,10.613842592592594,9.854004629629632,28.40766700267791,
1496078646.8541663,56.04033413887023,8.788773148148149,10.723796296296292,10.073194444444443,28.132917173703497,
1496082250.7668355,56.885917924245184,7.483635477582846,9.139502923976606,8.550604288499024,27.993999977111816,
1496085854.6636848,57.2112507279714,7.639215399610135,9.46486842105263,8.80893762183236,27.8
@skyzh
skyzh / Anki.md
Last active April 11, 2019 04:17
Review Anki cards on Kindle
  1. Use Basic Print Support Anki addon.
  2. Print to HTML
  3. Apply CSS
  4. Print to PDF

This CSS adds card number and forces page break after each card.

image

@skyzh
skyzh / Bear.md
Created April 18, 2018 15:04
Prepare Bear App exported notes for printing

Texts are darkened and serif-ied for better printing visual effects.

Before

image

After

image

@skyzh
skyzh / Todoist-Fantastical-Sorted.md
Last active April 22, 2018 03:42
Sync Todoist tasks to Fantastical and many other apps
  1. Create a project like this (parent tasks with children of one level indent), and assign due dates. image
  2. Run main.py in Terminal, input project id, press enter and copy the generated texts. image
  3. In Drafts 4 on iOS, paste and run Quick-Add to Fantastical Reminder workflow. image
  4. In Sorted or any other apps, use functionalities like Reminder Capture to import these tasks. image
@skyzh
skyzh / index.js
Created December 23, 2017 03:21
Export Anki cards to HTML
/*
How to use?
Install Node.js and run 'npm init', than install the dependency 'lodash'.
Install the Anki addon from 'https://ankiweb.net/shared/info/1788670778', and export your deck to JSON.
Run 'node index.js', and there will be a generated 'index.html'.
*/
const _ = require('lodash');
const fs = require('fs');
@skyzh
skyzh / main.py
Last active July 28, 2017 14:39
Mock Transaction: N people have `DEFALUT_WALLET` CNY at the beginning, and will transfer 1 CNY to another person in each round. After R rounds, this program will print how much money each person has.
#!/usr/bin/env python3
import random
DEFAULT_WALLET = 100
N = 100
R = 100
def do_transaction(storage, id_from, id_to):
storage[id_from] -= 1
@skyzh
skyzh / index.js
Created June 16, 2017 12:11
This script will parse Data under College English Disc to a html containing all answers.
const _ = require('lodash');
const Promise = require('bluebird');
const parser = Promise.promisifyAll(new require('xml2js').Parser());
const fs = Promise.promisifyAll(require('fs'));
let output = "";
fs.readdirAsync(`${__dirname}/data`)
.filter(file => /^1U0[6-7]p[A-Z0-9]{2}[A-F].xml$/.test(file))
.map(file => {