Skip to content

Instantly share code, notes, and snippets.

View begeekmyfriend's full-sized avatar

Leo Ma begeekmyfriend

View GitHub Profile
@begeekmyfriend
begeekmyfriend / mib_tree.c
Last active April 13, 2021 23:46
MIB tree structure demo
/*
* This file is part of SmartSNMP
* Copyright (C) 2014, Credo Semiconductor Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@begeekmyfriend
begeekmyfriend / msg_tips.c
Created February 2, 2015 14:48
Message enum and string pair
#define MSG_CODEC(ACTION) \
ACTION( UNKNOWN, ""/* unknown */ ) \
ACTION( REQ_GET, "get " ) \
ACTION( REQ_GETS, "gets " ) \
ACTION( REQ_DELETE, "delete " ) \
ACTION( REQ_CAS, "cas " ) \
ACTION( REQ_SET, "set " ) \
ACTION( REQ_ADD, "add " ) \
ACTION( REQ_REPLACE, "replace " ) \
ACTION( REQ_APPEND, "append " ) \
@begeekmyfriend
begeekmyfriend / dep_sort.lua
Last active May 1, 2017 14:48
Module Dependence Regitster Sequence
--[[
Date: 2014-8-1
Licence: MIT
Author: <begeekmyfriend@gmail.com>
<xfguo@credosemi.com>
]]
--[[
module_relation table
key -- module name
@begeekmyfriend
begeekmyfriend / binary_search.c
Created March 2, 2014 03:43
Only less than 10% programmers all over the world can get it right.
int binary_search_first_position(int *A, int n, int target)
{
int low = -1, high = n;
assert(A != NULL && n >= 0);
while (low + 1 < high)
{
int mid = (low + high) >> 1;
if (A[mid] < target)
low = mid;
else