Skip to content

Instantly share code, notes, and snippets.

View pezy's full-sized avatar
💭
I may be slow to respond.

pezy pezy

💭
I may be slow to respond.
  • Beijing, China
View GitHub Profile
@pezy
pezy / PathFileExists.cpp
Created September 17, 2013 09:09
PathFileExists
#include <windows.h>
#include <iostream>
#include "Shlwapi.h"
#pragma comment(lib, "Shlwapi.lib")
using namespace std;
int main(void)
{
@pezy
pezy / conversion.cpp
Last active July 2, 2024 09:56
Encoding Conversion In C++
// Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring &wstr)
{
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo(size_needed, 0);
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
@pezy
pezy / month_isnot_digit.cpp
Last active August 29, 2015 13:57
many date&time format function(use sscanf)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int map_month_name(char const *mmm)
{
static char const *months[] =
{
"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
};
public class IcoSphereCreator
{
private struct TriangleIndices
{
public int v1;
public int v2;
public int v3;
public TriangleIndices(int v1, int v2, int v3)
{
@pezy
pezy / sphere.cpp
Created June 3, 2014 11:36
use OSG draw sphere
#include <osgViewer/Viewer>
#include <iostream>
#include <cmath>
#include <osg/Group>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/PositionAttitudeTransform>
#include <osg/PolygonMode>
@pezy
pezy / 2.cpp
Created June 12, 2014 06:48
脑子犯二,今天被同事耻笑了。
#include <iostream>
class Father
{
public:
Father():i_(2){}
~Father(){}
int GetIValue(){return i_;}
void SetIValue(int i){i_ = i;}
#include <stdio.h>
#include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
QSettings settings("test.ini", QSettings::IniFormat);
settings.beginGroup("players");
const QStringList childKeys = settings.childKeys();
foreach (const QString &childKey, childKeys)
qDebug() << settings.value(childKey);
settings.endGroup();
class CameraUpdateCallback : public osg::NodeCallback {
private:
osg::ref_ptr<osg::Camera> mOtherCam;
public:
CameraUpdateCallback(osg::Camera* otherCam) : mOtherCam(otherCam) { }
osg::ref_ptr<osg::Camera> m_sourceCamera;
void operator()(osg::Node* node, osg::NodeVisitor* nv) {
osg::Camera* cam = static_cast<osg::Camera*>( node );
@pezy
pezy / ex11_32.cpp
Created August 28, 2014 13:05
C++ Primer 5th Ex 11.32的手痒一试
///
///@Author pezy
///@Date Aug, 2014
///@See http://www.douban.com/group/topic/61226023/
///Exercise 11.32:
///Using the multimap from the previous exercise, write a program to
///print the list of authors and their works alphabetically.
///
#include <iostream>