Skip to content

Instantly share code, notes, and snippets.

View markusfisch's full-sized avatar

Markus Fisch markusfisch

View GitHub Profile
@markusfisch
markusfisch / README.md
Last active August 29, 2015 14:00
Format data and automatically allocate memory to be of sufficient length

maprintf

Format data and automatically allocate memory to be of sufficient length.

This is a care-free alternative to snprintf() with strings of arbitrary length.

Sample

@markusfisch
markusfisch / .vimrc
Created May 8, 2014 08:24
Put this in your .vimrc to easily switch between tabs (F5) and spaces (F6) and highlight improper indent
" Use Tabs
function! UseTabs()
" Highlight tabs within lines, trailing whitespace and
" spaces at the beginning of lines
match errorMsg /[^\t]\zs\t\+\|\s\+$\|^[\t]*[ ]\+[\t]*[^\*]/
set noexpandtab
endfunc
nnoremap <F5> :call UseTabs()<CR>
" Use Spaces
@markusfisch
markusfisch / workspace.sh
Created May 16, 2014 07:27
bash script to easily switch to next workspace in Ubuntu compbiz using wmctrl
#!/usr/bin/env bash
# Switch to next viewport
next_viewport()
{
if (( X+VIEWPORT_WIDTH >= TOTAL_WIDTH ))
then
X=0
if (( Y+VIEWPORT_HEIGHT >= TOTAL_HEIGHT ))
@markusfisch
markusfisch / README.md
Last active August 29, 2015 14:04
Encode UTF-8 strings to be used with XML

entity

Encode UTF-8 strings to be used with XML.

Converts "Tästø÷…" into "T&#xE4;st&#xF8;&#xF7;&#x2026;".

Quick sample:

#include "entity.h"
@markusfisch
markusfisch / README.md
Created July 28, 2014 11:03
Format strings into a expanding buffer

sbprintf

Format strings into a expanding buffer.

Sample

struct sbprintf_string_buffer sb = { NULL, NULL, 0 };
@markusfisch
markusfisch / android.vim
Created April 24, 2015 16:24
VIM colorscheme, green and blue on a dark background
set background=dark
highlight clear
if exists( "syntax on" )
syntax reset
endif
let g:colors_name = "android"
hi Normal ctermfg=251 ctermbg=235
@markusfisch
markusfisch / how-to-contribute.md
Last active September 15, 2015 11:54
How to contribute

How To Contribute

  • Comply to the existing [code style][style].
  • Be [consistent][pikestyle].
  • Be [pragmatic][perils].
  • Choose [clear and simple semantics][semantics].
  • Prefer many short methods over of a lot of [indent][kernel].
  • Comment only [what the code cannot say][comment].
  • Test.
@markusfisch
markusfisch / mkpw.rb
Last active September 25, 2015 01:57
mkpasswd in ruby
#!/usr/bin/env ruby
c = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!-_".split( // )
(ARGV.length.zero? ? [8] : ARGV).each do |n|
puts (0...n.to_i).map{ c[rand( c.size )] }.join
end
@markusfisch
markusfisch / gist:3136580
Created July 18, 2012 14:40
Pan and zoom/pinch images with MOAI
------------------------------------------------------------------------------
-- local members
------------------------------------------------------------------------------
local devWidth, devHeight = 0, 0
local viewport = nil
local layer = nil
local quad = nil
local prop = nil
local imgWidth, imgHeight = 0, 0
@markusfisch
markusfisch / README.md
Created August 5, 2012 18:10
Configure vim and xterm to look and behave like GVim

Configure vim and xterm to look and behave like GVim

If you like to have an extra window for editing files with vim, you may either install/use GVim or you can simply make vim run inside xterm.

Setup

You'll need (at least) VIM 7.3 and XTerm 276.