Skip to content

Instantly share code, notes, and snippets.

@dagronf
dagronf / find-focus-stealer.swift
Last active September 24, 2024 09:17
Swift command-line tool to find which application is stealing your Mac's focus [macOS, script, steal, focus]
#!/usr/bin/swift
import Foundation
import AppKit.NSWorkspace
// Returns the name of the frontmost app, or <none> if no app is frontmost
func currentFocusApp() -> String {
NSWorkspace.shared.frontmostApplication?.localizedName ?? "<none>"
}
@kingargyle
kingargyle / End GCode
Last active February 9, 2024 10:35
Prusa Slicer Anycubic Kobra Neo
M117 Cooling down...
M104 S0 ; turn off extruder
M107 ; Fan off
M140 S0; Turn bed off
M84 ; disable motors
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 ;X-20 Y-20 F240 ;move Z up a bit and retract filament even more
G28 X0 ;move X to min endstops, so the head is out of the way
G90 ;Absolute positionning
@byt3bl33d3r
byt3bl33d3r / manager-config.yml
Created November 14, 2021 19:05
Nebula configuraton files for docker swarm manager and worker nodes
# !! Remember to replace LIGHTHOUSE_IP with your actual Nebula lighthouse external IP Address
# See the example config file to know what all of these options do https://github.com/slackhq/nebula/blob/master/examples/config.yml
pki:
ca: /etc/nebula/ca.crt
cert: /etc/nebula/host.crt
key: /etc/nebula/host.key
static_host_map:
"192.168.100.1": ["<LIGHTHOUSE_IP>:4242"]
@dagronf
dagronf / Notification+Visibility.swift
Last active April 13, 2024 12:50
Observe all notifications sent through a NotificationCenter or DistributedNotificationCenter
// Observe all notifications generated by the default NotificationCenter
NotificationCenter.default.addObserver(
forName: nil, object: nil, queue: nil) { notification in
Swift.print("Notification: \(notification.name.rawValue), Object: \(notification.object)")
}
// Observe all notifications generated by the default DistributedNotificationCenter
DistributedNotificationCenter.default().addObserver(
forName: nil, object: nil, queue: nil) { notification in
Swift.print("Notification: \(notification.name.rawValue), Object: \(notification.object)")
// Don't forget to add to the project:
// 1. DeepLabV3 - https://developer.apple.com/machine-learning/models/
// 2. CoreMLHelpers - https://github.com/hollance/CoreMLHelpers
enum RemoveBackroundResult {
case background
case finalImage
}
extension UIImage {
@dagronf
dagronf / ImageConversion.swift
Last active October 21, 2024 20:06
Extensions for converting NSImage <-> CGImage <-> CIImage
extension NSImage {
/// Create a CIImage using the best representation available
///
/// - Returns: Converted image, or nil
func asCIImage() -> CIImage? {
if let cgImage = self.asCGImage() {
return CIImage(cgImage: cgImage)
}
return nil
}
@onebytegone
onebytegone / backup-restore-docker-volume.md
Created November 14, 2018 00:59
Backup and restore a Docker volume on Mac OS X

Backup and restore a Docker volume on Mac OS X

This is a rough draft for backing up and restoring data contained in a Docker volume. I can't say that this is a "best practice". For my limited testing at the moment, it seems sufficient.

Example docker-compose.yml

version: '3'
@loganvolkers
loganvolkers / Byte Formatting for Google Sheets.md
Last active November 16, 2024 20:13
Byte formatting for Google Sheets
<html>
<head>
<script>
var Module = {
wasmBinaryFile: "site.wasm",
onRuntimeInitialized: main,
};
function run_with_ptr(vec_ptr, cb) {
const ptr = Module.HEAPU32[vec_ptr / 4];
@singhabhinav
singhabhinav / kafka_hands_on.sh
Last active February 19, 2021 11:49
Kafka hands-on on CloudxLab
# Include Kafka binaries in the path
export PATH=$PATH:/usr/hdp/current/kafka-broker/bin
# Create the topic
# Replace localhost with the hostname of node where zookeeper server is running.
# Replace test with your topic name
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
# Check if topic is created
kafka-topics.sh --list --zookeeper localhost:2181