Skip to content

Instantly share code, notes, and snippets.

View MicroCBer's full-sized avatar
💭
Studying

MicroBlock MicroCBer

💭
Studying
View GitHub Profile
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@MicroCBer
MicroCBer / fanctrl.sh
Created January 27, 2024 12:21
Basic fan control script for P40
#!/bin/bash
# Check if running with sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run with sudo:"
echo "sudo $0"
exit
fi
# Enable PWM
@MicroCBer
MicroCBer / cloneEx.js
Created August 17, 2023 08:22
Create an element delegate/proxy in js
const createElementDelegate = (ele, config) => {
const old2NewMap = new WeakMap(), new2OldMap = new WeakMap();
const clone = (ele, {cloneParent, syncProps, delegateEvents=true, delayedElementListChange}={}) => {
if(ele == null) return ele;
// clone, and delegate events, and preserve parent classes
let cloned = ele.cloneNode();
old2NewMap.set(ele, cloned);
new2OldMap.set(cloned, ele);
// clone child also
@MicroCBer
MicroCBer / ProgressFloatingWindow.js
Created July 13, 2023 17:32
进度浮窗,支持多窗口
class FloatingWindow {
static instanceCount = 0;
constructor() {
let body = document.body;
this.containerDiv = document.createElement('div');
this.containerDiv.setAttribute('style',
`bottom: ${10 + 110 * FloatingWindow.instanceCount}px;`
);
@MicroCBer
MicroCBer / findPaths.js
Last active April 20, 2024 08:35
find value in object
function findPaths(obj, kwd, maxDepth = 1, exclude=[]) {
const paths = [];
function exploreObject(obj, path, depth) {
if (depth > maxDepth) {
return;
}
for (const key in obj) {
const value = obj[key];
@MicroCBer
MicroCBer / inspect-object.js
Last active July 18, 2023 12:52
Inspect operations on an object
const apiMap = {}
function make_proxy(obj, path = '') {
if (typeof obj === "object" || typeof obj === "function")
return new Proxy(obj, {
get(target, prop) {
if (prop === '_origin_') return obj._origin_ ?? obj;
const fullPath = path ? `${path}.${String(prop)}` : String(prop);
@MicroCBer
MicroCBer / ncm.css
Created April 8, 2023 07:37
NCM PC Client CSS
This file has been truncated, but you can view the full file.
// extracted from ncm 2.10.8, with lots of betterncm plugins installed
.playbackrate-settings { right: 140px !important; }.playbackrate-settings-popup { position: fixed; transition: opacity 0.2s ease 0s, transform 0.2s ease 0s; opacity: 0; padding: 15px; border-radius: 10px; background-color: rgba(0, 0, 0, 0.204); backdrop-filter: blur(10px); transform: translateY(10px); z-index: 99999; color: white; }.playbackrate-settings-popup * { color: white; }.pbr-slider-wrapper { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 20px; position: relative; padding-bottom: 4px; overflow: hidden; transition: all 0.3s ease 0s; }.pbr-slider-label { margin-bottom: 12px; }.pbr-slider { appearance: none; background-color: rgba(223, 225, 228, 0.133); border-radius: 20px; width: 100%; height: 8px; }.pbr-slider:first-child { margin-top: 5px; }.pbr-slider::-webkit-slider-thumb { appearance: none; width: 10px; height: 10px; background: rgb(255, 255, 255); cursor: pointer; border-radius: 10px; transition
@MicroCBer
MicroCBer / dom_select.js
Last active March 25, 2023 05:15
Prompt for a dom
function selectAnyElement() {
return new Promise((resolve, reject) => {
if(document.querySelector('.tinyNCM-Selected')){
reject("Already selecting");
return;
}
// create fixed tips
let tips = dom("div",
{
style: {
@MicroCBer
MicroCBer / start.sh
Created March 19, 2023 07:11
Start a typescript server with esbuild-register with pm2
pm2 start server.ts --interpreter="node" --node-args="-r esbuild-register"
@MicroCBer
MicroCBer / 403.html
Created March 7, 2022 04:39
extremely short auto reload&show cc protection tip code
<body onload="a=30;setInterval(()=>{t.innerText=`aa${(a--)||location.reload()}`},1000)"><c style="text-align: center;"><h1>xxxx</h1><h3 id=t><h3>WGzeyu