Skip to content

Instantly share code, notes, and snippets.

View amochkin's full-sized avatar
🏴‍☠️

Al Mochkin amochkin

🏴‍☠️
  • Miami
  • 03:07 (UTC -04:00)
View GitHub Profile
@amochkin
amochkin / digital-ocean-download-backup.md
Last active January 31, 2024 10:08
Download droplet snapshot or backup from Digital Ocean

Download droplet snapshot or backup from Digital Ocean

Problem

Digital Ocean does not allow you to download backups or shanpshots of the droplet. This may be a problem if you want to migrate from Digital Ocean to somewhere else.

Solution

  1. Boot into Recovery Console (choose Boot from Recovery ISO option) for the source droplet. If you need specific backup or snapshot, you would need to restore it either into source droplet or create a new droplet out of it.
@amochkin
amochkin / aerohive.md
Created May 30, 2023 16:13 — forked from samdoran/aerohive.md
Configuring Aerohive access points using the CLI

Aerohive

Initial setup

  1. Reset to factory defaults

     reset config bootstrap
     reset config
    
  2. Configure interfaces

@amochkin
amochkin / conventional_hook.sh
Last active May 4, 2023 15:18
Oneliner that creates and installs a conventional commit enforcement script for git. Run this oneliner in your git repo root.
printf '#!/bin/sh\n
# Get the commit message
commit_message=$(cat "$1")\n
# Regular expression pattern for conventional commits
pattern='\''^(feat|fix|docs|style|refactor|test|chore)(\([a-z0-9-]+\))?!?: [^\s].{0,100}$'\''\n
# Check if the commit message matches the pattern
if echo "$commit_message" | grep -qE "$pattern"; then
\techo "Commit message is compliant with conventional commits."
else
\techo "Commit message is not compliant with conventional commits. See https://www.conventionalcommits.org/en/v1.0.0/#summary"; exit 1
@amochkin
amochkin / sequencer.ts
Created December 14, 2022 21:40
Custom Jest sequencer Typescript
import Sequencer, { ShardOptions } from '@jest/test-sequencer';
import { Test } from '@jest/test-result';
const sorterFn = (a: Test, b: Test) => {
return a.path > b.path ? 1 : -1;
};
class CustomSequencer extends Sequencer {
/**
* Select tests for shard requested via --shard=shardIndex/shardCount
import { useEffect, useRef, useState } from 'react';
type TimerCallbackType = (timerLeft: number) => void;
/**
* useTimer hook to handle timer events. Has protection from subsequent calls, ie calling the timer when it was already started.
* @param callback Callback function
* @param timer Timer in milliseconds
* @param interval Interval between timer ticks in milliseconds
*/