Skip to content

Instantly share code, notes, and snippets.

@z4none
z4none / tray.cpp
Created May 27, 2017 09:10
win32 trayicon
#ifndef _TRAYICON_H_
#define _TRAYICON_H_
// 简单的支持气泡的 trayicon
// z4none@gmail.com
#include <ShellAPI.h>
#define WM_TRAYICON_NOTIFY (WM_USER + 8964)
@z4none
z4none / SharedMemorySample_read_main.cpp
Created November 14, 2017 04:07 — forked from yoggy/SharedMemorySample_read_main.cpp
SharedMemory Sample for WIN32
#include <SDKDDKVer.h>
#include <Windows.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int shmem_size = 16; // 16byte
HANDLE shmem = INVALID_HANDLE_VALUE;
HANDLE mutex = INVALID_HANDLE_VALUE;
@z4none
z4none / pagination.html
Created March 22, 2018 08:15
django bootstrap3 pagination
<ul class="pagination">
{% if page_obj.has_previous %}
<li>
<a href="?page={{ page_obj.previous_page_number }}">
{% else %}
<li class="disabled">
<a href="#">
{% endif %}
<span>&laquo;</span>
</a>
int width = m_view_size.width();
int height = m_view_size.height();
uint8_t * data = new uint8_t[width * height * 4];
m_gles2->ReadPixels(m_context->pp_resource(), 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
cv::Mat rgbFrame, outputFrame;
cv::Mat glFrame = cv::Mat(height, width, CV_8UC4, data);
cv::cvtColor(glFrame, rgbFrame, CV_BGRA2RGB);
cv::flip(rgbFrame, outputFrame, 0);
@z4none
z4none / microtime.c
Created June 11, 2019 14:41
Get the current time in microseconds in C.
#include <sys/time.h>
/**
* Returns the current time in microseconds.
*/
long getMicrotime(){
struct timeval currentTime;
gettimeofday(&currentTime, NULL);
return currentTime.tv_sec * (int)1e6 + currentTime.tv_usec;
}
@z4none
z4none / auth.py
Created September 4, 2019 02:22
django rest framework token
import datetime
from django.conf import settings
from rest_framework.authentication import TokenAuthentication
from rest_framework import exceptions
from django.utils.translation import ugettext_lazy as _
from django.core.cache import cache
EXPIRE_MINUTES = getattr(settings, 'REST_FRAMEWORK_TOKEN_EXPIRE_MINUTES', 1)
@z4none
z4none / .npmrc
Created September 4, 2019 14:41
speedup npm install in china
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org
@z4none
z4none / main.cpp
Created January 6, 2020 08:11
MFC enable dialog controls
void EnableDlgItem (CWnd *dlg, int items[], BOOL bEnable)
{
int i = 0, item ;
while ((item = items[i++]) != 0)
{
CWnd *pControl = dlg->GetDlgItem(item) ;
if (pControl != NULL)
pControl->EnableWindow(bEnable) ;
}
@z4none
z4none / main.cpp
Created January 6, 2020 15:28
MFC conversion
USES_CONVERSION;
A2CT(str);
CT2A(str);
@z4none
z4none / ifregex.py
Created March 28, 2020 07:01
django if regex tag
class IfRegexNode(Node):
def __init__(self, var1, var2, nodelist_true, nodelist_false, negate):
self.var1, self.var2 = Variable(var1), Variable(var2)
self.nodelist_true, self.nodelist_false = nodelist_true, nodelist_false
self.negate = negate
def __repr__(self):
return "<IfRegexNode>"
def render(self, context):