Skip to content

Instantly share code, notes, and snippets.

View yuikns's full-sized avatar
🎯
Focusing

Yu yuikns

🎯
Focusing
View GitHub Profile
package util;
import java.util.ArrayList;
import java.util.List;
public abstract class MinHeap<T> {
private int sizeLimit;
private int size;
private List<T> heap;
@yuikns
yuikns / rsync_back.sh
Last active August 29, 2015 13:56
backup & rsync a remote project
#!/bin/sh
DIR_LIST=`cat filelist`
EXC_PATTERN=`cat exclude`
tar -czvf .bak.src.`date "+%Y%m%d%H%M%S"`.tar.gz $DIR_LIST
rsync -avh --progress --exclude=$EXC_PATTERN hang@10.1.1.111:xdatacenter_load/ proj/
@yuikns
yuikns / WindowsLockAndWriteFile.c
Last active August 29, 2015 13:57
windows , lock a file
#include <stdio.h>
#include <windows.h>
int main()
{
//获取进程ID,因为你希望是多个进程运行同时写一个文件,所以,我们打印出进程ID
DWORD dwProcessID = GetCurrentProcessId();
//初始化我们要写入文件中的内容,及该内容长度;
//为了让每次写入内容变化,此处只声明,需要时候再写。
@yuikns
yuikns / gc.cc
Created March 23, 2014 12:14
a test of gc
#include <cstdio>
class MyClass
{
public :
MyClass()
{
printf("my class inited\n");
}
~MyClass()
@yuikns
yuikns / file_manager.c
Created March 23, 2014 13:02
file manager
#include <stdio.h>
#include <stdlib.h> // for system xxx
#include <string.h>
#include <sys/stat.h> // for int mkdir(const char *path, mode_t mode);
#define MATCH(a,b) (strcmp(a,b) == 0)
void fdel(const char * name);
void fadd(const char * name);
@yuikns
yuikns / MappingDict.cc
Last active August 29, 2015 13:57
MappingDict
/**
* MappingDict.cc
*
* Created on: May 28, 2013
* Author: zhangjing0544
*/
#include "MappingDict.h"
int MappingDict::GetId(const string& key)
package com.argcv.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class CSVParser {
final static int defaultMaxWidth = 20;
void file_copy(const char * dest, const char* src)
{
FILE * fsrc = fopen(src,"rb");
FILE * fdest = fopen(dest,"wb");
fseek(fsrc,0L,SEEK_END);
long sz = ftell(fsrc);
rewind(fsrc);
unsigned char * buff = (unsigned char *)malloc(sizeof(unsigned char) * sz);
fread(buff,sz,sizeof(unsigned char),fsrc);
fwrite(buff,sz,sizeof(unsigned char),fdest);
@yuikns
yuikns / hash_key_generator.c
Created April 7, 2014 09:16
generate hash key from a string , should init first
#include <string.h>
#include <stdio.h>
static unsigned long crypt[0x500];
void crypt_init();
#define PRIME_SIZE 32
static const unsigned long prime_list[PRIME_SIZE] =
{
0ul, 3ul, 11ul, 23ul, 53ul,
@yuikns
yuikns / MersenneTwister.h
Last active August 29, 2015 13:58
Mersenne Twister random number generator -- a C++ class MTRand
// MersenneTwister.h
// Mersenne Twister random number generator -- a C++ class MTRand
// Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
// Richard J. Wagner v1.1 28 September 2009 wagnerr@umich.edu
// The Mersenne Twister is an algorithm for generating random numbers. It
// was designed with consideration of the flaws in various other generators.
// The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
// are far greater. The generator is also fast; it avoids multiplication and
// division, and it benefits from caches and pipelines. For more information