Host: Xubuntu 23.10 (mantic)
# id
uid=1000(roman) gid=1000(roman) ...
Docker Container: Debian 12 (bookworm)
Dockerfile:
FROM node:21.6.2-bookworm
RUN apt-get update && apt-get install sudo
RUN echo "node:root" | chpasswd && usermod -aG sudo node
# Other RUN instructions ...
USER node
#docker #fix #php #dockerfile #chmod
Please open Telegram to view this post
VIEW IN TELEGRAM
๐ค1
Please open Telegram to view this post
VIEW IN TELEGRAM
Tampermonkey take page screenshot button:
// ==UserScript==
// @name Screenshot Downloader
// @namespace http://your.namespace.com
// @version 1.0
// @description Take a screenshot and download it as an image
// @include *://*/*
// @grant GM_download
// @require https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js
// ==/UserScript==
(function() {
'use strict';
// Function to convert the screenshot to a base64 image
function takeScreenshotAndDownload() {
html2canvas(document.body, {
onrendered: function(canvas) {
var screenshotUrl = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
GM_download({
url: screenshotUrl,
name: 'screenshot.png'
});
}
});
}
// Add a button to trigger the screenshot download
var button = document.createElement('button');
button.innerText = 'Photo';
button.onclick = takeScreenshotAndDownload;
button.style.position = 'absolute';
button.style.top = '70px';
button.style.right = '50px';
document.body.appendChild(button);
})();
Please open Telegram to view this post
VIEW IN TELEGRAM
๐1
sudo yum install bluez || sudo apt install bluez
bluetoothctl connect A1:B2:C3:E4:F5:G6 # MAC Address
#bluetooth #headphones #bluez #bluetoothctl
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Workaround Yandex Music Script
setInterval(() => {
navigator.mediaSession.setActionHandler("pause", (details) => {
const nextButton = document.getElementsByClassName('d-icon d-icon_track-next')[0];
if (nextButton) {
nextButton.click();
console.log('Clicked on the next button successfully.');
} else {
console.log('Element not found. Make sure the class selector is correct.');
}
console.log('Pause');
});
}, 1);#yandex #music #js #tampermonkey #workaround #bluetooth #pause
Please open Telegram to view this post
VIEW IN TELEGRAM
โค1๐ฅ1
echo "Enter your slave branch:"
read your_branch
echo "Enter your main branch:"
read master_branch
changes=$(git --no-pager diff --name-only "$master_branch" "$your_branch")
while IFS= read -r file;
do
file_changes=$(git --no-pager diff "$master_branch" "$your_branch" -- "$file")
line_count=$(echo "$file_changes" | wc -l)
if [ "$line_count" -eq 3 ]; then
line2=$(echo "$file_changes" | sed -n '2p') # Get the second line
line3=$(echo "$file_changes" | sed -n '3p') # Get the third line
if [[ "$line2" == "old mode"* ]] && [[ "$line3" == "new mode"* ]]; then
chmod -x "$file"
fi
fi
done <<< "$changes"
echo "Success! Happy codding!"
Fast execution:
curl -so fix-git-mode.sh https://gist.githubusercontent.com/makhnanov/275672ed5d139170d62d338ddf18faab/raw/abf3998b9198b64962c4e3e9ec5aa4e4e532018a/fix-git-mode.sh && chmod +x fix-git-mode.sh && ./fix-git-mode.sh && rm fix-git-mode.sh
#permission #mode #chmod #git #rollback
Please open Telegram to view this post
VIEW IN TELEGRAM
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
nvm i node
Alternative:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
nvm install 20.16.0
Check Current NodeJS Versions
#js #javascript #nvm #npm #node
Please open Telegram to view this post
VIEW IN TELEGRAM
nodejs.org
Node.js โ Node.js Releases
Node.jsยฎ is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
JavaScript create alias for any function ๐ฅ
#js #javascript #includes #contains #alias #frontend
if (!String.prototype.contains) {
// Provide an alias to 'includes' for older browsers
String.prototype.contains = function(search) {
return this.includes(search);
};
}
// Test the polyfilled 'contains' method
const str = "Hello, World!";
console.log(str.contains("Hello")); // Outputs: true
console.log(str.contains("JavaScript")); // Outputs: false#js #javascript #includes #contains #alias #frontend
Please open Telegram to view this post
VIEW IN TELEGRAM
๐คฃ1
Replace
</head> to sometext</head>#!/bin/bash
# Loop through each HTML file and replace </head> with sometext</head>
for file in ./*/*/*.html; do
# Check if the file is a regular file
if [ -f "$file" ]; then
# Replace </head> with sometext</head> using sed
sed -i 's/<\/head>/sometext<\/head>/g' "$file"
echo "Replacement done in $file"
fi
done
#bash #sed #loop #replace
Please open Telegram to view this post
VIEW IN TELEGRAM
Local:
echo debug.sh >> .git/info/exclude
Global:
wip
#git #gitignore #exclude #debug
Please open Telegram to view this post
VIEW IN TELEGRAM