Skip to content

Instantly share code, notes, and snippets.

@nkalvi
nkalvi / getNumberSeparators.js
Created September 11, 2023 03:58
Get locale-based number formatting options in JavaScript
// https://codepen.io/nkalvi/pen/MWZpzOg
// Get separator symbols as .decimal and .thousands
// for given locale or default locale
function getNumberSeparators(locale) {
const str = (1234.56).toLocaleString(locale);
const regex = /\p{Nd}(?<thousands>[^\p{Nd}]?)\p{Nd}{3}(?<decimal>[^\p{Nd}]?)\p{Nd}{2}/u;
const found = str.match(regex);
if (!found || !found.groups) return undefined;
@nkalvi
nkalvi / NavigationSplitViewExample.swift
Last active September 21, 2023 14:14 — forked from Dimillian/NavigationSplitViewExample.swift
An example on how to use the new NavigationSplitView on iPad with global navigation - updated to work by following "Bringing robust navigation structure to your SwiftUI app"
// 2022-08-03: updated to work by following "Bringing robust navigation structure to your SwiftUI app"
// https://developer.apple.com/documentation/swiftui/bringing_robust_navigation_structure_to_your_swiftui_app
// Tested with Xcode Version 14.0 beta 4 (iOS 16.0 beta 4)
import SwiftUI
import Combine
@main
struct SplitNav_2022_08_02App: App {
@StateObject var navigationModel = NavigationModel(sidebarDestination: .subreddit(subreddit: .games))
@nkalvi
nkalvi / SetTitlesToAlbumNameWithAutoNumber.scpt
Last active December 11, 2019 01:28
AppleScript to set item titles based on album name - in Mac Photos
-- Purpose:
-- In Mac Photos, traverse selected albums and set title to the following format, preserving the order of items
-- [Album Name]-xx of xx (then export choosing titles as file names)
--
-- Why? - wouldn't export in Photos with 'Album Name with Number' work?
-- 2019-12-10
-- Fixed! in Catalina 10.15.2, Photos Version 5.0 (121.17.170)
-- 2019-12-09
-- This script is not needed if the export function in Photos preserved the order when selecting
-- sequential numbering or auto-numbering scheme; it worked when exporting unmodified originals.
@nkalvi
nkalvi / 0_reuse_code.js
Created November 18, 2016 05:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nkalvi
nkalvi / ios_apps_info.py
Created June 1, 2016 04:23
Python3.5: List iOS app details in tabular form (by reading .ipa files under ~/Music/iTunes/iTunes Media/Mobile Applications/)
#!/usr/bin/env python3
import sys
import plistlib
import zipfile
import glob
import os
columns = ['Title', 'Seller', 'Category', 'version', 'Released', 'Purchased', 'AppleIdForPurchase']
print(*columns, sep = "\t")
@nkalvi
nkalvi / AdvancedWelcomeEulaDlg_Custom.wxs
Last active January 12, 2017 03:57
Revised Pandoc Windows Installer 2016-02-22
<?xml version="1.0" encoding="UTF-8"?>
<!--
<copyright file="AdvancedWelcomeEulaDlg.wxs" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
@nkalvi
nkalvi / pandoc.wxs
Last active June 22, 2016 22:32
pandoc.wxs 2015-07-09
<?define UpgradeCode = "A68E8EF6-ABB1-4F22-A3C5-68DFDF0AB562" ?>
<?if $(sys.BUILDARCH)=x64?>
<?define ProgFilesFolder="ProgramFiles64Folder"?>
<?else?>
<?define ProgFilesFolder="ProgramFilesFolder"?>
<?endif?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
UpgradeCode="$(var.UpgradeCode)" Name="Pandoc $(var.VERSION)"
Version="$(var.VERSION)" Manufacturer="John MacFarlane"
@nkalvi
nkalvi / pandoc.wxs
Created June 29, 2015 13:30
pandoc.wxs 2015-06-29
<?xml version="1.0"?>
<?define UpgradeCode = "A68E8EF6-ABB1-4F22-A3C5-68DFDF0AB562" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
UpgradeCode="$(var.UpgradeCode)" Name="Pandoc $(var.VERSION)"
Version="$(var.VERSION)" Manufacturer="John MacFarlane"
Language="1033">
<Package InstallerVersion="200" Compressed="yes"
Comments="Windows Installer Package" />
@nkalvi
nkalvi / pandoc.wxs
Created June 29, 2015 03:57
pandoc.wxs 2015-06-15
<?xml version="1.0"?>
<?define UpgradeCode = "A68E8EF6-ABB1-4F22-A3C5-68DFDF0AB562" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
UpgradeCode="$(var.UpgradeCode)" Name="Pandoc $(var.VERSION)"
Version="$(var.VERSION)" Manufacturer="John MacFarlane"
Language="1033">
<Package InstallerVersion="200" Compressed="yes"
Comments="Windows Installer Package" />
@nkalvi
nkalvi / pandoc-1.14-test-pandoc.log
Created April 22, 2015 23:31
pandoc-1.14-test-pandoc.log
Test suite test-pandoc: RUNNING...
pandoc: ignoring :language: field because the parent of role :python: is :indirect: not :code:
Old:
markdown:
writer:
basic: [OK]
tables: [OK]
lhs to normal: [OK]
lhs to lhs: [OK]
reader: