Skip to content

Instantly share code, notes, and snippets.

View fpersson's full-sized avatar

Fredrik Persson fpersson

View GitHub Profile
@fpersson
fpersson / test.lua
Created September 9, 2011 20:52
lua namespace and class
namespace = {}
namespace.class = {}
namespace.class.__index=namespace.class
function namespace.class:create(name)
print("Create a class")
local l = {}
setmetatable(l, namespace.class)
l.m_name = name
@fpersson
fpersson / about.md
Created September 9, 2011 20:59 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@fpersson
fpersson / facts.lua
Created September 9, 2011 21:34 — forked from randrews/facts.lua
Make Lua look like Prolog!
----------------------------------------------------------------------------------------------------
--- Making Lua look like Prolog:
---
--- Let's use metatables for something other than emulating prototype-based OO. By making the
--- __index metamethod create values for undefined things, we can make Lua look like Prolog!
--- We create empty tables for anything starting with a capital letter, functions that populate
--- those tables for lowercase things (to assign relationships) and if a name begins with "is_"
--- then it becomes a function that queries those tables.
----------------------------------------------------------------------------------------------------
@fpersson
fpersson / CMakeLists.txt
Created September 10, 2011 06:06
a minimal working sample of cmake for gtest
# Breif - A minimal working CMakeLists.txt for goggle unittesting
# Author - Fredrik Persson - [email protected]
# Licens - BSD
cmake_minimum_required (VERSION 2.6)
project(demo)
find_package (GTest REQUIRED)
include_directories(${GTest_INCLUDE_DIRS})
@fpersson
fpersson / CMakeLists.txt
Created September 19, 2011 19:34
Abstract Adaptor patter in C++
cmake_minimum_required (VERSION 2.6)
project(demo)
find_package(Boost 1.4.2)
include_directories(${Boost_INCLUDE_DIR})
set(CORELIBS ${Boost_LIBRARIES})
@fpersson
fpersson / CMakeLists.txt
Created September 19, 2011 19:34
Abstract Adaptor patter in C++
cmake_minimum_required (VERSION 2.6)
project(demo)
find_package(Boost 1.4.2)
include_directories(${Boost_INCLUDE_DIR})
set(CORELIBS ${Boost_LIBRARIES})
#!/bin/bash
#Desc: Ett mindre fint bashscript för att skapa en mpeg-film av ett gäng bilder
# med morphad övergång mellan bilderna. Scriptet kräver ffmpeg och ImageMagick.
#Version: 1.1
#Coder: Fredrik Persson
#E-mail: [email protected]
#Download/webpage:
#Licens: BSD
#TODO: Exif-rotation?
@fpersson
fpersson / FileLocker.java
Created October 26, 2011 17:50
Lock a file and change last modified
import java.io.File;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.channels.OverlappingFileLockException;
import java.util.Date;
/**
* @author fredrik Persson
@fpersson
fpersson / FileLocker.java
Created October 26, 2011 18:13
lockfile for android
package test.demo;
import java.io.File;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.Date;
import android.app.Activity;
import android.os.Bundle;
@fpersson
fpersson / FileLocker.java
Created October 26, 2011 18:13
lockfile for android
package test.demo;
import java.io.File;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.Date;
import android.app.Activity;
import android.os.Bundle;