Skip to content

Instantly share code, notes, and snippets.

@Losses
Losses / json.ts
Created November 16, 2022 06:13
Stream loading JSON and Stream saving JSON w/ `stream-json`
import fs from "fs";
import { Readable } from "stream";
import { stat, move, remove } from "fs-extra";
import Assembler from "stream-json/Assembler";
import { chain } from "stream-chain";
import { parser } from "stream-json";
import { stringer } from "stream-json/Stringer";
import { disassembler } from "stream-json/Disassembler";
  1. Add special mirroring modes for demonstration purposes.

  2. Assume rotation of HDMI display is portrait.

adb shell setprop persist.demo.hdmirotation portrait
  1. Don't lock rotation while HDMI is plugged in.
@diyism
diyism / waydroid on debian x64 and armbian focal pine64.txt
Last active June 8, 2024 22:08
waydroid on debian x64 and armbian focal pine64
============================x64 debian=====================================
#redroid is easier than waydroid: https://github.com/remote-android/redroid-doc/issues/407
#https://hub.docker.com/r/teddynight/redroid
#adb connect localhost #20 seconds after docker run
#scrcpy -s localhost --audio-codec=aac --audio-encoder='OMX.google.aac.encoder'
#it seems only one redroid container can run correctly, so first "sudo docker stop <redroid 14 container>" then "sudo docker run <teddynight 11 container>"
#or else the adb/scrcpy won't connect it, even if the 2 containers listen on 2 differenct ports(one 5555, another 5556)
# upgrade kali linux kernel from 5.7 to 5.9+(download from: http://old.kali.org/kali/pool/main/l/linux/)
# sudo apt install linux-image-6.3.0-kali1-amd64
@mttjohnson
mttjohnson / validate_ssh_key.sh
Last active February 1, 2023 05:49
Validating ssh keys
# When you SSH into a server for the first time it prompts you if you trust the remote server's host key
# To validate that they key you received is the same as the server you just logged into you can check
# the fingerprint of the host key on the remote server itself.
# Output fingerprint of system's host key
ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
# You can fingerprint both the private and public key from a file
# They should both produce the same fingerprint value.
ssh-keygen -l -f ~/.ssh/id_ed25519.pub
const pw = require('playwright');
const UserAgent = require('user-agents');
const uuid = require('uuid');
const tmp = require('tmp-promise');
const UINT32_MAX = (2 ** 32) - 1;
const WEBGL_RENDERERS = ['ANGLE (NVIDIA Quadro 2000M Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (NVIDIA Quadro K420 Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (NVIDIA Quadro 2000M Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (NVIDIA Quadro K2000M Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (Intel(R) HD Graphics Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Family Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (ATI Radeon HD 3800 Series Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics 4000 Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (Intel(R) HD Graphics 4000 Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (AMD Radeon R9 200 Series Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (Intel(R) HD Graphics Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Family Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Family Direct3D
@jeffsheets
jeffsheets / timeZoneUtils.js
Last active November 5, 2021 02:49
Browser Javascript to get user timezone or offset that is IE11 safe when passed to a Java API, with Jest Test blogpost: https://www.sheetsj.com/2021/05/mock-intl-and-date-globals-in-jest.html
/**
* Useful when passing the browser timezone to a backend Java API that reads a timezone in using ZoneId.of(tz),
* as both 'America/Chicago' and '-0600' are valid values when passed to the Java API.
* The Offset is used to handle IE11 and other older browsers.
*/
export const getUserTimeZoneOrOffset = () => {
let timeZone;
try {
timeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch (error) {
@xausky
xausky / tester.sh
Last active April 4, 2021 01:14
Emby 服务批量测速脚本
# 使用方式: 有个 bash 环境,安装 curl 和 jq 工具,把 /create 命令返回的信息放到 urls.txt 中然后通过以下两个命令设置用户名和密码即可执行
# export username=xxxx
# export password=xxxx
# 输出结果的列分别为耗时,获取到数据大小(正常为 1M 即 1048575),响应状态码(正常为 200),响应的 URL
for url in $(awk '/^http.*$/' < urls.txt)
do
{
token=$(curl --connect-timeout 30 --max-time 60 -s --location --request POST "$url/emby/Users/AuthenticateByName?format=json" --header 'X-Emby-Authorization: MediaBrowser Client="Kodi",Device="Kodi",DeviceId="00:01:02:03:04:05",Version="1.0.0"' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode "username=$username" --data-urlencode "pw=$password" | jq -r .AccessToken)
curl -o /dev/null --connect-timeout 30 --max-time 60 -s -w %{time_total}"\t"%{size_download}"\t"%{http_code}"\t"%{url_effective}"\n" $url/emby/playback/bitratetest?size=$((0xFFFFF)) -H "X-MediaBrowser-Token: $token"
@buptczq
buptczq / detect.py
Last active January 30, 2022 06:39
QQ URL detect
import hashlib
import struct
import sqlite3
def md5hash(buf):
return hashlib.md5(buf.encode("utf-16")[2:]).digest()
def md5cmp(buf, postfix, a1, a2, a3, a4):
if len(buf) < postfix:
return False
@mezcel
mezcel / .gitattributes
Last active September 24, 2023 19:29
Alpine Linux Notes
## win10 line endins
*.bat eol=crlf
*.ps1 eol=crlf
## Linux/Posix line endins
*.go eol=lf
*.sh eol=lf
*.source eol=lf
Makefile eol=lf