Skip to content

Instantly share code, notes, and snippets.

@hoterran
hoterran / ftruncate_bigfile.c
Last active August 29, 2015 14:19
ftruncate a big file
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
// Purpose: ftruncate big file
//
// argv[1] file
// argv[2] shrinked size each loop, default is 100m
@hoterran
hoterran / mysql_store_use_result_stmt_cursor.c
Created August 28, 2013 13:14
mysql api example, include store_result, use_result, stmt, server cursor , fetch row setting
#include <stdio.h>
#include <mysql.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char *argv[]) {
MYSQL *mysql;
MYSQL_RES *result;
●PHP中出现的字符串Hash函数
static unsigned long hashpjw(char *arKey, unsigned int nKeyLength)
{
unsigned long h = 0, g;
char *arEnd=arKey+nKeyLength;
while (arKey < arEnd) {
h = (h << 4) + *arKey++;
if ((g = (h & 0xF0000000))) {
@hoterran
hoterran / gist:4296761
Created December 15, 2012 16:16
ngrep help
-i ignore case of regex
-w match regex
-q don't output any information other than packet headers and payloads
-e show empty packets
-v invert the match
-x hex as well as ASCII
-l stdout line buffered
-s snaplen
set caplen,default 65536