Skip to content

Instantly share code, notes, and snippets.

View 599316527's full-sized avatar

Kyle He 599316527

View GitHub Profile
@599316527
599316527 / dwc3_otg.c.patch
Last active February 8, 2021 07:52
[KERNEL] Z3TC (SGP611) USB OTG (host mode) + simultaneous charging!
--- 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 April 22, 2023 13:14
下载爱奇艺视频
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 September 20, 2019 03:54
米家摄像头 分钟 视频合并
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 August 15, 2019 09:44
N数之和 通解
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 August 14, 2019 06:20
转罗马数字
// 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 July 17, 2019 13:16
ffmpeg compress video to a specific filesize
#!/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
我本想享受生活,结果发现活下来都很困难。
你的计划,就像零食,吃到肚子里之后就是个屁。
我已经不是那个花五十块钱,也要考虑很久的小孩了,现在五块钱都要深思熟虑。
今天天气很好,在房间里宅久了,准备去客厅散散心。
春节你要小心了,毕竟过年,都是要杀猪的。
经过多年的打拼,虽然没有什么收获,但你有债呀!
人为什么叫人类,因为人活着就是累。
说错话不要紧,你还会继续说错的。
你倒下了,能顶替你的人千千万
你获得了很多金钱,但同时也失去了很多东西,比如烦恼。
@599316527
599316527 / remove-soagent.sh
Last active November 21, 2018 06:38
Remove soagent
#!/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 June 14, 2018 14:01
Leaflet coordinates helper
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 June 13, 2018 15:23
下载多玩地图图片块
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))