Blog

This section contains notes to myself that I hoped would help others.

Anyway, Forgive the formatting please :)

(续)Function static变量引发的血案

Function static variable的后续研究和例程

July 27, 2020

Function static变量引发的血案

函数静态变量引发的奇怪crash

July 25, 2020
July 18, 2020

Software Engineering checklist

a check list for a software project

January 29, 2015

What's the strategy when setup live-update of a product?

learned from previous projects how to plan a product’s live-update feature at beginning

December 11, 2014

[ZT] 中年男人的掩耳盗铃

中年男人的掩耳盗铃

August 4, 2020
January 3, 2020
January 3, 2020

How to compare version string in a better way from shell command line

In shell command, compare version string in a better way

November 5, 2019

Draw anti-alias circle at give point with specified radius using OpenGL Core profile

In modern opengl (core profile), there are a lot of tutorials on how to draw a circle using fragment shader,but most of lack of source code and only show how to draw at (0,0).This code piece draw circle at given center point with specified radius.pyopengl implementation is at github: https://github.com/stonewell/code-snippets/tree/master/opengl%5Fcircle

April 18, 2017

Draw thick lines in opengl core profile

Modern opengl (core profile), the line width is limited by system.In order to draw a free width line smooth, we draw multiple triangles to construct a thick line.pyopengl implmentation is at github:https://github.com/stonewell/code-snippets/tree/master/opengl%5Fthick%5Fline

April 18, 2017

Calculate div and mod result between 2 uint64_t values without directly using / and % operator

calculate div and mod result between 2 uint64_t values without directly using / and % operator

March 12, 2017

Simplified Wrapper and Interface Generator

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of target languages including common scripting languages such as Javascript, Perl, PHP, Python, Tcl and Ruby. The list of supported languages also includes non-scripting languages such as C#, Common Lisp (CLISP, Allegro CL, CFFI, UFFI), D, Go language, Java including Android, Lua, Modula-3, OCAML, Octave, Scilab and R.

November 4, 2016

Text Redering with OpenGL

Rendering 2d text with opengl, either using bitmap font or freetype library

November 4, 2016

Some interesting blog about security needs to be checkout

http://www.darkreading.com/ http://securityweekly.com/ http://www.technewsworld.com/perl/section/tech-security/ http://ddosattackprotection.org/blog/cyber-security-blogs/ https://heimdalsecurity.com/blog/best-internet-security-blogs/ http://www.rasmussen.edu/degrees/technology/blog/top-cyber-security-blogs/ http://www.veracode.com/blog/2012/02/top-20-security-blogs http://www.marblesecurity.com/2014/01/22/top-10-security-blogs/

March 4, 2016

Build your own render farm

To Build your own render farmRender Manager: http://cgru.info/homeA blog page talking about how to built your own Render Farm: http://arstechnica.com/information-technology/2014/05/how-to-network-lots-of-dumb-computing-muscle-in-a-fast-efficient-render-farm/1/a maya script for v-ray http://www.creativecrash.com/maya/script/v-ray-tuner-for-maya

February 4, 2016

[ZT] 拜服吧,关于唐诗的那些猛人猛事

关于唐诗的那些猛人猛事

January 4, 2016

How (and Why) to Assign the .local Domain to Your Raspberry Pi

Original URL:How (and Why) to Assign the .local Domain to Your Raspberry Pi

December 11, 2015

How the wifi adapter or automatically wifi configuration for device works?

It is very interesting technology. Basically the device to be configured put the wifi device in “monitoring” mode,and the app will send udp wifi packet with different length, which different length indicate different “character”.http://depletionregion.blogspot.ch/2013/10/cc3000-smart-config-transmitting-ssid.htmlhttp://electronics.stackexchange.com/questions/61704/how-does-ti-cc3000-wifi-smart-config-work

November 4, 2015

How to protect your cloud storage files with EncFS

Original Post URL:https://www.bestvpn.com/blog/11385/protect-cloud-storage-files-encfs/

October 13, 2015

Virus Bulletin : Dylib hijacking on OS X

Original Post URL:https://www.virusbtn.com/virusbulletin/archive/2015/03/vb201503-dylib-hijacking

September 22, 2015

Introducing RancherVM: Package and Run Virtual Machines as Docker Containers | Rancher Labs

http://rancher.com/introducing-ranchervm-package-and-run-virtual-machines-as-docker-containers/

August 20, 2015

C++ Code Snippet - Print Stack Backtrace Programmatically with Demangled Function Names

Original Post URL:https://panthema.net/2008/0901-stacktrace-demangled/ // stacktrace.h (c) 2008, Timo Bingmann from http://idlebox.net/ // published under the WTFPL v2.0 #ifndef _STACKTRACE_H_ #define _STACKTRACE_H_ #include <stdio.h>#include <stdlib.h>#include <execinfo.h>#include <cxxabi.h> /** Print a demangled stack backtrace of the caller function to FILE* out. */ static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63) { fprintf(out, "stack trace:\n"); // storage array for stack trace address data void* addrlist[max_frames+1]; // retrieve current stack addresses int addrlen = backtrace(addrlist, sizeof(addrlist) / sizeof(void*)); if (addrlen == 0) { fprintf(out, " <empty, possibly corrupt>\n"); return; } // resolve addresses into strings containing "filename(function+address)", // this array must be free()-ed char** symbollist = backtrace_symbols(addrlist, addrlen); // allocate string which will be filled with the demangled function name size_t funcnamesize = 256; char* funcname = (char*)malloc(funcnamesize); // iterate over the returned symbol lines.

August 11, 2015

How dynamic linking working on iOS8 or newer platform

The iOS8 or newer platform now supports dynamic library, here is a link details about the dynamic linking. http://ddeville.me/2014/04/dynamic-linking/

August 4, 2015

Client Certificate Authentication With Apache

Original Post URL:http://www.impetus.us/~rjmooney/projects/misc/clientcertauth.html

January 28, 2015

How to produce portable executable/dynamic library

When create executable or dynamic library, sometimes they need to depends on third-party shared library, so how system find the third-party shared library and how can you make sure the system find the right version of library instead of some library in same name? Solution could be pack the correct third-party library with your executable or library, but how to let system find the packed library? most platform has search directory list to find dependent libraries, even you put the third-party library in the same directory, the system still could find wrong one.

January 3, 2015

Useful resources when create thunderbird/firefox extension

jar.mn document http://dxr.mozilla.org/mozilla-central/source/build/docs/jar-manifests.rst https://developer.mozilla.org/en-US/docs/HowMozilla'sbuildsystemworks https://developer.mozilla.org/en-US/docs/UsingDependentLibrariesInExtension%5FComponents https://developer.mozilla.org/en-US/docs/Bundlingmultiplebinary%5Fcomponents https://code.google.com/p/gears/source/browse/trunk/gears/base/firefox/static%5Ffiles/components/stub.js https://developer.mozilla.org/en-US/Add-ons/CreatingCustomFirefoxExtensionswiththeMozillaBuildSystem https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Guide/Cross-threadcallsusing%5Frunnables

January 1, 2015

Dynamic_cast RTTI and class size

dynamic_cast requires RTTI flag when do compiling, the RTTI will increase object size. and RTTI only generate for polymorphic classes. class A { public: std::string m_Data; } although A class is not polymorphic, but the m_Data is a instance of polymorphic class, the sizeof(A) will change when compile with/without RTTI. programmer should be very carefully when link with third-party library, it is more difficult to find out the crash compare to pack problem.

December 25, 2014

How to create auto increment build numbers using Ant

To create auto increment build number without third-party component, script or other code, just pure ant tasks. please refer to http://stackoverflow.com/questions/1431315/build-numbers-major-minor-revision

November 1, 2014

In java when using SSL may have error: Invalid session

The error message looks like Error occurred during the SSL handshake: invalid SSL session It may caused by JVM needs the JCE, download JCE from Oracle and follow instructions in README http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html

October 29, 2014

Use -noverify to avoid PowerMock fail

When using PowerMock https://code.google.com/p/powermock/ to do unit test, some times jvm may report bytecode version mismatch and refuse to run, it caused by PowerMock will dynamic change the bytecode. Add -noverify option to fix the problem

October 29, 2014

重温一下const char *和char * const

今天写代码的时候突然不能肯定const char * d; d++; 是不是对的了,就重温了一下经典的c++定义结论: char * const p 定义一个指向字符的指针常数,即const指针 const char * p 定义一个指向字符常数的指针 char const*p 等同于const char* p 普通的指针d,进行d++肯定没问题了http://blog.163.com/pei%5Fhua100/blog/static/805697592009550281616/

September 2, 2014

How to convert OpenSSH key to GnuPG

First we need to create a certificate (self-signed) for our ssh key:openssl req -new -x509 -key ~/.ssh/id_rsa -out ssh-cert.pem We can now import it in GnuPG openssl pkcs12 -export -in ssh-certs.pem -inkey ~/.ssh/id_rsa -out ssh-key.p12 gpgsm --import ssh-key.p12 Notice you cannot import/export DSA ssh keys to/from GnuPG The more key conversions, please refer tohttp://www.sysmic.org/dotclear/index.php?post/2010/03/24/Convert-keys-betweens-GnuPG,-OpenSsh-and-OpenSSL

December 9, 2013

Fast Hex String decode/encode by table look up

Decode a hex string by using look up table char m_table['f' + 1]['f' + 1] = {0}; void initDecodeTable() { const char * hexValue = "0123456789abcdefABCDEF"; int len = strlen(hexValue); for(int i=0;i < len;i++) { for(int j=0;j int v; char tmp[2] = { tolower(hexValue[i]), tolower(hexValue[j]) }; sscanf(tmp, "%x", &v); m_table[hexValue[i]][hexValue[j]] = (v & 0xFF); } } } void decodeHex(const char * pIn, int inLen, char * pOut, int & outLen) { outLen = inLen / 2; for(int i=0; i < outLen;i++) { pOut[i] = m_table[pIn[i * 2]][pIn[i * 2 + 1]]; } if (inLen % 2 !

December 9, 2013

screen 和 reptyr 远程工作的利器

在unix,maxosx或者linux下工作的时候,经常需要长时间运行一个程序,通常会把程序放到后台,然后通过日志来监控。如果使用screen的话,可以让程序保持前台运行,又能通过detach放到后台。如果在公司机器上用screen运行一个程序,然后detach,回家后通过ssh连接公司机器,用screen restore就可以继续观察程序运行了。可是如果一开始没有用screen运行,直接放置到后台怎么办呢。reptyr就派上用场了,以下是reptyr的说明 reparent a orphan background process, means background a process in a terminal and bring it back to foreground to another terminal reptyr - A tool for "re-ptying" programs. ----------------------------------------- reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, but have to leave and don't want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home.

May 10, 2013

命令行ssh桥接

通过一些ssh的客户端,可以很方便的做ssh forward,也就是通过一台主机上ssh连接到另一台主机,那么命令行可不可以呢?只要在~/.ssh/config中加入如下指令即可host serverB.example.com serverB ProxyCommand ssh -W %h:%p gateway serverB是最终的目的主机,gateway是中间转发的主机,gateway上需要配置无密码登录。或者暴力一点ssh -t usergateway@gateway ssh user1@serverb

May 10, 2013
Nifty tech tag lists from Wouter Beeftink