Skip to content

Instantly share code, notes, and snippets.

View junfenglx's full-sized avatar
🏠
Working from home

junfeng_hu junfenglx

🏠
Working from home
View GitHub Profile
@junfenglx
junfenglx / chardev.c
Created December 8, 2013 14:39
char driver demo
#include "chardev.h"
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
//global varibles
static int unused=1;
static int number=0;
static char msg[N]="13111387\0";
@junfenglx
junfenglx / semaphores.c
Created November 11, 2013 13:12
named semaphores use example.
#include <stdio.h> /* printf() */
#include <stdlib.h> /* exit(), malloc(), free() */
#include <unistd.h>
#include <sys/types.h> /* key_t, sem_t, pid_t */
#include <sys/wait.h>
#include <sys/shm.h> /* shmat(), IPC_RMID */
#include <errno.h> /* errno, ECHILD */
#include <semaphore.h> /* sem_open(), sem_destroy(), sem_wait().. */
#include <fcntl.h> /* O_CREAT, O_EXEC */
@junfenglx
junfenglx / compile_flag.sh
Created January 15, 2016 06:44
使用tesseract-ocr和opencv识别视频中文字
#!/bin/bash
g++ -std=c++11 `pkg-config --libs tesseract opencv lept` $1 -o ${1}.out
@junfenglx
junfenglx / mlstm_word_embedding_at_epoch7-8.log
Created June 2, 2016 05:01
SNLI accuracy of match LSTM with word2vec word embedding
Loading data ...
Loading dev ...
10000
10000
9842
Loading test ...
10000
10000
9824
num_epochs: 20
@junfenglx
junfenglx / pcprocess.c
Created November 15, 2013 15:57
producer and consumer problem,process version. using Posix mqueue.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <semaphore.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <mqueue.h>
#define N 1
#define BUFSIZE 1024
@junfenglx
junfenglx / readers_preference.c
Created November 14, 2013 10:53
readers and writers.readers_preference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
int count = 0;
int share=0;
pthread_t maintid;
sem_t roomEmpty;
sem_t mutex;
@junfenglx
junfenglx / decorators.py
Created November 9, 2013 16:23
decorators run
def makebold(fn):
def wrapped():
return "<b>" + fn() + "</b>"
return wrapped
def makeitalic(fn):
def wrapped():
return "<i>" + fn() + "</i>"
return wrapped
@junfenglx
junfenglx / dfa.py
Created November 9, 2013 16:21
DFA simulate
DFA={"A":{0:"B",1:"C"},"B":{0:None,1:"D"},"C":{0:"D",1:None},"D":{0:"A",1:"B"}}
def genstr(n,s,inputs):
if n==0:
inputs.append(s)
return
genstr(n-1,s+"0",inputs)
genstr(n-1,s+"1",inputs)
def simulate():
for n in range(1,15):
var name="Window";
var Top={
name:"top",
Inner:{
name:"inner",
getName:function(){
var that=this;
var i=0;
function increase(){
var rt="this binding:"+this.name+"\n\n"+"number i:"+i;
@junfenglx
junfenglx / test_trail0.py
Created September 1, 2015 02:42
factorial trailing zeros test
# coding: utf-8
cache = dict()
def f(n):
if n <= 0:
return 0
prev = cache.get(n-1)
if not prev:
s = 1;
for i in range(1, n+1):
s *= i