Skip to content

Instantly share code, notes, and snippets.

@maker27
maker27 / direction.scss
Created July 1, 2022 11:37 — forked from saeedseyfi/direction.scss
RTL/LTR support using sass mixins.
$layout-direction: ltr !default;
@mixin ltr {
@if $layout-direction == ltr {
@content;
}
}
@mixin rtl {
@if $layout-direction == rtl {
@content;
@maker27
maker27 / gist:927e2aae74174b3068c8c8dc7a5cba0d
Created November 5, 2021 12:41
Task. Реализуйте функцию parseUrl(string), которая будет парсить URL строку и возвращать объект с распарсенными данными.
Пример:
let a = parseUrl('http://tutu.ru:8080/do/any.php?a=1&b[]=a&b[]=b#foo')
// Вернет объект, в котором будут следующие свойства:
console.log( a.href == "http://tutu.ru:8080/do/any.php?a=1&b[]=a&b[]=b#foo" )
console.log( a.hash == "#foo" )
console.log( a.port == "8080" )
console.log( a.host == "tutu.ru:8080" )
console.log( a.protocol == "http:" )
@maker27
maker27 / axiosInterceptor.js
Created March 4, 2021 21:48 — forked from nzvtrk/axiosInterceptor.js
Axios create/recreate cookie session in node.js enviroment
/* Basic example of save cookie using axios in node.js and recreate session if it expired.
* Get/save cookie manually cause WithCredential axios param use XHR and not work in node.js
* Supports parallel request and send only one create session request.
* */
const BASE_URL = "https://google.com";
// Init instance of axios which works with BASE_URL
const axiosInstance = axios.create({ baseURL: BASE_URL });
@maker27
maker27 / socket-cheatsheet.js
Created September 26, 2020 19:27 — forked from alexpchin/socket-cheatsheet.js
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@maker27
maker27 / clock-angle.js
Created October 29, 2019 18:23
Get angle between hour and minute hands on the clock
function getWatchAngle(hours, minutes){
const minutesAngle = minutes * 360/60;
const hourAngle = (hours%12 + minutes/60) * 360/12;
return Math.abs(minutesAngle - hourAngle);
}
@maker27
maker27 / create-certs.sh
Created June 21, 2019 16:57 — forked from sethvargo/create-certs.sh
Use openssl to create an x509 self-signed certificate authority (CA), certificate signing request (CSR), and resulting private key with IP SAN and DNS SAN
# Define where to store the generated certs and metadata.
DIR="$(pwd)/tls"
# Optional: Ensure the target directory exists and is empty.
rm -rf "${DIR}"
mkdir -p "${DIR}"
# Create the openssl configuration file. This is used for both generating
# the certificate as well as for specifying the extensions. It aims in favor
# of automation, so the DN is encoding and not prompted.