Skip to content

Instantly share code, notes, and snippets.

myModule.factory 'websocket', ($q) ->
# to run, inject thus:
# myModule.run (websocket) ->
# websocket.connect("ws://localhost:8000")
# websocket.on "myCommand", (data) ->
# c.log "data received!", data
# websocket.send "my outgoing message"
@danr
danr / Unigen.hs
Created May 24, 2013 12:50
Generate xmodmap files by specifying all modifiers
-- runghc Unigen.hs ∣ xmodmap -
module Main where
import Data.Char
import Numeric
import Data.List
type Mod = (Int,Char,Char,Char,Char)
@danr
danr / nonempty.kak
Created January 28, 2017 17:53
Move around dodging empty lines
def nonempty -params 1 %{
exec -no-hooks %arg{1}
try %{
exec -no-hooks -draft \;Gg<a-k>(\n.*){3}<ret>
exec -no-hooks -draft \;Ge<a-k>(\n.*){3}<ret>
exec -no-hooks -draft \;<a-x><a-k>\A[\n]\Z<ret>
nonempty %arg{1}
}
}
@danr
danr / buffers.kak
Last active February 13, 2017 13:14
simple Kakoune buffer changer
# Buffers (by danr 2017, public domain)
map global normal <a-,> :bp<ret>:bufinfo<ret>
map global normal <a-.> :bn<ret>:bufinfo<ret>
map global normal <a--> ga:bufinfo<ret>
map global normal <a-d> :db<ret>:bufinfo<ret>
map global normal <a-q> :db!<ret>:bufinfo<ret>
def bufinfo %{
%sh{
echo -n info -- %^
@danr
danr / plug.kak
Created March 5, 2017 16:57
simple Kakoune plugin manager
def plug -params 1 %{
%sh{
# Check out the repo to ~/build if it does not exist
if [[ ! -d $HOME/build/$1 ]]; then
(cd $HOME/build; git clone https://github.com/$1)
fi
# Source all .kak files in it
for file in $(echo $HOME/build/$(basename $1)/*.kak); do
echo source "$file"
done
@danr
danr / xml.kak
Created September 19, 2017 08:15
Selecting and wrapping with xml tags in kakoune
def div -params 0..1 -docstring %{Wraps selected text with a tag and indents it.
The parameter can be omitted and then defaults to div.} %{
eval -itersel %{
exec <a-:><a-x>H Zo< / %sh{[ -n "$1" ] && echo "$1" || echo "div"} ><esc><a-x>yz<A-P>s/<ret>dz>
}
}
def select-tag -docstring %{Selects xml tag from start to end.
@danr
danr / expand-write.kak
Created October 22, 2017 11:08
make a json object and write it to a file
# try for example:
# :expand-write state.json '{"selections":%val{selections},"filetype":%opt{filetype},"yank":%reg{"}}'
def expand -params 1 %{
eval -no-hooks -draft %{
try %{
edit -scratch *expand*
}
}
@danr
danr / alexsearch.kak
Last active December 14, 2018 16:56
def tabsearch -params 1 %{
define-command -allow-override next "exec \"%arg{1}\%reg{/}\""
map global prompt <tab> <ret>:next<ret>
exec %arg{1}
}
def colon %{
map global prompt <tab> <tab>
exec :
}
map global normal / ':tabsearch /<ret>'
@danr
danr / Linsris_med_rokt_paprika_och_fankal.md
Created August 19, 2021 14:55 — forked from jonasryberg/Linsris_med_rokt_paprika_och_fankal.md
Jag köpte en tryckkokare. Nu samlar jag på mig bra vegetariska recept att laga till i den.

Linser och ris med smak av rökt paprika och fänkål

Det här receptet ger en rejäl laddning av linser och ris som passar bra att servera till tofu, ha i en wrap eller kanske bara till stekta grönsaker. Ursprungsreceptet hittade jag här.

Ingredienser

  • 400 gram gröna linser
  • 350 gram basmatiris (vitt)
  • 1 liter grönsaksbuljong