Skip to content

Instantly share code, notes, and snippets.

@jvarn
jvarn / reverse-table-columns.vb
Last active March 26, 2024 09:54
Reverse order of table columns in MS Word VBA
' Reverses LTR tables with visually RTL content and vice versa
' Tested with simple table (no merged cells) on Microsoft 365 versions of:
' Microsoft Word for Mac, Version 16.83
' Microsoft Word for Windows, Version 2402
Sub ReverseTableColumns()
Dim tbl As Table
Dim colCount As Long
Dim i As Long
Dim j As Long
Dim tempContent As String
@jvarn
jvarn / markdown-parsing.html
Last active July 17, 2023 06:05
Markdown parsing with code highlighting using Marked JS and Marked Highlight
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Markdown Parsing</title>
</head>
<body>
<h1>Markdown Parsing using Marked JS</h1>
<p>Fetches Marked JS Readme.md as an example.</p>
<section id="content"></section>
@jvarn
jvarn / ubuntu_post_install.sh
Last active July 12, 2023 06:02
Ubuntu post-install script (installs my usual packages and apps)
#!/bin/bash
sudo apt update && sudo apt upgrade -y
### APT
function install_apt_packages {
apt_packages=""
read -e -p "Install Gnome Tweaks? (n) " choice
[[ "$choice" == [Yy]* ]] && apt_packages="${apt_packages}gnome-tweaks "
@jvarn
jvarn / find_installed_software.sh
Created July 10, 2023 09:07
Quick search for installed dpkg, flatpak, snap packages
#!/bin/bash
BoldGreen='\033[1;32m'
NoColour='\033[0m'
## Parameter specified?
if [ $# -eq 0 ]; then
echo -e "No package specified"
exit 1
fi
@jvarn
jvarn / make_windows_usb.sh
Last active July 4, 2023 05:28
Make Windows USB Installer on Mac
#!/bin/bash
# Installs Homebrew and Wimlib if not already installed,
# then formats and prepares an external USB device as
# a bootable Windows installer from your Windows ISO.
#
# Usage: ./make_windows_usb.sh windows_installer.iso
# (first make executable with: chmod u+x ./make_windows_usb.sh)
#
# Insert single external USB target device before running.
# Do not use blindly – bad things can happen.
@jvarn
jvarn / mobile-number-formatter.php
Created August 1, 2022 05:19
PHP function to make mobile numbers in full international format
<?php
/**
* Formats mobile numbers as international.
*
* @access public
* @param string $number is a mobile phone number
* @param array $args is an associative array of variables (see $defaults)
* @return string
*/
@jvarn
jvarn / geolocation.js
Last active April 4, 2022 05:57
Insert Latitude and Longitude into Formidable Forms
var geomaptarget = document.getElementById("geomaptarget");
var field_latitude = document.getElementById("field_latitude");
var field_longitude = document.getElementById("field_longitude");
function getLocation() {
if ( geomaptarget !== null ) { // for paginated forms
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition( // https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition
// Success function
@jvarn
jvarn / excel-url-decode.vba
Created March 2, 2022 06:31
URL Encode and Decode VBA functions for Excel on Mac or Windows including UTF-8 support. Source: ExcelVBA.ru
Function URLDecode(ByVal strIn)
On Error Resume Next
Dim sl&, tl&, key$, kl&
sl = 1: tl = 1: key = "%": kl = Len(key)
sl = InStr(sl, strIn, key, 1)
Do While sl > 0
If (tl = 1 And sl <> 1) Or tl < sl Then
URLDecode = URLDecode & Mid(strIn, tl, sl - tl)
End If
Dim hh$, hi$, hl$, a$