Skip to content

Instantly share code, notes, and snippets.

View cahva's full-sized avatar

Markku Virtanen cahva

View GitHub Profile
@cahva
cahva / blacklist-domain.html
Last active February 19, 2025 14:11
Blacklist domain
<script>
const restrictedDomains = [
'@example.com',
'@foo.bar'
];
async function initEmailCheck() {
try {
const emailInput = await waitForElementPromise('#EMAIL_2');
const submitButton = await waitForElementPromise('#submit-button');
@cahva
cahva / mount-ephemeral.sh
Created December 8, 2024 15:01
Mount nvme disk in aws
#!/usr/bin/env bash
MOUNT="/media"
EPHEMERAL_DISK=$(sudo nvme list | grep 'Amazon EC2 NVMe Instance Storage' | awk '{ print $1 }')
# Check if the mount point exists in /proc/mounts
if grep -qs ${MOUNT} /proc/mounts; then
echo "It's mounted."
else
# Check if the block device exists and is not formatted as ext4
if [ -b ${EPHEMERAL_DISK} ] && ! blkid ${EPHEMERAL_DISK} | grep -qs ext4; then
@cahva
cahva / setlangparameter.js
Created December 3, 2024 09:54
Set language parameter if it does not exist
// Only proceed if we're not on a register page
if (!window.location.pathname.includes('/register')) {
const params = new URLSearchParams(window.location.search);
// Only add language param if it doesn't exist
if (!params.has('language')) {
params.append('language', 'en');
// Construct new URL with updated params
const newUrl = window.location.pathname + '?' + params.toString() + window.location.hash;
@cahva
cahva / getsuppressedemails.sh
Last active October 11, 2024 08:51
Get suppressed emails from SES
#!/bin/env bash
# Get aws sesv2 list-suppressed-destinations
# It will have a json output and has format like this:
# {
# "SuppressedDestinationSummaries": [
# {
# "EmailAddress": "string",
# "LastUpdateTime": "string",
# "Reason": "string" # BOUNCE | COMPLAINT
@cahva
cahva / inject-id-to-link.html
Last active February 22, 2024 12:46
inject id from search params to data-inject-qs elements
@cahva
cahva / calcdiff.js
Last active October 9, 2023 12:11
Calculate difference between dates in days, hours, mins and secs
function getDifference(toD, fromD = new Date(), zeroPad = false) {
let d1 = new Date(fromD); // Current date and time
let d2 = new Date(toD); // Target date and time
// Calculate difference in milliseconds
let diffMs = Math.abs(d2 - d1);
// Convert to respective units
let diffSeconds = Math.floor(diffMs / 1000);
let diffMinutes = Math.floor(diffSeconds / 60);
@cahva
cahva / gist:411822c9e86ea7499b19e2b64572ddac
Last active March 8, 2022 10:27
Delete old snapshots from ofs
We couldn’t find that file to show.
@cahva
cahva / privacypolicy.md
Last active February 28, 2022 16:37
Videosync privacy policy

Privacy Policy

Videosync privacy statement

Flik Media Group, the creator of Videosync service, is committed to protecting your privacy and personal data. This privacy statement (“Privacy Statement”) explains how Flik Media Group and its authorised partners and affiliates (“Flik”) process personal data in connection with the Videosync service (“Service”).

Personal data is information that is about you as an identifiable individual. Aggregated, statistical or de-identified information is not personal information. Information generated through your use of our websites or watching videos will not be personal information unless we can combine it with other information that would identify you.

The term “personal data”, as used in this Privacy Statement, refers to any information about you which can be used to personally identify you, such as your name, address, telephone number, e-mail address, or any other personal information you might supply.

@cahva
cahva / git-submodule-rewrite
Last active February 9, 2022 13:54
Git submodule rewrite
#!/usr/bin/env bash
# This script builds on the excellent work by Lucas Jenß, described in his blog
# post "Integrating a submodule into the parent repository", but automates the
# entire process and cleans up a few other corner cases.
# https://x3ro.de/2013/09/01/Integrating-a-submodule-into-the-parent-repository.html
function usage(){
echo "Usage: $0 <submodule-name> [<submodule-branch>]"
echo "Merge a single branch of <submodule-name> into a repo, retaining file history."
@cahva
cahva / rename-file-extensions-git.sh
Created February 7, 2022 09:41
Shell script to rename files to another extension in git
#/bin/bash
for i in $(find . -iname "*.jade"); do
git mv "$i" "$(echo $i | rev | cut -d '.' -f 2- | rev).pug";
done