Skip to content

Instantly share code, notes, and snippets.

View daniil4udo's full-sized avatar
🇺🇦

Daniil Chudo daniil4udo

🇺🇦
View GitHub Profile
@daniil4udo
daniil4udo / vscodium-extensions-update.js
Created October 17, 2023 05:53
VS Codium update extensions
import { exec } from 'node:child_process';
import fs from 'node:fs/promises';
import path from 'node:path';
const HOME_DIR = process.env.HOME || process.env.USERPROFILE;
async function getVSIXPackage(vendor, extensionName) {
const payload = {
assetTypes: null,
filters: [
@daniil4udo
daniil4udo / Dockerfile
Last active March 10, 2022 16:02
Dockerfile for slim Node and pre-installed pnpm
# syntax=docker/dockerfile:experimental
# 🟠 If the Docker image is built on an M1 chip then you’ll notice this container error
# docker rmi --force daniil4udo/pnpm-slim:latest
# DOCKER_BUILDKIT=1 docker buildx build --platform=linux/amd64 -t daniil4udo/pnpm-slim . --no-cache
# docker push daniil4udo/pnpm-slim:latest
FROM --platform=linux/amd64 node:14.19.0-buster-slim
RUN npm i -g pnpm@^6
@daniil4udo
daniil4udo / web-worker-canvas.js
Created May 20, 2021 10:24
Web Worker canvas
let options = {
padding: 15,
yRange: [0, 10, 20, 30, 40, 50],
fontSize: 12,
fillColor: '#00e5ff',
strokeColor: '#263238',
xRange: ["Cluster 1", "Cluster 2", "Cluster 3", "Cluster 4", "Cluster 5"]
}
const startButton = document.getElementById('start'),
@daniil4udo
daniil4udo / unicode.js
Created January 2, 2021 06:32
Convert string to unicode
// String to Unicode
export function strEncodeUTF16(x: string) {
const z = [];
const strLen = x.length;
const trimSpaces = false; // whitespaces
const s = '\\u';
let charCode;
for (let v = 0; v < strLen; v++) {
charCode = x.charCodeAt(v);
if (trimSpaces == false && d(charCode) == true) {
@daniil4udo
daniil4udo / responsivness.scss
Created May 19, 2020 14:36
Completely responsive CSS values, more than just media queries
/*
Example
https://habr.com/ru/post/500014/
*/
/* Mobile and Tablet */
@media (max-width: 768px) {
html {
font-size: calc(16px + 2 * ((100vw - 360px) / 768));
}
@daniil4udo
daniil4udo / promise-based-xml-json.js
Created March 15, 2020 06:22
Promise base XMLHttpRequest to fetch local json
/**
* No workers way
*/
function request(url) {
return new Promise(function (resolve, reject) {
const xhr = new XMLHttpRequest();
xhr.overrideMimeType("application/json");
xhr.open('GET', url, true);
xhr.onreadystatechange = _ => {
if (xhr.readyState === 4) {
@daniil4udo
daniil4udo / Vue dynamic components
Created February 22, 2020 09:50
dynamicImport.js
const ComponentContext = require.context('./widgets', true, /\.vue$/i, 'lazy');
ComponentContext.keys().forEach((componentFilePath) => {
const componentName = componentFilePath.split('/').pop().split('.')[0];
console.log(`Dmc${capitalize(componentName)}`);
Vue.component(`Dmc_${componentName}`, () => ComponentContext(componentFilePath));
});
/*
computed: {
@daniil4udo
daniil4udo / node-sharedhosting.bash
Last active July 22, 2019 07:52
Node and Shared hosting
#https://www.a2hosting.com/kb/installable-applications/manual-installations/installing-node-js-on-managed-hosting-accounts
ssh -p 2222 f8rqbozg@50.116.92.122
# Sync files
#The very basic usage:
scp remote_user@remote_host:/path/to/remote/file /path/to/local/file
# and vice versa:
scp /path/to/local/file remote_user@remote_host:/path/to/remote/file
@daniil4udo
daniil4udo / command-line-cheats.bash
Created June 17, 2019 10:38
Command line Mac cheats
# Replace word in the file / files
perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt
@daniil4udo
daniil4udo / deploying-to-heroku.bash
Created June 16, 2019 12:03
Deploying to Heroku
# Implying you already have Heroku CLI
# Create Procfile & add script from package.json to run
touch Procfile
echo > "web: npm run prod" Procfile
# Create new app
heroku create
# Add config variable