Skip to content

Instantly share code, notes, and snippets.

View kyle-go's full-sized avatar
🌴
On vacation

Kyle kyle-go

🌴
On vacation
View GitHub Profile
@kyle-go
kyle-go / encrypt.cpp
Last active December 14, 2015 00:59
simple encrypt
/*!
simple encrypt
*/
#include <string>
#include <assert.h>
std::string encrypt(const std::string &src, bool encrypt)
{
assert(!src.empty());
std::string ret;
@kyle-go
kyle-go / Jgg2.cpp
Last active December 14, 2015 00:59
jgg2 encrypt
/*!
jgg encrypt
*/
#include <string>
#include <assert.h>
#define JGG_CONST_STRING " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
//#define CONST_STRING " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\r\n\t"
#define JGG_SIZE (sizeof(JGG_CONST_STRING)-1)
/*!
dispatch message.
copy from https://github.com/chenshuo/recipes/blob/master/protobuf/dispatcher.cc
*/
#include <map>
#include <assert.h>
#include <iostream>
#include <functional>
class Message
@kyle-go
kyle-go / Jgg.cpp
Last active December 14, 2015 01:09
jgg encrypt
#include "Jgg.h"
#define REAL_SHIFT(i) (i%8+1)
#define KEY_BYTE 0xE9
JGG_KEY jggSetup(unsigned char *key, int len)
{
JGG_KEY jk;
int i=0, j=0, k=0;
@kyle-go
kyle-go / thread.cpp
Last active December 14, 2015 02:29
sth about windows thread
#include "thread.h"
#include <memory>
int main()
{
struct UR_STRUCT
{
int a;
//...
};
@kyle-go
kyle-go / scopeGuard.h
Last active December 14, 2015 04:48
scope guard
#ifndef SCLOUD_SCOPE_GUARD_H_
#define SCLOUD_SCOPE_GUARD_H_
#include <functional>
namespace scloud{
class ScopeGuard
{
public:
explicit ScopeGuard(std::function<void(void)> onExitScope)
@kyle-go
kyle-go / C++ mvc.h
Last active December 15, 2015 11:29
c++ mvc model.... compile with vs2008
#ifndef MVC_H_
#define MVC_H_
#include <set>
#include <list>
#include <memory>
#include <functional>
template <typename T>
class observer
{
@kyle-go
kyle-go / c++ mvc.h
Last active December 15, 2015 11:49
c++ mvc.h v2 complie with vs2010
#ifndef MVC_H_
#define MVC_H_
#include <set>
#include <memory>
#include <functional>
template <typename T>
class observer
{
public:
#include "httpdownload.h"
#include <windows.h>
#include <wininet.h>
#include <shlwapi.h>
#include <tchar.h>
#include "scope.h"
#pragma comment(lib, "wininet")
#pragma comment(lib, "shlwapi")
@kyle-go
kyle-go / curl_httpdownload.cpp
Last active December 17, 2015 01:59
curl-httpdownload...
#include "curl_httpdownload.h"
#include <stdlib.h>
#include <sys/stat.h>
#include <curl/curl.h>
#include "scope.h"
#ifdef _DEBUG
#pragma comment(lib, "libcurl-d.lib")
#else
#pragma comment(lib, "libcurl.lib")