Skip to content

Instantly share code, notes, and snippets.

View zalesky's full-sized avatar
🇺🇦
Glory to Ukraine!

Andriy Zaleskyy zalesky

🇺🇦
Glory to Ukraine!
View GitHub Profile
/**
* Checks if line is crossed by rectangle
* @param x1 most left X of rectangle
* @param y1 most left Y of rectangle
* @param a side length of rectangle
* @param b side length of rectangle
* @param degree is an angle to X axis
* @param borderX - x coordinate of a line to check crossing
* @return {boolean} Returns true if rectangle that described with params x1, y1, a, b, degree is crossing the line.
*/
@zalesky
zalesky / hexToRgba.js
Created September 11, 2017 12:48
hex to rgba
let hexToRGB = (hex, opacity) => {
var r = parseInt(hex.slice(1, 3), 16),
g = parseInt(hex.slice(3, 5), 16),
b = parseInt(hex.slice(5, 7), 16);
return opacity ? 'rgba(' + [r, g, b, opacity].join(',') + ')' : 'rgb(' + [r, g, b].join(',') + ')';
};
@zalesky
zalesky / saveImages.js
Created May 12, 2017 14:06
saves images
let IMG_CLASS = '.slide_image';
let IMG_URL_ATTR = 'data-full';
let imgName = 0;
[...document.querySelectorAll(IMG_CLASS)].map(el => setTimeout(() => {
let link = document.createElement('a');
link.download = imgName++;
link.href = el.getAttribute(IMG_URL_ATTR) || el.getAttribute('src');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);