Skip to content

Instantly share code, notes, and snippets.

View Deliaz's full-sized avatar

Denis Leonov Deliaz

View GitHub Profile
@Deliaz
Deliaz / get_image_screenshot.js
Last active June 2, 2017 09:50
Get a screenshot from video
/**
* Takes a screenshot from video.
* @param videoEl {Element} Video element
* @param scale {Number} Screenshot scale (default = 1)
* @returns {Element} Screenshot image element
*/
function getScreenshot(videoEl, scale) {
scale = scale || 1;
const canvas = document.createElement("canvas");
@Deliaz
Deliaz / webaudio-tests.js
Created June 14, 2017 08:42
Just some tips apply filters to an audio from video stream
// # 1st way
var context = new AudioContext();
var source = context.createMediaElementSource(document.querySelector('.video-stream.html5-main-video'));
//Now we want to create a filter
var filter = context.createBiquadFilter();
source.connect(filter); //and of course connect it
filter.type = "highshelf"; //this is a lowshelffilter (try excuting filter1.LOWSHELF in your console)
filter.frequency.value = 200; //as this is a lowshelf filter, it strongens all sounds beneath this frequency
@Deliaz
Deliaz / config-raspberry-on-sd.txt
Last active January 18, 2018 10:28
Help note to configure WiFi and SSH on SD card
cd /Volumes/boot
nano wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid="YOUR_NETWORK_NAME"
psk="YOUR_PASSWORD"
key_mgmt=WPA-PSK
}
<html lang="ru">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
#canv {
border: 2px solid #eee;
margin: 20px auto;
display: block;
color: #7a93b4;
}
@Deliaz
Deliaz / crxver.sh
Last active April 8, 2019 05:24
Shows versions of .CRX file (chromium extensions). Bash version.
#!/bin/bash
echo -n -e "File type:\t"
xxd -l 4 $1 | awk '{for(i=NF; i>3; --i) print $NF}'
echo -n -e "Version:\t"
xxd -l 1 -c 1 -ps -s 4 $1
@Deliaz
Deliaz / crxver.js
Created April 8, 2019 05:22
Shows version of .CRX file (chromium extensions). JavaScript version.
#!/usr/bin/env node
const fs = require('fs');
const filePath = process.argv[2];
if(!filePath) {
console.error('No file specified.\nUsage:\n\tnode crxver.js my-extensions.crx\n');
process.exit(-1);
}
const buf = fs.readFileSync(filePath);
@Deliaz
Deliaz / arrayBufferToBase64.js
Created December 16, 2016 06:12
Convert array buffer to base64 string
function arrayBufferToBase64(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
#CUSTOM
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats ' (%b)'
setopt PROMPT_SUBST
@Deliaz
Deliaz / pm2-update-restart-check.sh
Created April 5, 2024 01:07
Bash script to update PM2-managed web services and verify online status post-rebuild. Stops the process, pulls code changes, runs npm install if needed, and restarts. Continuously checks HTTP status until the service is back online, reporting the time taken.
#!/bin/bash
# Configuration variables
PROCESS_ID=1 # PM2 process ID
DOMAIN_URL=https://example.com # Domain to check
CHECK_INTERVAL=10 # Interval for HTTP check in seconds
SERVICE_DIRECTORY=path-to-folder/ # Directory of the web service
# Function to check HTTP status code
check_http_status() {