Skip to content

Instantly share code, notes, and snippets.

@jmn
jmn / .keysnailrc#bookmark-with-org
Last active August 29, 2015 14:21
.keysnailrc config to create "M-x bookmark-with-org" which uses org-protocol to org-capture the URL, title and selection in the browser.
ext.add("bookmark-with-org",
function (aEvent, aArg) {
var od = window.content.document;
window.loadURI('org-protocol://capture://n/'+encodeURIComponent(od.location.href)+'/'+encodeURIComponent(od.title)+'/'+encodeURIComponent(window.getSelection()));
}, M({en: "Save bookmark in Emacs org-mode using org-protocol"}));
key.setGlobalKey(['C-x', 'r', 'm'], function (aEvent) {
ext.exec("bookmark-with-org", aEvent);
}, 'Bookmark in Emacs org-mode', true);
@jmn
jmn / .keysnailrc#bookmarks-bar
Created May 23, 2015 04:10
Toggle the Firefox bookmarks bar with a keysnail binding
key.setGlobalKey([['C-M-b'], ['C-B']], function (ev) {
var win = Services.wm.getMostRecentWindow(null);
win.CustomizableUI.setToolbarVisibility('PersonalToolbar', document.getElementById('PersonalToolbar').getAttribute("collapsed") == "true");
}, 'Toggle bookmarks bar', true);
@jmn
jmn / Emacs-firefox-org-capture.emacs
Created May 23, 2015 20:15
Emacs org-capture: Handle wrong (non utf-8) character encoding using special template
;; If the org property value of CODING is not nil, mark the (capture) buffer it and use recode-region to recode it to UTF-8.
(defun jmn/recode-buffer-from-cp1252-to-utf-8 ()
""
(message "recoding buffer!")
(interactive)
(mark-whole-buffer)
(recode-region (region-beginning) (region-end) 'cp1252 'utf-8)
)
@jmn
jmn / jmn-url-get-title.el
Last active September 12, 2023 19:36
How to make org-mode org-insert-link (C-c C-l) automatically fill in the description from a webpage
;; How to make org-mode org-insert-link (C-c C-l) automatically fill in the description from a webpage:
(defun jmn/url-get-title (url &optional descr)
"Takes a URL and returns the value of the <title> HTML tag,
Thanks to https://frozenlock.org/tag/url-retrieve/ for documenting url-retrieve"
(let ((buffer (url-retrieve-synchronously url))
(title nil))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
import XMonad
import XMonad.Config.Gnome
import XMonad.Layout.NoBorders (smartBorders)
import XMonad.Util.EZConfig (additionalKeys, removeKeysP)
import XMonad.Actions.NoBorders
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders
-- import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
;; Align messages in Emacs erc IRC-client by setting nick names
;; to use a fixed number of chars.
(defun jmn-erc-format-nick (&optional user channel-data)
"Like `erc-format-nick' but trim/pad nick to a fixed length.
- Based on xwl-erc-format-nick"
(let ((nick (erc-format-nick user channel-data)))
(when (> (length nick) 9)
(setq nick (concat (substring nick 0 6)
".."
@jmn
jmn / gist:4de857259b1dfc54ab80b5682af935ad
Last active July 13, 2021 03:12
Building h2load (of nghttp2) on Ubuntu 16.04
#! /bin/bash
# https://nghttp2.org/documentation/h2load-howto.html
sudo apt-get update
sudo apt-get install g++ make binutils autoconf automake autotools-dev libtool pkg-config \
zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev libjansson-dev \
libc-ares-dev libjemalloc-dev cython python3-dev python-setuptools libjemalloc-dev \
libspdylay-dev
git clone https://github.com/nghttp2/nghttp2.git && cd nghttp2
autoreconf -i && automake && autoconf
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCp5xK+7H7BFptsZOgPabttZx/evAx2TWNZ7GZnO0DrfRxhE7iu3Wv9X+MggMbImbpUnwvlUU9/I+2rs7l+113q6mUTSYv5UdIuykVNUmbSWuT9pk9BQbFWuZq85J3ZoX9mGc0gzpSmlbgCa2NL6L9bWPNldeIRsKn4aXG9H8wdGnNvUGHBk+PRBr0YDoFLbthK4t/KNv6LLvt2Wc2V6zOr3F01hPKVECj3Tj+ughhUlQiKEVsBm3kIUdhjbPinebdXqMrhBt830frBEnS98CpknwU/C8PamMQN8h+QYgH7r+QxNfd/n/ftNfLb8YJay3tOZwVr8ZnoPz/+MBII7bAV jmn@wo
@jmn
jmn / .bash_aliases
Created April 23, 2017 19:23
radio from the console
# http://www.listenlive.eu/uk.html
# wget the playlist and copy the track adress.
alias m='mplayer'
alias bbc-world='m http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-eieuk'
alias p1='m http://http-live.sr.se/p1-aac-192'
alias npr='mplayer tk'
@jmn
jmn / settings.json
Created April 23, 2017 21:36
VS Code settings.json April 2017
{
"workbench.colorTheme": "Minimal Colors",
"workbench.activityBar.visible": true,
"window.zoomLevel": 1,
"workbench.sideBar.location": "right",
"editor.fontLigatures": true,
"editor.fontSize": 12,
"editor.fontFamily": "'Fira Code', 'SF Mono', Hasklig, Menlo, Monaco, 'Courier New', monospace",
"terminal.integrated.fontLigatures": true,
"editor.lineNumbers": "off",