Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@drewkerr
drewkerr / get-focus-mode.js
Last active April 23, 2024 12:34
Read the current Focus mode on macOS Monterey (12.0+) using JavaScript for Automation (JXA)
const app = Application.currentApplication()
app.includeStandardAdditions = true
function getJSON(path) {
const fullPath = path.replace(/^~/, app.pathTo('home folder'))
const contents = app.read(fullPath)
return JSON.parse(contents)
}
function run() {
@nathan-osman
nathan-osman / build-qt5
Last active April 23, 2024 12:33
This script provides an easy way to build Qt5 for both 32 and 64-bit Windows. This script assumes that the Mingw-w64 compilers are installed on the host as well as Perl.
#!/bin/bash
#===========================================
# Download URLs for the required libraries.
#===========================================
# NOTE: if you add a URL here, you also need to add it to the
# $packages_to_build list to ensure the proper order.
declare -A urls=(
@guwidoe
guwidoe / GetLocalOneDrivePath.bas.vb
Last active April 23, 2024 12:33
VBA Function to get the local path of a OneDrive/SharePoint synchronized Microsoft Office file
'Attribute VB_Name = "GetLocalOneDrivePath"
'
' Cross-platform VBA Function to get the local path of OneDrive/SharePoint
' synchronized Microsoft Office files (Works on Windows and on macOS)
'
' Author: Guido Witt-Dörring
' Created: 2022/07/01
' Updated: 2024/04/23
' License: MIT
'
@richardpl
richardpl / drcbox.lua
Last active April 23, 2024 12:31
dynaudnorm filter with visual feedback
--[[
mpv dynaudnorm filter with visual feedback.
Copyright 2016 Avi Halachmi ( https://github.com/avih )
Copyright 2020 Paul B Mahol
License: public domain
Needs mpv with very recent FFmpeg build.
Default config:
@mbostock
mbostock / .block
Last active April 23, 2024 12:30
Hierarchical Edge Bundling
license: gpl-3.0
height: 960
border: no
redirect: https://observablehq.com/@d3/hierarchical-edge-bundling
console.clear();
function saveData(blob, fileName)
{
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
var url = window.URL.createObjectURL(blob);
a.href = url;
@dabodamjan
dabodamjan / MailComposeViewController.swift
Last active April 23, 2024 12:28
Sending a contact us email on iOS 14 (can be also used with SwiftUI)
//
// Feel free to use this code in your project.
// Inspired by SO answer https://stackoverflow.com/a/65743126
// Uses DeviceKit as a dependency https://github.com/devicekit/DeviceKit
//
import Foundation
import MessageUI
import DeviceKit
@miguelmota
miguelmota / log
Created September 20, 2014 06:11
Fully expand object while logging in Node.js
var util = require('util');
console.log(util.inspect(myObject, {showHidden: false, depth: null}));
# alternative shortcut
console.log(util.inspect(myObject, false, null));
# stringifying alternative
console.log(JSON.stringify(myObject, null, 4));
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active April 23, 2024 12:23
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@ThePlenkov
ThePlenkov / boot.sh
Last active April 23, 2024 02:54
Resolve WSL DNS automatically
#!/bin/bash
# Remove existing "nameserver" lines from /etc/resolv.conf
sed -i '/nameserver/d' /etc/resolv.conf
# Run the PowerShell command to generate "nameserver" lines and append to /etc/resolv.conf
# we use full path here to support boot command with root user
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command '(Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses | ForEach-Object { "nameserver $_" }' | tr -d '\r'| tee -a /etc/resolv.conf > /dev/null