Skip to content

Instantly share code, notes, and snippets.

View jdrzejb's full-sized avatar

Jay jdrzejb

  • Poland
View GitHub Profile
@jdrzejb
jdrzejb / retry.ts
Created February 25, 2021 14:21
promise retry
export function retryPromise<T>(fn: () => Promise<T>, retriesLeft = 5, interval = 375): Promise<T> {
return new Promise((resolve, reject) => {
fn()
.then(resolve)
.catch(error => {
setTimeout(() => {
if (retriesLeft === 1) {
// reject('maximum retries exceeded');
reject(error);
return;
@jdrzejb
jdrzejb / script.ps1
Created January 19, 2021 22:54
Bootable Windows Server Iso
$ISOFile = "C:\Users\DELL\Downloads\17763.737.190906-2324.rs5_release_svc_refresh_SERVERHYPERCORE_OEM_x64FRE_en-us_1.iso"
$USBDrive = Get-Disk | Where FriendlyName -eq " USB Flash Memory"
$USBDrive | Clear-Disk -RemoveData -Confirm:$true -PassThru
$USBDrive | Set-Disk -PartitionStyle GPT
$Volume = $USBDrive | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel WS2019
$ISOMounted = Mount-DiskImage -ImagePath $ISOFile -StorageType ISO -PassThru
$ISODriveLetter = ($ISOMounted | Get-Volume).DriveLetter
Copy-Item -Path ($ISODriveLetter +":\*") -Destination ($Volume.DriveLetter + ":\") -Recurse
@jdrzejb
jdrzejb / util.coffee
Created November 23, 2020 20:07
Truncate text
# This function truncates multiple line texts
# @pre - set 'line-height' prop for container
# @param container - jQuery elem holding the text
# @param text - text to truncate
# @param lines - number of text lines in container
truncateText: (container, text, lines) ->
container.text text
maxHeight = lines * parseFloat container.css 'line-height'
# return original text w/o '...'
return text if container.innerHeight() <= maxHeight
@jdrzejb
jdrzejb / calculate-orientation.ts
Created August 12, 2020 09:27
Get exit orientation from a file using JavaScript and TypeScript
enum Bytes {
JPGStartMarker = 0xffd8,
EXIFMarker = 0xffe1,
EXIFInfo = 0x45786966,
OrientationMarker = 0x0112,
Empty = 0xff00,
ExifAlignment = 0x4949
}