Skip to content

Instantly share code, notes, and snippets.

magnars / setup-hippie.el
Created Nov 12, 2012
Hippie Expand: use closest matches first
View setup-hippie.el
;; 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 /
Last active Mar 20, 2019
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:

  • 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 / dev.clj
Last active Feb 11, 2019
Suppress datomic transactions to prod from dev
View dev.clj
(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})))
View system.clj
(reify Thread$UncaughtExceptionHandler
(uncaughtException [_ thread ex]
(log/error ex "Uncaught exception on" (.getName thread)))))
magnars / gist:2360578
Created Apr 11, 2012
ido-imenu as used in Emacs Rocks #10
View gist:2360578
(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."
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
magnars / gist:2350388
Created Apr 10, 2012
Push mark when using ido-imenu
View gist:2350388
;; 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
(defun ido-imenu-push-mark ()
View index.html
<!DOCTYPE html>
<!-- This file is autogenerated with info from build/link_app/build_config.clj
Regen with build/ -->
<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 / gist:3048595
Created Jul 4, 2012
View gist:3048595
(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."
(set-buffer-file-coding-system 'utf-8))
(defun cleanup-buffer ()
View firstResultEventTest.js
(function (L) {
"use strict";
describe(" 'first-results'", function () {
var eventHub;
beforeEach(function () {
eventHub = FINN.eventHub.create();
View misc-defuns.el
;; shorthand for interactive lambdas
(defmacro λ (&rest body)
`(lambda ()
(global-set-key (kbd "s-l") (λ (insert "\u03bb")))