Skip to content

Instantly share code, notes, and snippets.

View Osse's full-sized avatar

Øystein Walle Osse

View GitHub Profile
@Osse
Osse / .zshrc
Created August 2, 2012 11:59
:help from the command line
function :he {
vim +":he $1" +'wincmd o' +'nnoremap q :q!<CR>'
}
@Osse
Osse / .vimrc
Created August 11, 2012 12:46
Insert_header_guards()
let header = ['#ifndef ', '# define ', '#endif ' ]
function! Insert_header_guards()
let basename=substitute(@%, "[^/]*/", "", "g")
let underscored=tr(basename, ".", "_")
let const=substitute(underscored, ".*", "\\U\\0", "")."_"
call setline(1, map(g:header, 'v:val . const'))
call append('$', ['','','','#endif ' . const])
5
endfunction
@Osse
Osse / output
Created August 21, 2012 17:39
output
osse@osse-w760:/me/H/M/Fai/Faith No More - 1992 - Angel Dust$ ~/Programmering/mperl3tag/mperl3tag.pl
Artist | Album | Track | Title | Genre | Year
--------------+------------+-------+---------------------+-------------+-----
Faith No More | Angel Dust | 14 | Easy (Extra) | Alternative | 1992
Faith No More | Angel Dust | 12 | Jizzlobber | Alternative | 1992
Faith No More | Angel Dust | 13 | Midnight Cowboy | Alternative | 1992
Faith No More | Angel Dust | 02 | Caffeine | Alternative | 1992
Faith No More | Angel Dust | 09 | Be Aggressive | Alternative | 1992
Faith No More | Angel Dust | 10 | A Small Victory | Alternative | 1992
Faith No More | Angel Dust | 01 | Land of Sunshine | Alternative | 1992
@Osse
Osse / perl.pl
Created August 22, 2012 15:56
Find duplicates
sub findDuplicates {
# @info is an array of hashrefs
my @keys = keys $info[0];
grep {
for (my $i = 0; $i < scalar(@info) - 1; $i++) {
# I want to remove any keys from @keys if two adjacent
# values in $info are unequal for the same key
$info[$i]{$_} eq $info[$i]{$_}
}
} @keys;
@Osse
Osse / dups.pl
Created August 23, 2012 16:41
Find duplicates redux
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
# Notice that the values are all equal for some of the keys
my @stuff = ( { a => "1", b => "2", c => '4'},
{ a => "1", b => "3", c => '4'},
@Osse
Osse / reval.vim
Created August 24, 2012 11:28
Reval
autocmd CmdwinEnter * nnoremap <buffer> <CR> <CR>q/"/p
autocmd CmdwinEnter * inoremap <buffer> <CR> <CR>q/"/p
@Osse
Osse / annoying.c
Created August 24, 2012 18:05
Annoying program
#include <stdio.h>
#include <unistd.h>
int main(int argc, char const *argv[]) {
pid_t pid = fork();
if (pid) {
printf("The daemon's PID is %i.\n", pid);
}
else {
printf("The daemon is now running.\n");
@Osse
Osse / eels.patch
Created August 24, 2012 23:02
Patch
diff --git a/src/core/curvematrix.cpp b/src/core/curvematrix.cpp
index c26090a..2a7f3ce 100644
--- a/src/core/curvematrix.cpp
+++ b/src/core/curvematrix.cpp
@@ -340,15 +340,15 @@ void CurveMatrix::inv_inplace_ATLAS(){
//a fast implementation using ATLAS
//this may crash if the library is not found or if it is compiled for the wrong machine in that case revert to the old and slow implementation
//ipiv already has the size of M
- if (!square()) throw CurveMatrixerr::not_square();
-try{
@Osse
Osse / example.patch
Created August 28, 2012 11:10
Git diff output
diff --git a/example.sh b/example.sh
index 08034e3..9f02e0e 100644
--- a/example.sh
+++ b/example.sh
@@ -2,13 +2,13 @@
if [[ -z "$3" ]]
then
- echo "Max two arguments"
- if [[ -z "$2" ]]
@Osse
Osse / away.py
Created September 5, 2012 12:15
Check away status in WeeChat
hdata = weechat.hdata_get("irc_server")
buffer = weechat.buffer_search_main()
weechat.prnt("", "away = %d" % weechat.hdata_integer(hdata, buffer, "is_away"))