Skip to content

Instantly share code, notes, and snippets.

View ironhouzi's full-sized avatar

Robin Skahjem-Eriksen ironhouzi

View GitHub Profile
#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()
@ironhouzi
ironhouzi / .vimrc
Last active December 20, 2015 04:29
Basic vimrc
set nocp " use vim settings instead of vi - MUST BE 1ST LINE!
" set pathogen plugin which helps installing plugins and runtime files
execute pathogen#infect()
set encoding=utf-8
set fileencoding=utf-8
scriptencoding utf-8
let mapleader = ","
syntax on " enable syntax highlighting
@ironhouzi
ironhouzi / .vimrc
Last active December 26, 2015 07:59
Airline settings
" ---------------------------------------
" AIRLINE
" ---------------------------------------
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_fugitive_prefix = '⎇ '
let g:airline#extensions#tabline#enabled = 0 " Extended tab bar on top
let g:airline#extensions#default#section_truncate_width = {
\ 'a': 45,
\ 'b': 45,
@ironhouzi
ironhouzi / tibtest.html
Last active January 4, 2016 00:39
Corner case for testing correct stacking of Tibetan Unicode glyphs
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p style="font-size:400%"> &#x0f67;&#x0fb9;&#x0fa8;&#x0fb3;&#x0fba;&#x0fbc;&#x0fbb;&#x0f83;&#x0f0b;&#x0f4a;&#x0f9b;&#x0f9c;&#x0f9d;&#x0f9e;&#x0f71; </p>
</body>
</html>
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 / .muttrc
Last active June 9, 2016 17:44
Script for piping IMAP and SMTP passwords from KWallet to mutt.
#in .muttrc
set imap_pass ="`pass.sh mutt 2>&1`"
set smtp_pass ="`pass.sh mutt 2>&1`"
@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