Skip to content

Instantly share code, notes, and snippets.

@ctanis
ctanis / gist:70a2ef077528e5a5c71f8d8473af3e5b
Created November 9, 2021 18:40
use hammerspoon to avoid triggering the menu bar, unless you hold alt
-- don't trigger menubar in fullscreen mode unless you hold alt
stopmenu=hs.eventtap.new({ hs.eventtap.event.types.mouseMoved }, function(e)
local flags=e:getFlags()
if not flags.alt then
if e:location().y<1 then
e:location().y=1
return e
end
end
return nil
@ctanis
ctanis / gist:9bb4610eda3b3f34e8af
Created August 20, 2015 19:32
Here's my emacs/flymake setup for java with and without a dominating build.xml
(require 'flymake)
;; flymake requires something like this in the build.xml:
;; <target name="check-syntax" depends="init" description="check for errors">
;; <javac destdir="${build}"
;; classpathref="project.class.path"
;; includeantruntime="false">
;; <src path="${CHK_SOURCES}" />
;; <compilerarg value="-Xlint" />
;; </javac>
@ctanis
ctanis / package-check.el
Created September 13, 2013 18:50
here's a function for determining how many emacs packages (using emacs 24 package system) are ready to upgrade. this is suitable for execution in batch-mode, perhaps as part of a script that routes output to a system-wide notification
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/" ))
;(package-initialize) ;; trigger elpa packages
(defun get-updatable-count ()
(let (old-archives new-packages)
;; Read the locally-cached archive-contents.
(package-read-all-archive-contents)
(setq old-archives package-archive-contents)
@ctanis
ctanis / gist:6201749
Created August 10, 2013 19:15
a dinky little elisp function for searching duckduckgo with (optionally) the region contents (optionally enclosed in quotes) with no active region, it just sends the minibuffer contents. with an active region, it concats the minibuffer contents with the region contents. with a prefix argument, the region contents are enclosed in quotes.
(defun ddg-search (prefix str)
(interactive "P\nMSearch term: ")
(let ((arg
(if (region-active-p)
(concat str (if prefix " \"" " ")
(buffer-substring (region-beginning) (region-end))
(if prefix "\""))
str)))
(browse-url (concat "https://duckduckgo.com/?q=" (url-hexify-string arg)))))
@ctanis
ctanis / notrackpad.el
Last active December 20, 2015 20:19
lisp to silently ignore all accidental trackpad input ... i wish there was a programmatic way to build these mouse symbols (they're not symbols!)
(dolist (k '([mouse-1] [down-mouse-1] [drag-mouse-1] [double-mouse-1] [triple-mouse-1]
[mouse-2] [down-mouse-2] [drag-mouse-2] [double-mouse-2] [triple-mouse-2]
[mouse-3] [down-mouse-3] [drag-mouse-3] [double-mouse-3] [triple-mouse-3]
[mouse-4] [down-mouse-4] [drag-mouse-4] [double-mouse-4] [triple-mouse-4]
[mouse-5] [down-mouse-5] [drag-mouse-5] [double-mouse-5] [triple-mouse-5]
[mouse-6] [down-mouse-6] [drag-mouse-6] [double-mouse-6] [triple-mouse-6]
[mouse-7] [down-mouse-7] [drag-mouse-7] [double-mouse-7] [triple-mouse-7]
[M-mouse-1] [M-down-mouse-1] [M-drag-mouse-1] [M-double-mouse-1] [M-triple-mouse-1]
[M-mouse-2] [M-down-mouse-2] [M-drag-mouse-2] [M-double-mouse-2] [M-triple-mouse-2]
@ctanis
ctanis / gist:5468298
Created April 26, 2013 15:51
applescript to choose Finder's "remove from dock" Dock context menu option, if present -- assumes(?) that this option is the 9th line in the context menu. also it temporarily mutes the system volume so you don't hear the "poof" sound effect.
tell application "Dock"
activate
end tell
try
set oldvalue to output muted of (get volume settings)
set volume output muted 1
tell application "System Events"
tell process "Dock"
set frontmost to true
activate
@ctanis
ctanis / man.sh
Created April 3, 2013 13:11
open man pages in Preview.app (caches generated pdfs in ~/.manpath)
#!/bin/sh
#Based on this Mac OS X Hint:
#http://hints.macworld.com/article.php?story=20110511111211385
#Modified for input of multiple commands to seperate .PS files
CACHE=~/.mancache
mkdir -p $CACHE
COMMANDS="$@"
for f in $COMMANDS
do
@ctanis
ctanis / gist:4119882
Created November 20, 2012 18:29
gdb 7.5 patch to shut up about unknown BFD/mach-o commands on Mtn. Lion
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 1f9fc17..5e324fc 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -2003,8 +2003,9 @@ bfd_mach_o_write_contents (bfd *abfd)
case BFD_MACH_O_LC_SUB_FRAMEWORK:
break;
default:
- (*_bfd_error_handler) (_("unable to write unknown load command 0x%lx"),
- (unsigned long) cur->type);
@ctanis
ctanis / rlist.pl
Created December 16, 2011 16:37
Some exploratory hacking to access the iCloud-synced safari "reading list" from other desktop browsers.
#! /usr/bin/perl -w
# Craig Tanis
# craig-tanis@utc.edu
# http://weblar.org
#
# http://github.com/ctanis/rlist
# Wed Feb 8 09:04:06 2012
use strict;
@ctanis
ctanis / switch-win.applescript
Created December 14, 2011 14:20
task switcher to complement command tab (i have it on option-tab)
activate
on expose_app(appname)
-- figure out if the current frontmost application is full screen
-- set isFull to false
-- tell application "System Events"
-- set firstProc to (name of first process whose frontmost is true)
-- try
-- tell process firstProc