Skip to content

Instantly share code, notes, and snippets.

View aberezin's full-sized avatar

Alan Berezin aberezin

View GitHub Profile
@apfelchips
apfelchips / defaults.duti
Last active December 23, 2023 03:53
set file-associations on macOS: ~ 🥖.config 🥖duti 🥖defaults.duti
# duti settings file
# src: https://gist.github.com/apfelchips/0073cb3e8d186115f590d318998c1025
# mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/duti/" && curl -L "https://git.io/JRtzH" -o "${XDG_CONFIG_HOME:-$HOME/.config}/duti/default.duti"
# duti-apply wrapper: alias duti-apply='duti -v "${XDG_CONFIG_HOME:-$HOME/.config}/duti"'
## duti documentation http://duti.org/documentation.html
## see also: https://github.com/Lord-Kamina/SwiftDefaultApps#readme
# List of MIME Types:
@mwender
mwender / impbcopy.m
Last active April 29, 2024 02:40
Command line copy an image file to the clipboard in Mac OS X. See first comment for install instructions.
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
if([path isEqualToString:@"-"])
{
// http://caiustheory.com/read-standard-input-using-objective-c
@cowboy
cowboy / sudo-keepalive-example.sh
Created July 15, 2012 20:55
Bash: Sudo keep-alive (good for long-running scripts that need sudo internally but shouldn't be run with sudo)
#!/bin/bash
# Might as well ask for password up-front, right?
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Example: do stuff over the next 30+ mins that requires sudo here or there.
function wait() {