Skip to content

Instantly share code, notes, and snippets.

(defun isearch-delete-me ()
(interactive)
(delete-char (- (length isearch-string))))
(define-key isearch-mode-map (kbd "<C-backspace>") 'isearch-delete-me)
@magnars
magnars / setup-hippie.el
Created November 12, 2012 17:23
Hippie Expand: use closest matches first
;; To use, replace these values in your hippie-expand-try-functions-list:
;;
;; try-expand-dabbrev => try-expand-dabbrev-closest-first
;; try-expand-line => try-expand-line-closest-first
;;
(defvar he-search-loc-backward (make-marker))
(defvar he-search-loc-forward (make-marker))
(defun try-expand-dabbrev-closest-first (old)
@magnars
magnars / donations.md
Last active March 20, 2019 18:50
Donations for any of my open source work

Are you happily using one of my open source projects, and want to donate somehow? I'm so glad to hear it. I am happy to accept donations to any of the following non-profits:

  • 350.org uses online campaigns, grassroots organizing, and mass public actions to oppose new coal, oil and gas projects, take money out of the companies that are heating up the planet, and build 100% clean energy solutions that work for all. 350's network extends to 188 countries.

  • Environmental Defense Fund create environmentally sound solutions that also carry economic benefits, such as removing obsolete rules that hamper the clean energy market in the U.S. EDF rewards people for protecting the environment, not exploiting it. Rooted in strong science and economics, they work with allies across the political spectrum and partnering with business, turning ideas into lasting change.

  • Sierra Club Foundation promotes climate solutions, conservation, an

@magnars
magnars / dev.clj
Last active February 11, 2019 22:36
Suppress datomic transactions to prod from dev
(defn suppress-datomic-transactions-to-prod [config]
(when (str/starts-with? (:datomic-uri config) "datomic:ddb://")
(println "Warning! Suppressing transactions to production datomic from dev environment. Check your config.")
(let [the-conn (d/connect (:datomic-uri config))]
(alter-var-root (var datomic.api/transact)
(fn [transact]
(fn [conn txs]
(if (= conn the-conn)
(do (log/warn "Suppressed datomic transaction to production.")
(let [db (d/db conn)] (future {:db-after db :db-before db :tx-data nil})))
(Thread/setDefaultUncaughtExceptionHandler
(reify Thread$UncaughtExceptionHandler
(uncaughtException [_ thread ex]
(log/error ex "Uncaught exception on" (.getName thread)))))
@magnars
magnars / gist:2360578
Created April 11, 2012 17:05
ido-imenu as used in Emacs Rocks #10
(defun ido-imenu ()
"Update the imenu index and then use ido to select a symbol to navigate to.
Symbols matching the text at point are put first in the completion list."
(interactive)
(imenu--make-index-alist)
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
@magnars
magnars / gist:2350388
Created April 10, 2012 10:50
Push mark when using ido-imenu
;; Push mark when using ido-imenu
(defvar push-mark-before-goto-char nil)
(defadvice goto-char (before push-mark-first activate)
(when push-mark-before-goto-char
(push-mark)))
(defun ido-imenu-push-mark ()
(interactive)
<!DOCTYPE html>
<html>
<!-- This file is autogenerated with info from build/link_app/build_config.clj
Regen with build/build-dev.sh -->
<head><meta charset="UTF-8"><meta content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width" name="viewport"><meta content="yes" name="apple-mobile-web-app-capable"><meta content="yes" name="mobile-web-app-capable"><link href="/css/reset.css" rel="stylesheet" /><link href="/css/ionicons.css" rel="stylesheet" /><link href="/css/lato.css" rel="stylesheet" /><link href="/css/init.css" rel="stylesheet" /><link href="/css/inspector.css" rel="stylesheet" /><link href="/css/main.css" rel="stylesheet" /></head><body><div id="main-app-area"></div><script src="/app-config/local-defaults.js"></script><script src="/app-config/local-overrides.js"></script><script src="/js/lib/linkBrowser.js"></script><script src="/js/lib/base64Decode.js"></script><script src="/js/lib/intercom-tracking.js"></script><script src="/js/lib/heap-tracking.js"></script><script src="/js/
@magnars
magnars / gist:3048595
Created July 4, 2012 17:57
cleanup-buffer.el
(defun cleanup-buffer-safe ()
"Perform a bunch of safe operations on the whitespace content of a buffer.
Does not indent buffer, because it is used for a before-save-hook, and that
might be bad."
(interactive)
(untabify-buffer)
(delete-trailing-whitespace)
(set-buffer-file-coding-system 'utf-8))
(defun cleanup-buffer ()
(function (L) {
"use strict";
describe("lms.events 'first-results'", function () {
var eventHub;
beforeEach(function () {
eventHub = FINN.eventHub.create();
L.setupFirstResultsEvent(eventHub);
});