Skip to content

Instantly share code, notes, and snippets.

View vaclavbohac's full-sized avatar

Vaclav Bohac vaclavbohac

View GitHub Profile
@vaclavbohac
vaclavbohac / delegates.cs
Created March 24, 2011 11:05
Example of anonymous methods in C#.
using System;
namespace Example
{
delegate void Callback(int x);
class Application
@vaclavbohac
vaclavbohac / allocation.c
Created April 11, 2011 21:34
Example of memory allocation in C.
// Example of memory allocation in C.
// For educational purposes only.
// Author: Vaclav Bohac
#include <stdio.h>
#include <stdlib.h>
int main( void )
@vaclavbohac
vaclavbohac / queue.c
Created April 11, 2011 23:49
IPC Message queue in C.
// Example of message queue in C.
// For educational purposes only.
// Author: Vaclav Bohac
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
@vaclavbohac
vaclavbohac / queue-delete.c
Created April 11, 2011 23:51
Delete existing message queue in C.
// Deletes message queue in C.
// For educational purposes only.
// Author: Vaclav Bohac
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
@vaclavbohac
vaclavbohac / Makefile
Created April 23, 2011 10:58
matrices.pas
BIN = matrix
matrix: matrix.pas
fpc matrix.pas -o$(BIN)
clean:
rm *.o $(BIN)
@vaclavbohac
vaclavbohac / Makefile
Created May 4, 2011 21:28
Example of threads in c.
# Vaclav Bohac (c) 2011
FLAGS = -D__USE_REENTRANT -lpthread
hthread: hello-thread.o
cc $(FLAGS) -o $@ $<
hello-thread.o: hello-thread.c
cc -o $@ -c $<
@vaclavbohac
vaclavbohac / Makefile
Created May 9, 2011 15:28
Example of binary serialization in C#.
all: test.dll
test.dll: TestSerialization.cs
mono-csc -t:library -pkg:mono-nunit $< -out:$@
test: test.dll
nunit-console $<
clean:
-rm test.dll *.xml
@vaclavbohac
vaclavbohac / Primes.scala
Created May 10, 2011 10:54
Primes in scala.
object Primes {
def iterate(max: Int, callback: (Int) => Boolean) {
for (i <- 1 to max) {
if (callback(i)) {
println(i)
}
}
}
def isPrime(number: Int) : Boolean = {
@vaclavbohac
vaclavbohac / filetype.vim
Created May 17, 2011 10:37
Detecting latte syntax in vim.
" ~/.vim/filetype.vim
" Detecting latte in vim.
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.latte setfiletype smarty
au! BufRead,BufNewFile *.phtml setfiletype smarty
au! BufRead,BufNewFile *.neon setfiletype yaml
@vaclavbohac
vaclavbohac / .emacs
Created May 23, 2011 14:38
My emacs config file.
" Set up color theme. "
(add-to-list 'load-path ".emacs.d")
(require 'color-theme)
(require 'color-theme-gruber-darker)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)