Skip to content

Instantly share code, notes, and snippets.

@stu43005
stu43005 / parser.js
Last active March 31, 2024 13:54
Prometheus data parser
module.exports = // @generated by Peggy 4.0.2.
//
// https://peggyjs.org/
(function() {
"use strict";
function peg$subclass(child, parent) {
function C() { this.constructor = child; }
C.prototype = parent.prototype;
child.prototype = new C();
@stu43005
stu43005 / brave-flags.js
Created March 4, 2024 12:23
My brave://flags settings
const disabled = [
`#brave-ntp-branded-wallpaper-demo`,
`#brave-adblock-cookie-list-default`,
`#brave-adblock-cookie-list-opt-in`,
`#brave-adblock-cosmetic-filtering`,
`#brave-adblock-csp-rules`,
`#brave-adblock-default-1p-blocking`,
`#brave-adblock-mobile-notifications-list-default`,
`#brave-adblock-scriptlet-debug-logs`,
`#brave-super-referral`,
@stu43005
stu43005 / UnlockOneDrive.ps1
Created September 21, 2023 03:23
Unlock OneDrive if it is disabled by company or school group policies.
$regpath = "HKLM:\Software\Policies\Microsoft\Windows\OneDrive"
$regname = "DisableFileSyncNGSC"
$OneDriveExe = $Env:LocalAppData + "\Microsoft\OneDrive\OneDrive.exe"
$value = Get-ItemPropertyValue -Path $regpath -Name $regname -ErrorAction SilentlyContinue
if ($value -eq 1)
{
$command = '-noprofile -command "Set-ItemProperty -Path {0} -Name {1} -Value 0 -ErrorAction SilentlyContinue"' -f $regpath,$regname
Start-Process powershell.exe -Wait -Verb RunAs -ArgumentList $command
@stu43005
stu43005 / gpt.ts
Last active September 2, 2023 16:10
import { writeAll } from "https://deno.land/std@0.199.0/streams/write_all.ts";
import { load } from "npm:cheerio";
import OpenAI from "npm:openai";
// @deno-types="npm:@types/js-beautify"
import beautify from "npm:js-beautify";
const res = await fetch("https://www.google.com/"); // 網址
const html = await res.text();
const $ = load(html);
$(
@stu43005
stu43005 / dc_archive.js
Last active November 11, 2023 02:17
用DiscordChatExporter匯出頻道訊息後,從指定的時間開始回放訊息
class ChatController {
/**
* @param {YoutubeController} yt
*/
constructor(yt) {
this.yt = yt;
this.isSticky = true;
}
get isSticky() {
return this._isSticky;
@stu43005
stu43005 / edit_system.img.sh
Created July 3, 2022 06:21
[筆記] 編輯 WSA system.img
# 擴充大小
system_size=$(( $(du -sB512 system.img | cut -f1) + 200000 ))
e2fsck -yf system.img
resize2fs system.img "$system_size"s
# 掛載映像檔
mkdir -p /tmp/system
sudo mount -o loop system.img /tmp/system
#
# << 在這邊編輯 /tmp/system 內容
#
@stu43005
stu43005 / gotoMemberOnlyPlaylist.js
Created October 11, 2021 12:38
Youtube goto MemberOnly playlist bookmark
const channelId = document.querySelector('meta[itemprop="channelId"]').content;
location.href = `https://www.youtube.com/playlist?list=UUMO${channelId.replace(/^UC/, "")}`;
// Bookmark:
// javascript: (() => { const i = document.querySelector('meta[itemprop="channelId"]').content;location.href=`https://www.youtube.com/playlist?list=UUMO${i.replace(/^UC/, "")}` })()
@stu43005
stu43005 / endpointToUrl.js
Created September 22, 2021 15:37
Youtube livechat navigationEndpoint parser
function endpointToUrl(navigationEndpoint, params, promise = false) {
if (!navigationEndpoint)
return null;
let url = "";
if (navigationEndpoint.commandMetadata && navigationEndpoint.commandMetadata.webCommandMetadata && navigationEndpoint.commandMetadata.webCommandMetadata.url) {
url = navigationEndpoint.commandMetadata.webCommandMetadata.url;
} else if (navigationEndpoint.searchEndpoint) {
url = "/results?search_query=" + encodeURIComponent(navigationEndpoint.searchEndpoint.query).replace(/%20/g, "+");
if (navigationEndpoint.searchEndpoint.params) { url += "&sp=" + navigationEndpoint.searchEndpoint.params; };
} else if (navigationEndpoint.watchEndpoint) {
$json = (Invoke-WebRequest -Uri https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest).Content
$release = ConvertFrom-Json -InputObject $json
$exe = $release.assets | ? { $_.name -eq "yt-dlp.exe" }
Invoke-WebRequest -Uri $exe.browser_download_url -OutFile yt-dlp.exe
@stu43005
stu43005 / windows-explorer-fix-ts-files.reg
Created June 16, 2021 14:13
fxxk windows explorer fix ts files
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.ts]
@="VSCode.ts"
"Content Type"="text/plain"
"PerceivedType"="text"
[-HKEY_CLASSES_ROOT\.ts\ShellEx\{BB2E617C-0920-11D1-9A0B-00C04FC2D6C1}]
[-HKEY_CLASSES_ROOT\.ts\ShellEx\{e357fccd-a995-4576-b01f-234630154e96}]