Skip to content

Instantly share code, notes, and snippets.

View luckman212's full-sized avatar

Luke Hamburg luckman212

View GitHub Profile
@joneskoo
joneskoo / ssh-knownhosts-cleanup.py
Last active April 3, 2023 00:42
SSH known hosts cleanup script. Combines same fingerprints to one line.
#!/usr/bin/env python3
# encoding: utf-8
# By Joonas Kuorilehto 2011, MIT license
#
# The script combines .ssh/known_hosts so that each fingerprint is only
# listed once.
import re
import sys
import os
@hjuutilainen
hjuutilainen / Fantastical log messages
Created November 19, 2013 11:47
Log messages by Fantastical (OS X)
19.11.2013 13.41.32,403 secd[540]: securityd_xpc_dictionary_handler Fantastical[1799] copy_matching The operation couldn’t be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements)
19.11.2013 13.41.32,403 Fantastical[1799]: SecOSStatusWith error:[-34018] The operation couldn’t be completed. (OSStatus error -34018 - Remote error : The operation couldn‚Äôt be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements))
19.11.2013 13.41.32,406 secd[540]: securityd_xpc_dictionary_handler Fantastical[1799] copy_matching The operation couldn’t be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements)
19.11.2013 13.41.32,406 Fantastical[1799]: SecOSStatusWith error:[-34018] The operation couldn’t be completed. (OSStatus error -34018 - Remote error : The operation couldn‚Äôt be completed. (OSStatus error -34018 - client has neith
@polo2ro
polo2ro / dump-imap.py
Last active February 9, 2024 22:32 — forked from FiloSottile/dump-imap.py
Simple script to dump an IMAP folder into eml files, store email using the message-id
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import imaplib
import argparse
import email
import re
argparser = argparse.ArgumentParser(description="Dump a IMAP folder into .eml files")
argparser.add_argument('-s', dest='host', help="IMAP host, like imap.gmail.com", required=True)
@mwender
mwender / impbcopy.m
Last active June 1, 2024 01:23
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
@zmwangx
zmwangx / plist2json
Last active August 26, 2022 17:19
Simple plist to JSON converter in Python.
#!/usr/bin/env python3
import argparse
import base64
import collections
import datetime
import json
import plistlib
import sys
import tempfile
@rudelm
rudelm / autofs.md
Last active June 5, 2024 20:26
Use autofs on Mac OS X to mount network shares automatically during access

Autofs on Mac OS X

With autofs you can easily mount network volumes upon first access to the folder where you want to mount the volume. Autofs is available for many OS and is preinstalled on Mac OS X so I show you how I mounted my iTunes library folder using this method.

Prepare autofs to use a separate configuration file

autofs needs to be configured so that it knows where to gets its configuration. Edit the file /etc/auto_master and add the last line:

#
# Automounter master map
#

+auto_master # Use directory service

@bmhatfield
bmhatfield / .profile
Last active May 6, 2024 22:27
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@heptal
heptal / webview_usercontent.md
Last active June 5, 2023 13:32
Poor man's imitation of Postman in Hammerspoon

Exploring the possibilities with hs.webview and hs.webview.usercontent. The primary feature here is WKUserContentController, which allows for injecting user scripts into a web view and for JavaScript to post messages directly back to the native runtime.

The good thing is it's very easy to design the web portion in JS sketchbooks such as jsbin/codepen/jsfiddle because the snippet code structure maps cleanly to this. The bad part is that WKWebView doesn't always behave consistently or have a clean slate. Maybe this will help resolve state issues in the future. It will randomly not be able to find injected scripts without any code changes, and I haven't figured out why.

In this, a two-column table in HTML can be filled with values from Lua tables, and can also send them back. This is used for HTTP requests with arbitrary headers in a fun and exciting way.

@aaronhoffman
aaronhoffman / iphone-text-message-sqlite.sql
Last active May 10, 2024 18:55
SQLite SQL Query for iPhone Text Message Backup
-- more info http://aaron-hoffman.blogspot.com/2017/02/iphone-text-message-sqlite-sql-query.html
select
m.rowid
,coalesce(m.cache_roomnames, h.id) ThreadId
,m.is_from_me IsFromMe
,case when m.is_from_me = 1 then m.account
else h.id end as FromPhoneNumber
,case when m.is_from_me = 0 then m.account
else coalesce(h2.id, h.id) end as ToPhoneNumber
,m.service Service
#! /bin/bash
set -euo pipefail
# This script will remove automatic association for all networks not listed in the whitelist
# passed as the first argument. Passwords will NOT be removed from the Keychain.
#
# Alternatively, you can untick "Remember networks" in Network Preferences > Wi-Fi > Advanced,
# but then you won't be able to auto-join networks even temporarily, and you might already
# have a long list to go through.
#