Skip to content

Instantly share code, notes, and snippets.

View jiyeqian's full-sized avatar

Jiye Qian jiyeqian

View GitHub Profile
void remove_if ( node **head, node **rear, remove_fn rm )
{
for ( node **curr = head; *curr; ) {
node *entry = *curr;
if ( rm ( entry ) ) {
*curr = entry->next;
if ( *curr ) {
(*curr)->previous = entry->previous;
} else { // the rear node removed
*rear = entry->previous;
@jiyeqian
jiyeqian / list.c
Last active December 15, 2015 06:59 — forked from Soft/list.c
list
#include <stdlib.h>
#include <stdbool.h>
#include "list.h"
Node *list_append(Node *list, void *data) {
if (list) list_last(&list);
Node *node = malloc(sizeof(Node));
if (node) {
node->data = data;
node->next = NULL;
@jiyeqian
jiyeqian / how_to_use_LIST_of_queue.c
Last active December 15, 2015 07:49
queue.h 8.5 (Berkeley) 8/20/94
#include <stdio.h>
#include <stdlib.h>
#include "queue.h"
// Be careful! LIST_* are MACROS, NOT functions. No formal parameters!
typedef struct List {
int data;
LIST_ENTRY ( List ) linker;
@jiyeqian
jiyeqian / opencv_data_structure.c
Last active December 15, 2015 13:58
basic data structures of OpenCV
#define IPL_DEPTH_1U 1 // 1位无符号整型(1bit)
#define IPL_DEPTH_8U 8 // 8位无符号整型(unsigned char)
#define IPL_DEPTH_16U 16 // 16位无符号整型
#define IPL_DEPTH_32F 32 // 32位浮點
#define IPL_DEPTH_8S (IPL_DEPTH_SIGN| 8)
#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16)
#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32)
typedef struct _IplImage
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "queue.h"
typedef struct Node {
void *element;
LIST_ENTRY ( Node ) linker;
@jiyeqian
jiyeqian / url_hander.py
Created July 25, 2013 05:50
handle urls of weepy
# http://fighter1945.iteye.com/blog/1347732
import web
from web import form as form
urls = (
'/add/me/(.+)','add',
'/myadd','myadd'
)
class add:
@jiyeqian
jiyeqian / quick.c
Last active January 1, 2016 14:29
Sort Algorithms
void QuickSort(int *seq, const int begin, const int end)
{
if (begin < end) {
int position = begin; // 选择起始元素作为划分参考
int value = seq[position];
for (int i = begin + 1; i < end; ++i) {
if (seq[i] < value) {
position++;
if (position != i) {
Swap(&seq[position], &seq[i]);
@jiyeqian
jiyeqian / x265_log.cpp
Last active August 29, 2015 13:59
x265_log
/* Log level */
#define X265_LOG_NONE (-1)
#define X265_LOG_ERROR 0
#define X265_LOG_WARNING 1
#define X265_LOG_INFO 2
#define X265_LOG_DEBUG 3
#define X265_LOG_FULL 4
// http://tinyhack.com/2014/03/12/implementing-a-web-server-in-a-single-printf-call/
// http://blog.jobbole.com/64252/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<sys/socket.h>
// OpenCV: sumpixels.cpp
template<typename T, typename ST, typename QT>
void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep,
QT* sqsum, size_t _sqsumstep, ST* tilted, size_t _tiltedstep,
Size size, int cn )
{
int x, y, k;
int srcstep = (int)(_srcstep/sizeof(T));