Skip to content

Instantly share code, notes, and snippets.

#include <QRubberBand>
class RubberBand : public QRubberBand
{
Q_OBJECT
public:
RubberBand(QWidget *parent = 0, QColor c = QColor("red"), Shape s = QRubberBand::Rectangle);
void paintEvent(QPaintEvent *);
private:
QColor color;
};
@Temptationx
Temptationx / UTF8ToUTF16.cpp
Last active August 29, 2015 14:08
utf-8, gbk, utf-16 转换
wstring UTF8ToUTF16(const char *strUTF8)
{
int len = MultiByteToWideChar(CP_UTF8, 0, strUTF8, -1, NULL, 0);
wchar_t* wszGBK = new wchar_t[len + 1];
memset(wszGBK, 0, len * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, strUTF8, -1, wszGBK, len);
wstring ret(wszGBK);
if (wszGBK) {
delete[] wszGBK;
}
@Temptationx
Temptationx / match.cpp
Created February 9, 2015 21:19
opencv match template
void match(Mat &a, Mat &b)
{
Mat r;
matchTemplate(a, b, r, CV_TM_SQDIFF_NORMED);
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc(r, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
@Temptationx
Temptationx / socket_client.c++
Created February 9, 2015 21:22
socket_client
void main()
{
WSADATA wsaData;
auto success = WSAStartup(MAKEWORD(2, 2), &wsaData);
// ERROR_CHECK
SOCKET m_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// ERROR_CHECK
sockaddr_in addr = { 0 };
addr.sin_addr.S_un.S_addr = inet_addr("192.168.1.118");
addr.sin_family = AF_INET;
@Temptationx
Temptationx / channel_mixer.c++
Created February 9, 2015 21:27
channel_mixer
struct ChannelMixerParameter
{
int output_channel;
double r;
double g;
double b;
};
void channel_mixer(const cv::Mat &src, cv::Mat &m, const ChannelMixerParameter &param)
{
@Temptationx
Temptationx / gist:7170016
Last active December 26, 2015 14:59
dlopen, dlsym
#include <stdio.h>
#include <dlfcn.h>
void ppp()
{
}
int main(int argc, const char * argv[])
{
// For UUID
#include <Rpc.h>
#pragma comment(lib, "Rpcrt4.lib")
int _tmain(int argc, _TCHAR* argv[])
{
// Create a new uuid
UUID uuid;
RPC_STATUS ret_val = ::UuidCreate(&uuid);
class viewWeb;
class view{
public:
virtual ~view() {}
static view* creat();
protected:
view() { }
};
class viewWeb : public view{
public:
@Temptationx
Temptationx / remove border.c
Last active January 1, 2016 04:19
remove window border win32api
LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
SetWindowLong(hwnd, GWL_STYLE, lStyle);
LONG lExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle);
SetWindowPos(hwnd, NULL, 0,0,0,0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
import zlib
from glob import glob
def zipstreams(filename):
"""Return all zip streams and their positions in file."""
with open(filename, 'rb') as fh:
data = fh.read()
i = 0
while i < len(data):
try: