Skip to content

Instantly share code, notes, and snippets.

@jonEbird
jonEbird / remote_pdb.py
Created February 28, 2013 02:18
Slightly modified version of a remote Python pdb session found elsewhere. Just had to add SO_REUSEADDR socket option.
#!/bin/env python
# Taken from http://www.dzone.com/snippets/remote-debugging-python-using
# Only added the SO_REUSEADDR socket option since I hit the breakpoint often
import pdb, socket, sys
class Rdb(pdb.Pdb):
def __init__(self, port=4444):
self.old_stdout = sys.stdout
@jonEbird
jonEbird / satellite-skeleton.py
Created April 26, 2013 20:28
Sample Python script for connecting to your RedHat Satellite or Spacewalk server. But also an example of a file that you can source from your shell to help set some useful variables for subsequent invocations of your Python script. Trying to combine two conveniences into one file. I had seen this before and got a refresher course from [rosettaco…
#!/bin/bash
# -*- python -*-
"true" '''\'
#
# Shell Code that helps you setup useful variables. Source this script.
#
BN=$(basename -- $0)
if [ "$BN" == "bash" -o "$BN" == "zsh" -o "$BN" == "sh" ]; then
if [ -z "${SPACEWALK_USER}" ]; then

Keybase proof

I hereby claim:

  • I am jonEbird on github.
  • I am jonebird (https://keybase.io/jonebird) on keybase.
  • I have a public key whose fingerprint is 7643 3897 1509 964E 1C00 A027 ACD1 AB35 6CA2 12CF

To claim this, I am signing this object:

;; Help for attaching buffers and files
; I find it annoying that I have to move to the end of the email to attach
; or suffer the recepients getting the 2nd part of my email in a
; mime-attached generic part
(defun attach-buffer ()
"Call mml-attach-buffer but only after moving to the end of the message"
(interactive)
(save-excursion
(goto-char (point-max))
(call-interactively 'mml-attach-buffer)))
@jonEbird
jonEbird / unique_shell.el
Created June 4, 2014 21:44
Launch a unique shell per session / project
; Launch a unique shell for the particular session or project
(defun jsm/unique-shell (&optional directory)
"Start or return to a shell session named and started from a particular directory"
(interactive)
(let* ((basedir (or directory (read-directory-name "Base Directory: ")))
(default-directory basedir))
(shell (concat "*ProjSH* "
(file-name-base (replace-regexp-in-string "/*$" "" basedir))))))
(defun jsm/projectile-shell-other-window ()
@jonEbird
jonEbird / gh_markdown_preview.el
Created June 12, 2014 23:53
Preview the Github Markdown to HTML convertion before committing. Bound to F12 in markdown-mode.
;; Markdown preview helper
;; ------------------------------
(defun jsm/markdown-preview ()
"Preview the markdown file in a new browser tab"
(interactive)
(let ((my-filename (buffer-file-name))
(html-filename (format "%s.html" (file-name-base (buffer-file-name)))))
(shell-command (format "pandoc -f markdown_github -t html -o %s %s" html-filename my-filename) nil nil)
(browse-url (concat "file://" (file-name-directory (buffer-file-name)) html-filename))))
(define-key markdown-mode-map (kbd "<f12>") 'jsm/markdown-preview)
@jonEbird
jonEbird / screenkey.el
Last active August 29, 2015 14:04
Run screenkey for only a brief period. Intention to bind to key and use during screencasts.
(defvar screenkey-timeout 4
"Number of seconds to allow screenkey to run normally")
(defun screenkey-timed (&optional timeout)
"Run an external command and then asynchronously kill it after timeout"
(interactive)
(start-process "screenkey" "*screenkey*" "screenkey" "--no-detach")
(run-at-time (format "%d sec" (or timeout screenkey-timeout)) nil
'(lambda () (delete-process "*screenkey*"))))
@jonEbird
jonEbird / mock_gnu_screen.el
Last active August 29, 2015 14:05
Simulate a GNU screen setup within Emacs
;; Simulate GNU Screen within Emacs using ansi-term
;; ------------------------------
(defun term-next ()
"Go to the next terminal based on the buffer name. Will extract the
number from the buffer-name, add 1 and go to a buffer of that name if it
exists."
(interactive)
(let ((cur-buffer (buffer-name)))
(if (string-match "\\([0-9]+\\)" cur-buffer)
(let* ((n (match-string-no-properties 0 cur-buffer))
@jonEbird
jonEbird / phi-search_mc.el
Created November 6, 2014 00:27
Only use phi-search when multiple cursors is enabled
;; Allow isearch functionality with multiple-cursors
(require 'phi-search)
(setq phi-search-limit 10000)
(add-hook 'multiple-cursors-mode-enabled-hook
(lambda ()
(interactive)
(global-set-key (kbd "C-s") 'phi-search)
(global-set-key (kbd "C-r") 'phi-search-backward)))
(add-hook 'multiple-cursors-mode-disabled-hook
(lambda ()
@jonEbird
jonEbird / updatefile.py
Created December 2, 2014 18:42
Stage and commit local file updates
import os
import sys
import stat
import shutil
import tempfile
import logging as log
class UpdateFile(object):
"""Update a file atomically