Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Denis Leonov Deliaz

🏠
Working from home
View GitHub Profile
@Deliaz
Deliaz / crxver.js
Created Apr 8, 2019
Shows version of .CRX file (chromium extensions). JavaScript version.
View crxver.js
#!/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 / crxver.sh
Last active Apr 8, 2019
Shows versions of .CRX file (chromium extensions). Bash version.
View crxver.sh
#!/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 / config-raspberry-on-sd.txt
Last active Jan 18, 2018
Help note to configure WiFi and SSH on SD card
View config-raspberry-on-sd.txt
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
}
@Deliaz
Deliaz / webaudio-tests.js
Created Jun 14, 2017
Just some tips apply filters to an audio from video stream
View webaudio-tests.js
// # 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 / get_image_screenshot.js
Last active Jun 2, 2017
Get a screenshot from video
View get_image_screenshot.js
/**
* 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");
View generate-guid.js
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
@Deliaz
Deliaz / build.xml
Created Feb 12, 2017
Build script for Phing
View build.xml
<?xml version="1.0"?>
<project name="Clipboard History" basedir="." default="tester">
<property name="build_dir" value="../scm_build" />
<property name="dest_dir" value="../scm_build/scm" />
<property name="src_dir" value="." />
<!-- ДЛЯ ТЕСТЕРОВ -->
<target name="tester" description="Сборка в папку для тестеров">
<!-- Создаем каталог для билда -->
<mkdir dir="${build_dir}" />
@Deliaz
Deliaz / arrayBufferToBase64.js
Created Dec 16, 2016
Convert array buffer to base64 string
View arrayBufferToBase64.js
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);
}
@Deliaz
Deliaz / uri.js
Created Dec 7, 2016 — forked from jlong/uri.js
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@Deliaz
Deliaz / es6-object-iteration.js
Created Nov 22, 2016
ES6 object itareraton
View es6-object-iteration.js
// using a generator function
function* entries(obj) {
for (let key of Object.keys(obj)) {
yield [key, obj[key]];
}
}
// an alternative version using a generator expression
function entries(obj) {
return (for (key of Object.keys(obj)) [key, obj[key]]);