Skip to content

Instantly share code, notes, and snippets.

@halbtuerke
halbtuerke / init.el
Created September 7, 2015 18:46
Save and restore shell buffers with desktop.el
(add-hook 'shell-mode-hook
(lambda ()
(make-local-variable 'desktop-save-buffer)
(setq desktop-save-buffer
(lambda (desktop-dirname)
default-directory))))
(defun shell-restore-desktop-buffer (file-name buffer-name directory)
(setq default-directory directory)
(shell))
@halbtuerke
halbtuerke / omnifocus-capture.el
Last active September 1, 2015 08:21 — forked from jrblevin/omnifocus-capture.el
Sending Tasks to OmniFocus from Emacs <http://jblevins.org/log/emacs-omnifocus>
;; Based on omnifocus-capture.el by Ken Case with the following original comment:
;;
;; To capture tasks from Emacs to OmniFocus using Control-C Control-O,
;; drop this script in your emacs load path and add lines like these to
;; your .emacs:
;;
;; (autoload 'send-region-to-omnifocus "omnifocus-capture" "Send region to OmniFocus" t)
;; (global-set-key (kbd "C-c C-o") 'send-region-to-omnifocus)
;;
;; The send-region-to-emacs function has been rewritten as follows:
@halbtuerke
halbtuerke / my-where-is.el
Last active August 29, 2015 14:16
Find key sequences of Emacs lisp function
;; PACKAGE: DASH
(use-package dash
:defer t
:ensure t)
(defun my-where-is (definition count &optional length)
"Return COUNT key sequences that invoke the command DEFINITTION as a string.
If COUNT is 0 then all key sequences will be returned.
The optional LENGTH argument limits the returned string to LENGTH number of chars.
@halbtuerke
halbtuerke / gist:5850c411498421865632
Created February 21, 2015 19:09 — forked from kiding/gist:589242021df49eb17be3
UTM Stripper Bookmarklet
javascript:(function()%7Bvar%20e%3Dwindow.location.href%3Bvar%20t%3De.indexOf(%22%3F%22)%3Bif(e.indexOf(%22utm_%22)%3Et)%7Bvar%20n%3De.replace(%2F(%5B%3F%26%5Dutm_(source%7Cmedium%7Cterm%7Ccampaign%7Ccontent)%3D%5B%5E%26%23%5D%2B)%2Fig%2C%22%22)%3Bif(n.charAt(t)%3D%3D%3D%22%26%22)%7Bn%3Dn.substr(0%2Ct)%2B%22%3F%22%2Bn.substr(t%2B1)%7Dif(n!%3De)%7Bhistory.replaceState(null%2Cnull%2Cn)%7D%7D%7D)();
(defun test-search-forward-replace-match ()
(interactive)
(save-excursion
(with-current-buffer (current-buffer)
(goto-char (point-min))
(search-forward "test" nil t)
(replace-match "it works"))))
(defun toggle-transparency ()
"Toggles the transparency of the current frame"
(interactive)
(let ((alpha-value 85))
(cond
((equal (frame-parameter nil 'alpha) nil) ; case 1
(set-frame-parameter (selected-frame) 'alpha '(alpha-value alpha-value))) ; action 1
((= alpha-value (car (frame-parameter nil 'alpha))) ; case 2
(set-frame-parameter (selected-frame) 'alpha '(100 100))) ; action 2
(t ; default case
# Usage:
# [sudo] gem install mechanize
# ruby tumblr-photo-ripper.rb
require 'rubygems'
require 'mechanize'
# Your Tumblr subdomain, e.g. "jamiew" for "jamiew.tumblr.com"
site = "doctorwho"
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)

Save books out of Safari Books Online

From http://objectivesea.tumblr.com/post/9033067018/safaribooks

This is hard. I spent way too much time figuring this out, because I was annoyed that a book I bought (Addison-Wesley) was available online for free, except only for 45 days after which payment was required. So I made this hack... probably useful to no one else, but here it is.

Requirements:

  1. iPad.
  2. Safari To Go (the Safari Books Online iPad app).
#!/bin/bash
# Runs the specified command (provided by the first argument) in all tmux panes
# for every window regardless if applications are running in the terminal or not.
function execute_in_all_panes {
# Notate which window/pane we were originally at
ORIG_WINDOW_INDEX=`tmux display-message -p '#I'`
ORIG_PANE_INDEX=`tmux display-message -p '#P'`