Skip to content

Instantly share code, notes, and snippets.

View ironhouzi's full-sized avatar

Robin Skahjem-Eriksen ironhouzi

View GitHub Profile
@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
#include <stdio.h>
#include <limits.h>
int main(void) {
int a = ((INT_MAX) / 2);
int b = ((INT_MAX) / 2) + 2;
long x = (long)(a + b);
printf("x = %d\na = %d\tb = %d\n", x, a, b);
@ironhouzi
ironhouzi / nvim_terminfo_fix.md
Last active August 29, 2015 14:27
Fixing terminfo for Neovim
  1. Create a copy of your terminfo file (mine is screen-256color):
  • mkdir -p ~/.terminfo && cd ~/.terminfo
  • infocmp > screen-256color
  1. Edit the file so that the backspace entry has the value \177. The name of the entry was in my case kbs, but perhaps you'll see key_backspace.
  • My example: il=\E[%p1%dL, il1=\E[L, ind=^J, initc@, is2=\E)0, kbs=\177
  1. Compile: tic screen-256color

  2. TERMINFO=~/.terminfo/ nvim works!

@ironhouzi
ironhouzi / .vimrc
Created September 4, 2015 11:31
Set's javapath
" Recurse to given file name
function! SetJavaPath()
let target_file = "build.xml"
let regex = eval("$HOME")
let java_path_root_dir = findfile(target_file, ".;")
let java_path = substitute(java_path_root_dir, regex, "~", "")
let g:syntastic_java_javac_classpath = fnamemodify(java_path, ":h")
endfunction
command! -register SetJavaPath call SetJavaPath()
LOCAL_DOCKER_IP = 192.168.99.100
STAGING_IP = xx.xxx.xxx.xxx
PRODUCTION_IP = xx.xxx.xxx.xxx
STAGING_DB_ID = $(shell ssh root@xx.xxx.xxx.xxx "docker ps | grep database" | awk '{print $$1}')
PRODUCTION_DB_ID = $(shell ssh root@xx.xxx.xxx.xxx "docker ps | grep database" | awk '{print $$1}')
download_production_db:
psql -h $(LOCAL_DOCKER_IP) -p 5432 -U postgres -c 'drop database estage_manager'
psql -h $(LOCAL_DOCKER_IP) -p 5432 -U postgres -c 'create database estage_manager'
@ironhouzi
ironhouzi / gist:044bdf68dd5297bcfb91
Created January 24, 2016 17:26
Tutum stackfile example
authorizedkeys:
image: 'tutum/authorizedkeys:latest'
autodestroy: always
deployment_strategy: every_node
environment:
- 'AUTHORIZED_KEYS=ssh_keys_go_here
tags:
- estage_manager
- staging
volumes:
@ironhouzi
ironhouzi / home_models.py
Last active November 7, 2016 23:48
Error: django.db.utils.ProgrammingError: multiple primary keys for table "gcal_centre" are not allowed
class AbstractHomePage(Page):
body = StreamField(HomePageStreamBlock(), verbose_name='hovedinnhold')
headingpanel = StreamField(
HeadingPanelStreamBlock(),
verbose_name='overpanel'
)
sidepanel = StreamField(SidePanelStreamBlock(), verbose_name='sidepanel')
class Meta:
abstract = True