Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Losh sjl

View GitHub Profile
@sjl
sjl / markdown.vim
Created Jun 21, 2011 — forked from vim-voom/markdown.vim
Markdown folding for Vim
View markdown.vim
" folding for Markdown headers, both styles (atx- and setex-)
" http://daringfireball.net/projects/markdown/syntax#header
"
" this code can be placed in file
" $HOME/.vim/after/ftplugin/markdown.vim
func! Foldexpr_markdown(lnum)
let l1 = getline(a:lnum)
if l1 =~ '^\s*$'
View foldtext.vim
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
View list-out-of-lambda.js
var empty_list = function(selector) {
return selector(undefined, undefined, true);
};
var prepend = function(el, list) {
return function(selector) {
return selector(el, list, false);
};
};
var head = function(list) {
@sjl
sjl / qud-item-values
Last active Oct 29, 2020
Item values in Caves of Qud, sorted by value/weight ratio
View qud-item-values
PRICE/WEIGHT | ITEM-KEY | DISPLAY-NAME | PRICE | WEIGHT
10000.0 | HANDENUKE | &mHand-E-Nuke | 10000.0 | 1.0
3000.0 | TIMECUBE | &ctimecube | 3000.0 | 1.0
2265.0 | MENTAL-AGGREGATOR | mental aggregator | 2265.0 | 1.0
1135.0 | SHORT-SWORD8 | &rmetametal &Kshort sword | 1135.0 | 1.0
750.0 | GEOMAGNETIC-DISC | geomagnetic disc | 750.0 | 1.0
635.0 | DAGGER8 | &rmetametal dagger | 635.0 | 1.0
630.0 | SHORT-SW
@sjl
sjl / ext.vim
Created Dec 15, 2014
ways to run external commands in vim
View ext.vim
" run command
" no stdin
" output displayed in "Press enter to continue" style
" current buffer untouched
:!uptime
" run command
" pipe range of text to command on stdin
" output replaces the range in the current buffer
:RANGE!grep foo
View lisprb.lisp
(declaim (optimize (speed 3) (safety 1) (space 1) (debug 1) (compilation-speed 1)))
(defconstant +width+ 1280)
(defconstant +height+ 720)
(defconstant +samples+ 50)
(defconstant +max-depth+ 5)
(defstruct (vec
(:conc-name v-)
@sjl
sjl / next_motion_mapping.vim
Created Aug 25, 2011 — forked from AndrewRadev/LICENSE
Execute a vim motion on the "next" text object
View next_motion_mapping.vim
" Motion for "next/last object". For example, "din(" would go to the next "()" pair
" and delete its contents.
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
@sjl
sjl / nextlast.vim
Created Sep 21, 2012
next/last text objects
View nextlast.vim
" Next and Last {{{
" Motion for "next/last object". "Last" here means "previous", not "final".
" Unfortunately the "p" motion was already taken for paragraphs.
"
" Next acts on the next object of the given type in the current line, last acts
" on the previous object of the given type in the current line.
"
" Currently only works for (, [, {, b, r, B, ', and ".
"
View list.lisp
;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
(in-package :split-sequence)
(declaim (inline
collect-until
count-while
split-list split-list-if split-list-if-not
split-list-from-end split-list-from-start split-list-internal))
View gist:124c4eff0273e8d0b477bfecf11774f8
(defcommand screen-single () ()
(loop with laptop = "eDP1"
with extern = "DP1"
for (output commands) in `((,laptop ("--primary"))
(,extern ("--off"))
(,laptop ("--preferred")))
do (uiop:run-program `("xrandr" "--output" ,output ,@commands))))
(defcommand screen-multi () ()
(loop with laptop = "eDP1"