Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
host=login12
port=12345
oldTunnel=$(ps ux | grep ssh | grep "\\-L $port")
if [[ -n "$oldTunnel" ]]; then
pid=$(echo "$oldTunnel" | awk '{print $2}')
kill "$pid"
fi
;;; keypeat.el -*- lexical-binding: t; -*-
(defvar ++keypeat-last-keys nil)
(defun ++keypeat-save-h ()
(setq ++keypeat-last-keys (this-command-keys)))
(add-hook 'post-command-hook #'++keypeat-save-h)
(defun ++keypeat-push-prefix (keyseq)
# Cobbled together from https://stackoverflow.com/questions/31607458
import io
import matplotlib.pyplot as plt
from PyQt5.QtGui import QImage
from PyQt5.QtWidgets import QApplication
def add_clipboard_to_figures():
oldfig = plt.figure
;; SCCS I.D. %W% delta: %G% %U% date: %H% %T%
;;;;; tablature-mode.el -- modes for editing guitar tablature in GNU emacs
;; Contains chord-mode and lead-mode, both minor modes of tab-mode.
;; Author: Mark R. Rubin <mark@phineas.jpl.nasa.gov>
;; Version: 1.00
;; Date: 9/20/93

Make sure Emacs server is running! Now use this bit of Lisp:

(defvar my/erc-aggressive-status-clear t
  "Setting this to t means that when you make a channel ``visible''
by unminimizing the Emacs frame or switching to its virtual
desktop, said channel will be removed from the status string. (To
be precise, we call `org-modified-channels-update' from the
polling function `my/erc-status', so there will be a delay
according to your polling interval.) Otherwise you'd need to
(defun mjk/buffer-flippy ()
(interactive)
(let ((now (cadr (current-time)))
(then (or (bound-and-true-p mjk//last-flippy-time) 0))
(prev-counter (or (bound-and-true-p mjk//flippy-counter) 0)))
(setq mjk//last-flippy-time now
mjk//flippy-counter (+ 1 prev-counter))
(if (> (- now then) 2)
(setq mjk//flippy-counter 1))
(if (<= mjk//flippy-counter 2)
@mjkramer
mjkramer / environmentally-friendly-dired.el
Last active March 21, 2018 01:39
fewer dired buffers, for your health!
(with-eval-after-load 'dired
(substitute-key-definition 'dired-find-file 'my/diredp-find-file-reuse-dir-buffer dired-mode-map)
(substitute-key-definition 'dired-mouse-find-file 'my/diredp-mouse-find-file-reuse-dir-buffer dired-mode-map)
(substitute-key-definition 'dired-up-directory 'my/diredp-up-directory-reuse-dir-buffer dired-mode-map))
(defun my/diredp-find-file-reuse-dir-buffer () ; Not bound
"Like `dired-find-file', but reuse Dired buffers.
Unlike `dired-find-alternate-file' this does not use
`find-alternate-file' unless (1) the target is a directory that is not
yet visited as a Dired buffer, and (2) the current (Dired) buffer is
@mjkramer
mjkramer / db_writer.py
Last active March 18, 2018 03:16
a teeny tiny ultra-minimal "ORM" for sqlite
#!/usr/bin/env python2.7
import sqlite3
class DBWriter(object):
class Model(object):
pass
class ModelBox(object):
pass
import os as _os
import dash as _dash
import sys as _sys
from importlib.util import find_spec
_components = _dash.development.component_loader.load_components(
_os.path.dirname(find_spec('ipop_components').origin) + '/metadata.json',
'ipop_components'
)