Skip to content

Instantly share code, notes, and snippets.

(require 'cl)
(require 'ivy)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General-purpose formatting functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ivy--cands-get-details (format_spec cand_info_fns entries)
"Extract symbols from FORMAT_SPEC, and evaluate the
corresponding function found in CAND_INFO_FNS for all ENTRIES.
For example:
(setq my_format_spec '(make-upper-case
@frostidaho
frostidaho / extend-evil-delete.el
Created November 6, 2015 20:55
Calling evil-delete externally?
(require 'evil)
(defun my/evil-delete-hook ()
(interactive)
;; (message "evil delete hook!")
(evil-local-mode -1))
(defun my/evil-delete ()
(interactive)
(unwind-protect
@frostidaho
frostidaho / e.py
Created November 11, 2015 02:56
e.py partial rewrite
#!/usr/bin/env python
"""e.
Usage:
e.py [--wait] [PATHS ...]
e.py (-h | --help)
Options:
-h --help Show this screen.
(bind-chords ("f;" . forward-sexp)
:map minibuffer-local-map
("g;" . minibuffer-keyboard-quit))
;; bind-chords errors with:
;; Debugger entered--Lisp error: (wrong-type-argument listp :map)
;; #[(form) "\203 \302\303\"\207\304 @\305 ADEC\207" [maps form mapcar #[(m) "\302@\303AD F\207" [form m bind-chord quote] 4] bind-chord quote] 4](:map)
;; mapcar(#[(form) "\203 \302\303\"\207\304 @\305 ADEC\207" [maps form mapcar #[(m) "\302@\303AD F\207" [form m bind-chord quote] 4] bind-chord quote] 4] (("f;" . forward-sexp) :map minibuffer-local-map ("g;" . minibuffer-keyboard-quit)))
;; #[(&rest args) "\304\305\"\211<\203 \202 C\306@!\203%\211A\210\211A\210\202\307\310\311\312\313 \"\"!+\207" [args map maps key-bindings plist-get :map keywordp macroexp-progn apply nconc mapcar #[(form) "\203 \302\303\"\207\304 @\305 ADEC\207" [maps form mapcar #[(m) "\302@\303AD F\207" [form m bind-chord quote] 4] bind-chord quote] 4]] 7 ("/home/ida/.cache/emacs_packages/
#!/usr/bin/bash
set -e -E # -e --> exit on err; -E --> print error trace
user="$1"
risna () {
playbook="$1"
user="$2"
rest="${@:3}"
isna $playbook -e username $user -u root,sudo,no $rest
}
@frostidaho
frostidaho / example_xcffib_randr.py
Created January 27, 2017 02:02
randr xcffib usage stub
# http://stackoverflow.com/a/21498380
import xcffib
import xcffib.xproto
import os
conn = xcffib.connect(os.environ['DISPLAY'])
screen = conn.get_setup().roots[conn.pref_screen]
window = conn.generate_id()
x = conn.core.CreateWindow(
@frostidaho
frostidaho / svg_test_bar.py
Created February 28, 2017 01:26
qtile svg test bar
from libqtile import bar
from libqtile import images
from libqtile import widget
BORDER_WIDTH = 4
BAR_SIZE = 32
colors = {
'bg': '#542437',
'bg_fg': '#aa929b',
@frostidaho
frostidaho / .cookiecutterrc
Created March 20, 2017 19:46
cookiecutter pylib issue
# This file exists so you can easily regenerate your project.
#
# `cookiepatcher` is a convenient shim around `cookiecutter`
# for regenerating projects (it will generate a .cookiecutterrc
# automatically for any template). To use it:
#
# pip install cookiepatcher
# cookiepatcher gh:ionelmc/cookiecutter-pylibrary project-path
#
# See:
@frostidaho
frostidaho / using_libqtile_images.py
Created May 5, 2017 01:52
using_libqtile_images.py
aa_svg = b"""
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 112 90">
<path d="M68,87h-13l20-56h14l20,56h-13l-4-12h-20l-4,12zM75,65h14l-7-22l-7,22z
" fill="#2a376e"/>
<path d="M15,87h-13l20-56h14l19,56h-12l-4-12h-21l-3,12zM22,65h14l-7-22l-7,22z" fill="#bf2426"/>
<path d="M705,169c5,18,5,27-2,48l-58,172l-62-175c0,0,7-19,11-30c3,0,9,7,9,7c0,0-7-20-4-24l9-24l10,6c-2-6-5-19-5-19l9-28l10,5c0,0-7-19-5-22l24-63c20,47,36,98,54,147zM659,485c1,5,0,11-5,19c1,10,1,13-2,17c-3,3-6,4-10,4c1-3,1-7,0-8c-13-17-42-50-42-50h-15l-14,36l6,10c0,0,13,0,19,0c1,0,2,1,3,3v6c-1-1-3-2-4-3c-14,0-24,0-37,1l-4,2c-2-5,2-9,5-9c3,0,6,0,5-2c-1-3-2-4-5-7h-16c-16-46-33-92-47-139c6,0,14-3,14-3c0,0-16-6-20-15c-3-9-14-40-14-40c0,0,9-1,13-3c-5-4-18-8-20-14c-7-18-11-35-11-35c0,0,16-1,14-2c-9-4-21-16-21-16c0,0-11-31-11-31c1-1,16,0,16,0c-4-8-16-12-13-23c4-13,9-26,12-34l9,5c-1-5-4-23-4-23l12-35l9,7l-3-24l20-51l52,147l109,310zM475,476l-5-8l-6,8h-22l48-74l27,74h-14l-5-8l-5,8h-18z" fill="#2a376e" transform="scale(0.1)"/>
</svg>
"""
from libqtil