Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Rust me if you can

Todsaporn Banjerdkit katopz

🦀
Rust me if you can
View GitHub Profile
@katopz
katopz / youtube-hd.js
Last active Aug 7, 2022
keep youtube at hi resolution
View youtube-hd.js
// https://gist.github.com/adisib/1e6b429b9bb630fceb170f3fa77c57a3
let ytPlayer = document.getElementById("movie_player") || document.getElementsByClassName("html5-video-player")[0];
let quality = ytPlayer.getAvailableQualityLevels()[0];
ytPlayer.stopVideo();
ytPlayer.setPlaybackQualityRange && ytPlayer.setPlaybackQualityRange(quality)
ytPlayer.setPlaybackQuality(quality);
let storedQuality = localStorage.getItem('yt-player-quality')
if (!storedQuality || storedQuality.indexOf(quality) === -1) {
let tc = Date.now(),
@katopz
katopz / force-push.sh
Created Oct 8, 2020
Force push on main from head (or other branch) // consider bad practice but sudo it ;p
View force-push.sh
# Switch main to head
git branch -f main head
# Force push
git push -f origin main
@katopz
katopz / postgres-restore-docker
Created Sep 26, 2020
Restore postgres from backup file in docker
View postgres-restore-docker
docker run --name foo-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
docker inspect -f '{{ json .Mounts }}' foo-postgres | python -m json.tool
```
[
{
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "",
"Name": "8ce3df1ef910ec01686401a1fc8cdfff729aa2cd88ccac852c436badab7f3dea",
@katopz
katopz / photopea-hide-ads.md
Last active Jun 26, 2022
How to hide photopea ads
View photopea-hide-ads.md

Open console and run this for 0px width ads. (ads still working, adjust width size to suite your need)

document.querySelector("body > div.flexrow.app > div:nth-child(2)").setAttribute('style','max-width:0px')

document.querySelector("body > div.flexrow.app > div").setAttribute('style','width:100%')
document.querySelector("body > div.flexrow.app > div > div.flexrow > div.panelblock.mainblock").setAttribute('style','width:100%')
const style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '.fixme { min-width:fit-content;overflow:unset; }';
document.querySelector("body > div.flexrow.app > div:nth-child(1) > div.flexrow").appendChild(style)
@katopz
katopz / netflix-fixer.md
Created Aug 2, 2020
A fix for Netflix's issue subtitles cause the screen colours to change
View netflix-fixer.md

Open dev console and run this

document.querySelector(".AkiraPlayer").insertAdjacentHTML('beforebegin', `<div style="
    position: absolute;
    z-index: 999;
    color: black;
    background-color: black;
    width: 1px;
    height: 1px;
 display: block;
@katopz
katopz / bq-del-dedup.md
Created Aug 1, 2020
BigQuery delete deduplication
View bq-del-dedup.md
View nl-kbtg-json2csv.js
fetch('https://covid19.th-stat.com/api/open/timeline')
.then(response => response.json())
.then(json => {
const header = Object.keys(json.Data.shift()).join(',')
const data = json.Data.map(e=>Object.values(e).join(',')).join('\n')
console.log(header + '\n' + data)
})
@katopz
katopz / youtube-auto-confirm.js
Last active Nov 6, 2019
To prevent annoying Youtube confirmation dialog box
View youtube-auto-confirm.js
const isBlock = () => {
// Check for existing dialog
const dialog = Array.from(document.querySelectorAll('paper-dialog'))[0]
if (!dialog) return false
if (getComputedStyle(dialog).display === 'none') return false
console.log('BLOCKED!!!')
return true
}
@katopz
katopz / sha-256.js
Last active Sep 16, 2019
sha-256-js
View sha-256.js
// Web : ref https://jameshfisher.com/2017/10/30/web-cryptography-api-hello-world/
async function sha256(str) {
const buf = await crypto.subtle.digest("SHA-256", new TextEncoder("utf-8").encode(str));
return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join('');
}
// Node
async function sha256(str) {
const crypto = require('crypto')
const hash = crypto.createHash('sha256')
@katopz
katopz / gcp-proof-file.json
Created Aug 26, 2019
gcp-proof-file.json
View gcp-proof-file.json
{
"@context": "https://w3id.org/chainpoint/v3",
"type": "Chainpoint",
"hash": "a6815bf709974ac6d76b790692e5ef9c407e6372b1cc26cdf6ba44a617914ecf",
"hash_id_node": "839033f0-c459-11e9-a2a3-01f3e4c4d74b",
"hash_submitted_node_at": "2019-08-21T21:20:34Z",
"hash_id_core": "859e5370-c459-11e9-be73-01c3a358a4f5",
"hash_submitted_core_at": "2019-08-21T21:20:38Z",
"branches": [
{