Skip to content

Instantly share code, notes, and snippets.

View embarq's full-sized avatar
🕶️
Working hard

Li Ihor embarq

🕶️
Working hard
View GitHub Profile
@embarq
embarq / folders_size.ps1
Created October 3, 2024 04:52
Windows tools
$targetfolder='C:\Users\'
$dataColl = @()
gci -force $targetfolder -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$filesCount = (gci -recurse -force $_.fullname -File -ErrorAction SilentlyContinue | Measure-Object).Count
$dataObject = New-Object PSObject -Property @{
Folder = $_.fullname
SizeGb = ('{0:N3}' -f ($len / 1Gb)) -as [single]
filesCount=$filesCount
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// @ts-check
import { Subject, from, fromEvent, timer } from 'rxjs'
import { filter, throttle, map, switchMap, tap, first, takeUntil } from 'rxjs/operators'
import gsap from 'gsap'
import './style.css'
console.clear()
class Slider {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>DOM task: Form model</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<style>
[
{
"id": "86837561-6718-4f43-9eb8-01176dbb1606",
"first-name": "Tedmund",
"last-name": "",
"email": "[email protected]",
"gender": "Male",
"iban": "FI21 1148 8020 1413 22",
"credit-card-type": "",
"credit-card": ""
[{
"name": "Ancient One",
"species": "human",
"genger": "Female",
"birthDay": "1316",
"deathDay": "2017",
"status": "deceased",
"actors": "Tilda Swinton",
"photo": "https://vignette.wikia.nocookie.net/marvelcinematicuniverse/images/4/46/DS_Ancient_One_Poster_cropped.png",
"movies": ["Doctor Strange", "Avengers: Endgame"]
@embarq
embarq / index.js
Created February 11, 2020 13:37
Solution to Codewars kata "Snake Collision" https://www.codewars.com/kata/5ac616ccbc72620a6a000096/javascript
// @ts-check
/**
* @param {Array<{ x: number, y: number }>} body snake body coords
* @param {{ x: number, y: number }} cell snake cell to check with
* @returns {{ x: number, y: number }} coords of the cell where collision occured(if any)
*/
function findCollision(body, cell) {
const { x: x1, y: y1 } = cell;
return body.find(({ x: x0, y: y0 }) => (x0 === x1 && y0 === y1));
@embarq
embarq / allow-ingress-multiple-ports.sh
Created November 28, 2019 11:01
GCloud Compute Engine: add multiple firewall rules for desired TCP ports
#!/bin/bash
BASE_RULE_NAME="rule-allow-tcp"
TARGET_NET_TAG="frontserver" # For more info see https://cloud.google.com/vpc/docs/add-remove-network-tags
for PORT in 4201 4202 4203 4204 4205 4206 4207 4208 4209
do
# See reference https://cloud.google.com/vpc/docs/using-firewalls
gcloud compute firewall-rules create $BASE_RULE_NAME-$PORT \
--source-ranges 0.0.0.0/0 \
--allow tcp:$PORT \
@embarq
embarq / README.md
Last active November 29, 2019 13:00
Remote development with VSCode & GCloud Compute Engine

Set up GCloud Compute Instance

  1. Create instance
  2. Create ssh key for remote host access locally: ssh-keygen -t rsa -C {host_username}
  3. Add ssh public keys to .ssh/authorized_keys on the host side
  4. Connect to host via ssh {host_username}@{host_ip}

If you want to use a specific port for local preview it needs to be available by setting up a firewall rule:

  1. Create new rule for a tag:
@embarq
embarq / temp.md
Last active September 10, 2019 12:10

Variables

  1. Immutable data-manipulations
// Instead of

const data = [ /*  */ ];
data.push(100, 200, 300);