Time of Update: 2018-12-04
一個簡單的OpenGL程式 cheungmine2009-2 這是一個Windows控制台程式,建立一個空項目,把下面的檔案添加進去,編譯即可。需要更改的是路徑“../../???”。 依存的庫目錄+--- win_opengl32/ | +--- inc/ | |--- GL.h,GLU.h,GLUT.h | +--- lib/ | |---
Time of Update: 2018-12-04
Webgis 列印實現技術細節——兼論如何?預覽列印褫其華袞,示人本相系列之三 cheungmine 在我的上一篇文章《Webgis
Time of Update: 2018-12-04
結合前面的例子,來寫一個條件運算式。如果第一個參數沒有,則輸出no parameter,否則輸出第一個參數。#!/bin/bashif [ -n "$1" ]then echo "1st parameter: $1"else echo "no parameter"fi輸入帶參數命令:$ ./test.sh 'this is a test'1st parameter: this is a test輸入無參數命令:$ ./test.shno parameter先解釋一下條件陳述式:if
Time of Update: 2018-12-04
方法很簡單,用update-alternatives命令 update-alternatives --config editorThere are 5 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status-----------------------------------------------------------
Time of Update: 2018-12-04
WinCE 介面開發:使用HTML Viewer Controlby cheungmine 2010-1在Win32平台上用 C++做介面開發確實是很吃力的活。無論使用MFC還是ATL或者WTL都是很痛苦的。通常引入HTML控制項,可以做出類似網頁效果的精美布局。在傳統的Windows應用程式中使用Web控制項已是大勢所趨,大大簡化工作量。但是在WinCE平台上,做同樣的事情,往往遇到很多困難。我自己摸索了半天,總結出下面的方法,效果還是很好的。首先,使用WTL(WTL8.0 with VS20
Time of Update: 2018-12-04
用emacs編輯nginx, 一不小心格式化就會把nginx的設定檔弄得一團糟。藉助nginx.model吧。首先下載https://raw.github.com/ajc/nginx-mode/master/nginx-mode.el讓後放在某個目錄下之後編輯.emacs檔案,添加幾行:(add-to-list 'load-path (expand-file-name "/opt/emacs_plugins/nginx/")) (require 'nginx-mode)然後重新啟動Nginx,
Time of Update: 2018-12-04
WINAPI 編程擷取檔案版本資訊cheungmine本文示範如何使用win32 api 編寫獲得檔案描述和產品版本。很簡單的小程式。下面就是全部代碼:test.c//// test.c// by cheungmine//#include <windows.h>#include <stdio.h>#define DLLFILE "C://WINDOWS//system32//aaaamon.dll"//// 使用 WIN32 API
Time of Update: 2018-12-04
因為也懂點LISP,會很多語言。本文的分析相當精彩,忍不住要轉載。具體全文參考:http://www.cnblogs.com/weidagang2046/archive/2012/06/03/tao_of_lisp.html下面是精彩摘要:Lisp的柔性與S運算式有著密切的關係。Lisp並不限制你用S運算式來表達什麼語義,同樣的S運算式文法可以表達各種不同領域的語義,這就是文法和語義解耦。如果說普通語言的剛性源於“文法和語義緊耦合”,那麼Lisp的柔性正是源於“文法和語義解耦”!“文法和語義解耦
Time of Update: 2018-12-04
BSTR 轉換到 UTF static int BSTR2UTF8(BSTR bstrIn, char **pszOut){ int cbSize = WideCharToMultiByte(CP_UTF8, 0, bstrIn, SysStringLen(bstrIn)+1, 0, 0, 0, 0); *pszOut = (char*) malloc(cbSize); assert(*pszOut); return
Time of Update: 2018-12-04
reference_wrapper模板:(ref.hpp檔案中)template<class T> class reference_wrapper{ public: typedef T type;#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) explicit reference_wrapper(T& t): t_(&t) {}#else
Time of Update: 2018-12-04
先看一下boost::visit_each模板,定義在visit_each.hpp檔案中namespace boost { template<typename Visitor, typename T> inline void visit_each(Visitor& visitor, const T& t, long) { visitor(t); } template<typename Visitor, typename T>
Time of Update: 2018-12-04
16位色和24位色轉換宏 #include <assert.h>typedef unsigned long DWORD;typedef unsigned char BYTE;typedef unsigned short WORD;// 24位色和16位色轉換宏// by cheungmine#define RGB888toRGB565(r,g,b) ((WORD)(((WORD(r)<<8)&0xF800)|((WORD(g)&
Time of Update: 2018-12-04
這裡看一下is_placehoder模板在is_placeholder.hpp中,有如下定義:namespace boost{template< class T > struct is_placeholder{ enum _vt { value = 0 };};} 在arg.hpp中,還有幾個偏特化版本的定義:#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )template< int I >
Time of Update: 2018-12-04
* 檔案操作 * 查看目錄檔案 * $ hadoop dfs -ls /user/cl * * 建立檔案目錄 * $ hadoop dfs -mkdir /user/cl/temp * * 刪除檔案 * $ hadoop dfs -rm /user/cl/temp/a.txt * * 刪除目錄與目錄下所有檔案 * $ hadoop dfs -rmr /user/cl/temp * * 上傳檔案 * 上傳一個本機/home/cl/local.txt到hdfs中/user/cl/temp目錄下 *
Time of Update: 2018-12-04
現在看一下storageN模板,定義在storage.hpp檔案中:先來個普通的:namespace _bi{// 1template<class A1> struct storage1{ explicit storage1( A1 a1 ): a1_( a1 ) {} template<class V> void accept(V & v) const { BOOST_BIND_VISIT_EACH(v, a1_, 0);
Time of Update: 2018-12-04
bind_t模板定義在bind.hpp中:#ifndef BOOST_NO_VOID_RETURNStemplate<class R, class F, class L> class bind_t{public: typedef bind_t this_type; bind_t(F f, L const & l): f_(f), l_(l) {}#define BOOST_BIND_RETURN return#include
Time of Update: 2018-12-04
終於到了最後一篇(至少目前我認為是最後一篇) vector<int>::iterator itor = std::find_if(v.begin(), v.end(), boost::bind(Foo, _1));上面的代碼find_if的第三個參數是bind的傳回值,看一下bind定義:template<class R, class F, class A1> _bi::bind_t<R, F, typename _bi::list_av_
Time of Update: 2018-12-04
如何傳遞引用<<Effective STL>>提到可以讓function object繼承自unary_function<T, void>,現在來試一下.class B : public unary_function<int,void>{public: B():x_(0){ } void operator()(int x){ cout<<++x_<<endl; } int x()
Time of Update: 2018-12-04
支援傳回型別目前的function_object_ref版本只能支援void傳回型別。我希望能夠讓它支援多種傳回型別,最簡單的方法是添加一個模板參數。請看下面的代碼:template<typename function_object_type,typename element_type,typename return_type>class function_object_ref{public: explicit
Time of Update: 2018-12-04
首先看一下bind.hpp中的list0模板定義:class list0{public: list0() {} template<class T> T & operator[] (_bi::value<T> & v) const { return v.get(); } template<class T> T const & operator[] (_bi::value<T> const & v)