Skip to content

Instantly share code, notes, and snippets.

View ironhouzi's full-sized avatar

Robin Skahjem-Eriksen ironhouzi

View GitHub Profile
@ironhouzi
ironhouzi / evdev.xml
Created May 20, 2014 22:38
XKB rules for Poker II in both English (US) and Norwegian (no dead keys), allowing esc to be used as the key to the left of '1' on a full size keyboard. Esc is handled by xcape to allow for dual-role caps_lock.
<!-- This goes in: X11/xkb/rules/evdev.xml -->
<!-- This file adds the custom layouts (no_poker & us_poker) -->
<!-- to the menu of available keyboard layouts. -->
<!-- This snippet goes above the tag: </layoutList> -->
<!-- ... -->
<layout>
<configItem>
<name>us_poker</name>
<shortDescription>us</shortDescription>
global !p
import string, vim
import textwrap
_snips_fns = {}
def py(*args):
import re
old_a = vim.eval('@a')
import sys
from PyQt4.QtGui import \
QApplication, \
QDialog, \
QGraphicsScene, \
QGraphicsView, \
QVBoxLayout, \
QPainter
@ironhouzi
ironhouzi / Makefile
Last active August 29, 2015 14:10
edit distance in c
ODIR := obj/
SDIR := src/
LDFLAGS = -lncurses
#TODO fix -g
DFLAGS = -g -std=c99 -Wall -Wextra -pedantic
CC = clang
lz : $(ODIR)lz.o
$(CC) $^ -o $@ $(LDFLAGS)
" vim-plug
call plug#begin('~/.vim/plugged')
" Bare necessities
Plug 'tpope/vim-surround'
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-vinegar'
nnoremap <leader>w :silent! %s/\s\+$//<cr>:let @/=''<CR>:w<CR>
function! FixInf3151()
normal mz
set st=2 sts=2 noet
retab!
set st=4 sts=4 et
retab
normal ,w
normal gg=G
@ironhouzi
ironhouzi / .vimrc
Last active August 29, 2015 14:20
Toggle between c/h-files
function! ToggleCH()
let extension = expand('%:e')
if extension =~ 'c'
let extension = '.h'
elseif extension =~ 'h'
let extension = '.c'
else
return
endif
# alt-. cycles last arguments
bindkey -M viins '^[.' insert-last-word
bindkey '^R' history-incremental-search-backward
bindkey '^N' up-line-or-beginning-search
bindkey '^P' down-line-or-beginning-search
@ironhouzi
ironhouzi / bioluminescence.vim
Created May 18, 2015 07:21
Bioluminescence - For Vim in 256 colours
" Vim color file - bioluminescence
" Generated by http://bytefluent.com/vivify 2015-05-18
set background=dark
if version > 580
hi clear
if exists("syntax_on")
syntax reset
endif
endif
@ironhouzi
ironhouzi / nice_but_slow.py
Created May 28, 2015 12:13
Python optimization problem
def validWylie(self, syllable):
return syllable.wylie.startswith(self.ga_prefix) \
or not any(char not in self.latin_set for char in syllable.wylie)
# called with: if not validWylie(somesyllable): ...
# runs at 10.7 seconds on test case