Skip to content

Instantly share code, notes, and snippets.

View natewalck's full-sized avatar

Nate Walck natewalck

View GitHub Profile
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@ljos
ljos / cocoa_keypress_monitor.py
Last active January 6, 2024 07:36
Showing how to listen to all keypresses in OS X through the Cocoa API using Python and PyObjC
#!/usr/bin/env python
#
# cocoa_keypress_monitor.py
# Copyright © 2016 Bjarte Johansen <Bjarte.Johansen@gmail.com>
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# “Software”), to deal in the Software without restriction, including
# main config
libdir = /usr/share/mcollective/plugins
logfile = /var/log/mcollective.log
daemonize = 1
keeplogs = 1
max_log_size = 10240
loglevel = debug
identity = my_laptop
registerinterval = 300
@gregneagle
gregneagle / gist:6957826
Last active January 4, 2021 09:39
Using PyObjC and NSWorkspace to set the desktop picture. I am such a hypocrite!
#!/usr/bin/python
'''Uses Cocoa classes via PyObjC to set a random desktop picture on all screens.
Tested on Mountain Lion and Mavericks.
See:
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWorkspace_Class/Reference/Reference.html
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html
#! /usr/bin/env ruby
require 'rubygems'
require 'sinatra/base'
require 'webrick'
#require 'webrick/https'
#require 'openssl'
require 'resolv'
require 'json'
@gregneagle
gregneagle / gurl.py
Last active December 28, 2015 22:29
# http://httpstat.us - for test error codes
# http://uri-labs.com/macosx_headers/NSURLConnection_h/Protocols/NSURLConnectionDelegate/index.html
# Notes:
# - Errors are only thrown when the connection:
# - Is interrupted before the headers can complete
# - SSL couldn't happen correctly
# - The connection never happens
# - A delegate.response always has a NSHTTPURLResponse key for HTTP/HTTPS
# For a file:// transfer, it's NSURLResponse
@grahamgilbert
grahamgilbert / com.grahamgilbert.crypt.launcher.plist
Created December 12, 2013 17:19
LaunchDaemon, LaunchAgent and script to run Crypt as root at login without using a loginhook. The user can click on the desktop and quit the app, but it does get around any networking issues that might happen when running before login is finished.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.grahamgilbert.crypt.launcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/crypt/Crypt.app/Contents/MacOS/Crypt</string>
</array>
@pudquick
pudquick / pids.py
Last active September 19, 2022 21:06
Get pids and path executables for processes running on OS X in python
from ctypes import CDLL, sizeof, memset, c_uint32, create_string_buffer
MAXPATHLEN = 1024
PROC_PIDPATHINFO_MAXSIZE = MAXPATHLEN*4
PROC_ALL_PIDS = 1
libc = CDLL('libc.dylib')
def get_pids():
number_of_pids = libc.proc_listpids(PROC_ALL_PIDS, 0, None, 0)
pid_list = (c_uint32 * (number_of_pids * 2))()
@Nora-Ballard
Nora-Ballard / Set-WindowState.ps1
Last active January 21, 2024 09:25
Hide, Show, Minimize, Maximize, etc window from Powershell.
function Set-WindowState {
param(
[Parameter()]
[ValidateSet('FORCEMINIMIZE', 'HIDE', 'MAXIMIZE', 'MINIMIZE', 'RESTORE',
'SHOW', 'SHOWDEFAULT', 'SHOWMAXIMIZED', 'SHOWMINIMIZED',
'SHOWMINNOACTIVE', 'SHOWNA', 'SHOWNOACTIVATE', 'SHOWNORMAL')]
[Alias('Style')]
[String] $State = 'SHOW',
[Parameter(ValueFromPipelineByPropertyname='True')]
@proudlygeek
proudlygeek / commands-channel.go
Last active March 31, 2024 03:31
Golang Commands in Goroutines
package main
import (
"fmt"
"log"
"os/exec"
"runtime"
)
type Worker struct {