Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle He 599316527

View GitHub Profile
@599316527
599316527 / dwc3_otg.c.patch
Last active Feb 8, 2021
[KERNEL] Z3TC (SGP611) USB OTG (host mode) + simultaneous charging!
View dwc3_otg.c.patch
--- a/drivers/usb/dwc3/dwc3_otg.c 2021-02-08 15:44:20.000000000 +0800
+++ b/drivers/usb/dwc3/dwc3_otg.c 2021-02-08 15:45:03.000000000 +0800
@@ -33,6 +33,18 @@
static int max_chgr_retry_count = MAX_INVALID_CHRGR_RETRY;
module_param(max_chgr_retry_count, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(max_chgr_retry_count, "Max invalid charger retry count");
+
+//Module param for aca enabling
+static bool aca_enable = 0;
+module_param(aca_enable, bool, S_IRUGO | S_IWUSR);
@599316527
599316527 / download-iqiyi-videos.js
Last active Dec 18, 2019
下载爱奇艺视频
View download-iqiyi-videos.js
const fse = require('fs-extra');
const uuid = require('uuid/v4');
const {spawnSync} = require('child_process');
const puppeteer = require('puppeteer');
// 从视频列表页读取视频URL(在 console 中执行)
function getLinks() {
let links = document.querySelectorAll('.qy-mod-link-wrap > a');
return Array.from(links).map(link => link.href);
}
@599316527
599316527 / prepareFfmpegInputVideoLists.js
Created Sep 20, 2019
米家摄像头 分钟 视频合并
View prepareFfmpegInputVideoLists.js
const path = require('path');
const fs = require('fs');
const cameraVideoDir = '/mnt/d/Oolong/xiaomi/xiaomi_camera_videos/04cf8cc737da';
let videoDateHourMinutes = fs.readdirSync(cameraVideoDir).filter(function (name) {
return /^\d{10}$/.test(name);
}).reduce(function (ret, name) {
let date = name.substring(0, 8);
if (!ret[date]) ret[date] = [];
@599316527
599316527 / sum-of-n-numbers.js
Last active Aug 15, 2019
N数之和 通解
View sum-of-n-numbers.js
function threeSum(nums, target) {
return uniq(findN(nums.sort(sortor), target, 3));
};
function fourSum(nums, target) {
return uniq(findN(nums.sort(sortor), target, 4));
};
@599316527
599316527 / intToRoman.js
Last active Aug 14, 2019
转罗马数字
View intToRoman.js
// Answer to https://leetcode-cn.com/problems/integer-to-roman/
function intToRoman(num) {
return [['X', 'V', 'I', 1], ['C', 'L', 'X', 10], ['M', 'D', 'C', 100], ['', '', 'M', 1000]]
.reduceRight(function (ret, item, index) {
let count = ~~(num / item[3]) % 10;
if (!count) return ret;
if (count % 5 == 4) return ret + item[2] + item[count > 5 ? 0 : 1];
return ret + item[1].repeat(count >= 5 ? 1 : 0) + item[2].repeat(count % 5);
}, '');
@599316527
599316527 / convert.sh
Last active Jul 17, 2019
ffmpeg compress video to a specific filesize
View convert.sh
#!/bin/zsh
ffmpegParam="-hide_banner -y";
videoEncodeParam="-c:v libx264 -crf 23 -profile:v main -level 3.1 -pix_fmt yuv420p -movflags +faststart -s 1024x768";
audioEncodeParam="-an";
fileSizeParam="-b:v 1.6M -maxrate 1.6M -bufsize 2m";
echo "Convert: $1 -> $2";
# Use two-pass to reduce size https://trac.ffmpeg.org/wiki/Encode/H.264
View from-nows-fun.txt
我本想享受生活,结果发现活下来都很困难。
你的计划,就像零食,吃到肚子里之后就是个屁。
我已经不是那个花五十块钱,也要考虑很久的小孩了,现在五块钱都要深思熟虑。
今天天气很好,在房间里宅久了,准备去客厅散散心。
春节你要小心了,毕竟过年,都是要杀猪的。
经过多年的打拼,虽然没有什么收获,但你有债呀!
人为什么叫人类,因为人活着就是累。
说错话不要紧,你还会继续说错的。
你倒下了,能顶替你的人千千万
你获得了很多金钱,但同时也失去了很多东西,比如烦恼。
View remove-soagent.sh
#!/usr/bin/env bash
# soagent consumes too much cpu resources for unknown reasons.
# The one way which i know so far to stop it is deleting it.
# Don't worry. An OS-update will take them back. (Just my personal experience)
rm -rf "/System/Library/LaunchAgents/com.apple.soagent.plist"
rm -rf "/System/Library/PrivateFrameworks/MessagesKit.framework/Versions/A/Resources/soagent.app"
rm -rf "~/Library/Application Scripts/com.apple.soagent"
rm -rf "~/Library/Containers/com.apple.soagent"
@599316527
599316527 / 0main.js
Last active Jun 14, 2018
Leaflet coordinates helper
View 0main.js
const L = require('./leaflet-0.5.0-coord-part')
const simpleCrs = L.Util.extend({}, L.CRS, {
code : 'simple',
projection : L.Projection.LonLat,
transformation : new L.Transformation(1,0,-1,0)
})
console.log(
L.CRS.EPSG3857.pointToLatLng(
@599316527
599316527 / get-map-images-curl-commands.js
Last active Jun 13, 2018
下载多玩地图图片块
View get-map-images-curl-commands.js
var path = require('path')
var fs = require('fs')
// 先在浏览器中把地图移动到右下角,一点一点放大,保证每个 level 的最大坐标的图片被请求了
// 然后 network 中 copy all as curl 保存到 urls.txt 里
var maxs = fs.readFileSync(path.join(__dirname, 'urls.txt'), 'utf8').split('\n').map(function (url) {
url = url.trim()
let i = url.indexOf('\'') + 1
return url.substring(i, url.indexOf('\'', i))