Skip to content

Instantly share code, notes, and snippets.

@HungMingWu
HungMingWu / Makefile
Created October 23, 2011 09:05
Linux Driver: Example0
mname := brook
$(mname)-objs := main.o
obj-m := $(mname).o
KERNELDIR := /lib/modules/`uname -r`/build
all:
$(MAKE) -C $(KERNELDIR) M=`pwd` modules
clean:
@HungMingWu
HungMingWu / Any.cpp
Created April 7, 2012 02:09
Boost Example
#include <boost/any.hpp>
#include <vector>
#include <iostream>
using namespace std;
using namespace boost;
void test_any()
{
std::vector<any> a;
a.push_back(2);
a.push_back(string("test"));
@HungMingWu
HungMingWu / hello.c
Created October 4, 2012 11:53
Example for gprof
int IsOdd(int x)
{
return x & 1;
}
int main(int argc, char *argv[])
{
for (int i = 0; i < 1000; i++) IsOdd(i);
}
@HungMingWu
HungMingWu / HelloWorld.c
Created November 8, 2012 03:54
JNI Tutorial
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT void JNICALL Java_HelloWorld_sayHello (JNIEnv *env, jobject obj) {
printf("Hello,the World!!!\n");
}
@HungMingWu
HungMingWu / Hello.cpp
Created November 8, 2012 08:16
JNI Tutorial 2
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <jni.h>
int main (int argc, char *argv[])
{
JavaVM *jvm; /* 宣告一個java machine */
JNIEnv *env; /* JNI的環境 */
JavaVMInitArgs vm_args;
@HungMingWu
HungMingWu / Demo1.cpp
Created December 4, 2012 02:42
C++ Return Secret
#include <iostream>
struct foo
{
static int count;
int id;
foo() : id(++count)
{
std::cout << "Constructing! " << id << std::endl;
}
@HungMingWu
HungMingWu / main.cpp
Created December 5, 2012 02:49
Memory Leak demo
#include <stdlib.h>
int main()
{
void *p = malloc(10);
return 0;
}
@HungMingWu
HungMingWu / deleter.cpp
Created December 5, 2012 07:44
Incomplete class types
#include "deleter.h"
void delete_object(Object* p)
{
delete p;
}
@HungMingWu
HungMingWu / _config.yaml.diff
Created December 7, 2012 08:36
Latex on Octopress
index 1a06ae2..ef440ea 100644
--- a/_config.yml
+++ b/_config.yml
@@ -33,7 +33,7 @@ destination: public
plugins: plugins
code_dir: downloads/code
category_dir: blog/categories
-markdown: rdiscount
+markdown: kramdown
pygments: false # default python pygments have been replaced by pygments.rb
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}