Skip to content

Instantly share code, notes, and snippets.

@MilesLitteral
MilesLitteral / What Is Metal
Last active January 17, 2023 06:37
Description of Metal Shader Language
# What Is Metal
Processing executed in parallel on the GPU can use a Shading language called Metal’s original Metal Shading Language (MSL).
The Metal shading language is a unified language that allows tighter integration between the graphics and compute programs.
MSL Filename Extension
A MSL filename extension is .metal. You can create a new metal file using the metal file template in Xcode.
Using .metal extension allows Xcode to recognize MSL files in your project, automatically build a default library at build time, and help you profile and debug source code with specialized Metal tools.
@Sam0230
Sam0230 / screenlockMonitor.swift
Created July 31, 2021 17:35
Monitoring lock / unlock on macOS.
// import Foundation;
import UserNotifications;
let dnc = DistributedNotificationCenter.default();
let lockObserver = dnc.addObserver(forName: .init("com.apple.screenIsLocked"), object: nil, queue: .main) { _ in
print("lock");
exit(0);
};
let unlockObserver = dnc.addObserver(forName: .init("com.apple.screenIsUnlocked"), object: nil, queue: .main) { _ in
print("unlock");
exit(0);
//
// main.swift
// Shell Notification Center
//
// Created by Keng Lee on 2021/1/15.
//
import Foundation
import Combine
var bag = Set<AnyCancellable>()
# git clone https://github.com/NVlabs/stylegan2
import os
import numpy as np
from scipy.interpolate import interp1d
from scipy.io import wavfile
import matplotlib.pyplot as plt
import PIL.Image
import moviepy.editor
import dnnlib
@Omar-Ikram
Omar-Ikram / EndpointSecurityDemo.m
Last active April 6, 2024 08:56
A demo of using Apple's EndpointSecurity framework - tested on macOS Monterey 12.2.1 (21D62)
//
// main.m
// EndpointSecurityDemo
//
// Created by Omar Ikram on 17/06/2019 - macOS Catalina 10.15 Beta 1 (19A471t)
// Updated by Omar Ikram on 15/08/2019 - macOS Catalina 10.15 Beta 5 (19A526h)
// Updated by Omar Ikram on 01/12/2019 - macOS Catalina 10.15 (19A583)
// Updated by Omar Ikram on 31/01/2021 - macOS Big Sur 11.1 (20C69)
// Updated by Omar Ikram on 07/05/2021 - macOS Big Sur 11.3.1 (20E241)
// Updated by Omar Ikram on 04/07/2021 - macOS Monterey 12 Beta 2 (21A5268h)
@smammy
smammy / macOS-IPv6-Tunnel-DNS-HOWTO.md
Created December 13, 2018 19:14
How to convince macOS to do IPv6 DNS lookups when your only IPv6 address is via a VPN or tunnel of some sort

This was a huge hassle to figure out, so I wrote up a little guide in hopes that others would find it helpful:

How to convince macOS to do IPv6 DNS lookups when your only IPv6 address is via a VPN or tunnel of some sort

The Problem

macOS's domain name resolver will only return IPv6 addresses (from AAAA records) when it thinks that you have a valid routable IPv6 address. For physical interfaces like Ethernet or Wi-Fi it's enough to set or be assigned an IPv6 address, but for tunnels (such as those using utun interfaces) there are some extra annoying steps that need to be taken to convince the system that yes, you indeed have an IPv6 address, and yes, you'd like to get IPv6 addresses back for DNS lookups.

I use wg-quick to establish a WireGuard tunnel between my laptop and a Linode virtual server. WireGuard uses a utun user-space tunnel device to make the connection. Here's how that device gets configured:

@miabrahams
miabrahams / FfmpegPostprocess.py
Last active March 2, 2024 18:07
Ffmpeg post-processing OBS Plugin
import obspython as obs
import subprocess
import os
import re
import datetime
# Info for potential OBS Python hackers!
# Tip 1 - Read the "OBS Studio Backend Design" documentation page. Read the documentation table of contents.
# Tip 2 - be sure to add obspython.py to your script path to enable completion.
# Tip 3 - Some of the Python API is generated at runtime, so it won't show up in obspython.py.
@pudquick
pudquick / heyheyhey.py
Last active April 13, 2019 05:08
Example of using nibbler to make an annoying window that re-focuses itself to the front every second
from nibbler import *
from Foundation import NSTimer, NSObject
from AppKit import NSApplication
n = Nibbler('/Users/frogor/Desktop/sweet.nib')
def test2():
print "hi (politely quit)"
n.quit()
@jonkwheeler
jonkwheeler / Download-Slack-Profile-Pictures.js
Last active August 30, 2023 15:41
Download Slack Profile Pictures / Images
// Enter slack in the browser. https://{insert your team name here}.slack.com/messages/
// Click on the channel you want.
// Click the information icon.
// Expand the members dropdown.
// Click "See All Members"
// Paste the next line into the console, hit enter.
var imageList = new Array()
// If your channel has more than 19 members, the list won't display past that. It also unloads them from the state as you scroll.
@Dregu
Dregu / instant-replay-playlist.lua
Last active October 1, 2020 00:49
OBS-studio script to play instant replays and/or automatically add replays to VLC playlist for later
obs = obslua
source_name = ""
vlc_name = ""
scene_name = ""
replaying = false
autoclear = false
addall = false
replaylength = 10
instant_hotkey_id = obs.OBS_INVALID_HOTKEY_ID
add_hotkey_id = obs.OBS_INVALID_HOTKEY_ID