Skip to content

Instantly share code, notes, and snippets.

View boardev's full-sized avatar

Boar boardev

  • MHP
  • Ukraine
  • 15:02 (UTC +02:00)
View GitHub Profile
@boardev
boardev / SetupWin11.ps1
Created October 18, 2024 10:30 — forked from TheGU/SetupWin11.ps1
Auto setup new win11 pc for development.
# =============
# Run terminal as admin, then run 'powershell.exe -ExecutionPolicy Unrestricted'
# to start powershell session in unrestricted mode
# https://learn.microsoft.com/th-th/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
# get all input parameter
$computerName = Read-Host 'Change Computer Name from [' $env:COMPUTERNAME '] to (blank to skip) '
$monitorTimeout = Read-Host 'Set monitor timeout to __ second (blank to skip) '
@boardev
boardev / promise-all-error-handling.js
Created September 12, 2024 11:41 — forked from munkacsitomi/promise-all-error-handling.js
Promise.all error handling
const pause = (data, time) => new Promise(resolve => setTimeout(() => resolve(data), time));
const pauseReject = (data, time) =>
new Promise((resolve, reject) =>
setTimeout(() => reject(new Error(`Something went wrong in the ${data} promise`)), time)
);
const parallelErrorHandlingWrong = () => {
const firstPromise = pause('first', 3000);
const secondPromise = pauseReject('second', 2000);
const thirdPromise = pause('third', 1000);
@boardev
boardev / prefetch.ts
Created July 9, 2024 07:35 — forked from nicooprat/prefetch.ts
Vue-router prefetch plugin for router-links (Vue 3)
/**
* Prefetch pages to make navigation faster (from route to route)
* Monkey patch router-link to trigger async import when the link is in the viewport
* Use a queue & requestIdleCallback to prevent browser from freezing
* Install in Vue 3 with `import prefetch from './prefetch` then `app.use(prefetch)`
* */
import { watchPausable } from '@vueuse/core';
import { ref } from 'vue';
import { RouterLink, useRouter } from 'vue-router';
@boardev
boardev / TreeBuilder.js
Created June 5, 2024 14:05 — forked from jjyyjjyy/TreeBuilder.js
Build a tree
function buildTree(array, parentRetriever = e => e.parentId) {
if (!array || array.length === 0) {
return []
}
array.forEach(e => {
e.children = [] // 为每个节点初始化children属性
})
const adjacencyTable = {}
@boardev
boardev / arrays.ts
Created May 23, 2024 22:38 — forked from robey/arrays.ts
common missing array functions in JS
// missing from JS stdlib
// return an array of numbers starting at `start`, not reaching `end`, incrementing by `step`.
export function range(start: number, end: number, step: number = 1): number[] {
return [...Array(Math.ceil((end - start) / step)).keys()].map(i => i * step + start);
}
// return the average of an array of numbers.
export function average(array: number[]): number {
return array.reduce((sum, n) => sum + n) / array.length;
@boardev
boardev / flatten.js
Created May 23, 2024 22:33 — forked from jjant/flatten.js
Simple Array flatten implementation in js
// Takes an array with possible nested arrays, and returns a **new** flat array.
const flatten = array =>
array.reduce(
(flattened, elem) =>
flattened.concat(Array.isArray(elem) ? flatten(elem) : elem),
[]
);
// From here on below we have only test utilities
const test = (testedFunc, input, expectedOutput, comparator) => {
@boardev
boardev / Common Style.css
Created April 1, 2024 10:22 — forked from nthung2112/Common Style.css
Custom scroll bar of Google drive
@-moz-document url-prefix() {
* {
scrollbar-width: thin;
scrollbar-color: #c1c1c1 rgba(0, 0, 0, 0.03);
}
}
::-webkit-scrollbar {
width: 10px;
height: 10px;
@boardev
boardev / _deobfuscating-unminifying-obfuscated-web-app-code.md
Created March 26, 2024 00:57 — forked from 0xdevalias/_deobfuscating-unminifying-obfuscated-web-app-code.md
Some notes and tools for reverse engineering / deobfuscating / unminifying obfuscated web app code
@boardev
boardev / Absolute Enable Right Click & Copy.user.js
Created February 27, 2024 21:39 — forked from thienha1/Absolute Enable Right Click & Copy.user.js
Absolute Enable Right Click & Copy.user.js
// ==UserScript==
// @name Absolute Enable Right Click & Copy
// @namespace Absolute Right Click
// @description Force Enable Right Click & Copy & Highlight
// @shortcutKeys [Ctrl + `] Activate Absolute Right Click Mode To Force Remove Any Type Of Protection
// @author Absolute
// @version 1.8.9
// @include *://*
// @icon https://i.imgur.com/AC7SyUr.png
// @compatible Chrome Google Chrome + Tampermonkey
@boardev
boardev / Portable_Virtualbox.md
Created January 26, 2024 09:27 — forked from badrelmers/Portable_Virtualbox.md
portable virtualbox using the latest virtualbox installers

This makes virtualbox works in a portable mode:

  • if you have any installed virtualbox then uninstall it first
  • download https://download.virtualbox.org/virtualbox/7.0.8/VirtualBox-7.0.8-156879-Win.exe or any newer or older version
  • click on Download ZIP above to download the scripts needed
  • create a folder inside your USB/external drive or whatever, name it myVMBOX (ex. F:\myVMBOX if your USB is in F:\).
  • inside F:\myVMBOX put the virtualbox exe we just downloaded (VirtualBox-7.0.8-156879-Win.exe) and rename it to VirtualBox.exe.
  • inside F:\myVMBOX put the following files start_virtualbox.bat and uninstall_virtualbox.bat, you will find them inside the zip you just downloaded.
  • now everytime you want to start virtualbox use start_virtualbox.bat.