Skip to content

Instantly share code, notes, and snippets.

@chchwy
chchwy / Batch_rename.py
Last active August 31, 2016 01:18
Python 批次修改檔名
import os
for filename in os.listdir('.'):
new_filename = filename.replace("OldStr", "NewStr")
os.rename(filename, new_filename)
print("{0} => {1}\n".format(filename, new_filename))
@chchwy
chchwy / Qmake.md
Last active December 19, 2015 00:29
Qmake使用筆記

設定Lib

LIBS += -Lfolderpath -lmylib

  • 大寫L是指lib的搜尋路徑 小寫l是指實際需要參考的lib檔名
  • 在Windows下lib檔通常取名為mylib.lib
  • 在OS X則是取名為libmylib.a
@chchwy
chchwy / QActions.cpp
Created June 27, 2013 13:56
Qt: Iterate all QActions
QList<QAction*> actionList = findChildren<QAction*>();
foreach ( QAction* action, actionList )
{
qDebug() << "Action: " << action->text()
<< "Shortcuts:" << action->shortcut().toString();
}
@chchwy
chchwy / stody.md
Last active August 31, 2016 01:32

在紐約, 有一名男子被控在雙層巴士上打了一個女人, 法官正在盤問他是不是有什麼理由。 這名男子解釋說:「噢,法官大人,事情是這樣的。 她上了巴士後,坐在下層,我旁邊的位子。 然後她打開袋子,取出皮包,閤上袋子,打開皮包, 拿出一塊錢,關上皮包,打開袋子,把皮包放進去, 然後再閤上袋子。然後,她看見車掌正要到上層去, 她就打開袋子,取出皮包,閤上袋子,打開皮包, 將一塊錢放進去,關上皮包,打開袋子, 把皮包放進去,然後再閤上袋子。」 法官大聲喝斥:「別說了!你快要把我搞瘋了!」 那男子說:「沒錯!那就是我的感覺!」

@chchwy
chchwy / PCMan.md
Last active August 31, 2016 01:33
PCMan 演講逐字稿

我先問在場大家一個小小的問題。可以嗎? 如果你知道有一個人他拿一個大家常在用的軟體來當作己網路ID。 比如說把自己叫 Photoshop`把自己叫Windows 或是把自己叫Angry Bird。 你會不會覺得他很宅?

一定會對不對? 可是這個軟體是他寫的呢?

大家好我是PCMan。 就是裝在你電腦你桌面上那個可以上BBS的電腦軟體PCMan。

{{ post.content | split:"<!-- more -->" | first }}
import math # Imports the math module
everything = dir(math) # Sets everything to a list of things from math
print everything # Prints 'em all!
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
Ogre::Item *item = sceneManager->createItem("Sphere1000.mesh",
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::SCENE_DYNAMIC );
Ogre::SceneNode* rootNode = sceneManager->getRootSceneNode( Ogre::SCENE_DYNAMIC )->createChildSceneNode( Ogre::SCENE_DYNAMIC );
rootNode->attachObject( item );
auto& meshMgrV1 = Ogre::v1::MeshManager::getSingleton();
Ogre::v1::MeshPtr planeMeshV1 = meshMgrV1.createPlane( "Plane v1",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::Plane( Ogre::Vector3::UNIT_Y, 1.0f ), 500.0f, 500.0f,
1, 1, true, 1, 4.0f, 4.0f, Ogre::Vector3::UNIT_Z,
Ogre::v1::HardwareBuffer::HBU_STATIC,
Ogre::v1::HardwareBuffer::HBU_STATIC );
Ogre::MeshPtr planeMesh = Ogre::MeshManager::getSingleton().createManual("Plane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );