Friday, 10 July 2015

Run as administrator Windows from command line

You can do it with the followings:

"runas.exe /savecred /user:administrator cmd"

Sunday, 21 June 2015

CMake and HLSL Shader Compilation

This post demonstrates how to use CMake 3.2 to configure the compilation of HLSL shaders, including setting shader types, models, and entry points.

CMake 3.2 introduces support for compiling HLSL shaders directly. This allows developers to easily integrate shader compilation into their build process.

set_source_files_properties( ${PS_SHADER_SOURCES}
    PROPERTIES VS_SHADER_TYPE Pixel
              VS_SHADER_MODEL 5.0
              VS_SHADER_ENTRYPOINT main )

set_source_files_properties( ${VS_SHADER_SOURCES}
    PROPERTIES VS_SHADER_TYPE Vertex
              VS_SHADER_MODEL 5.0
              VS_SHADER_ENTRYPOINT main )

In this example, we demonstrate how to configure two sets of shader sources: pixel shaders (`PS_SHADER_SOURCES`) and vertex shaders (`VS_SHADER_SOURCES`).

For each set, we use set_source_files_properties to define the following properties:

  • VS_SHADER_TYPE: Specifies the shader type (Pixel or Vertex).
  • VS_SHADER_MODEL: Sets the shader model version (in this case, 5.0).
  • VS_SHADER_ENTRYPOINT: Defines the entry point function for the shader (here, `main`).

This CMake snippet allows you to seamlessly manage HLSL shader compilation within your build system, streamlining your workflow and ensuring proper shader configuration.

Transmission tips

To get peers at every five minutes just add to cron ($ crontab -e):

*/5 * * * * LD_LIBRARY_PATH=/i-data/md0/.system/zy-pkgs/lib /i-data/md0/.system/zy-pkgs/bin/transmission-remote -tall --reannounce

Restart Transmission at 1 am:
0 1 * * * LD_LIBRARY_PATH=/usr/local/zy-pkgs/lib /usr/local/zy-pkgs/etc/init.d/Transmission disable
5 1 * * * LD_LIBRARY_PATH=/usr/local/zy-pkgs/lib /usr/local/zy-pkgs/etc/init.d/Transmission enable

Now reboot:
/etc/init.d/crond.sh restart

Monday, 25 May 2015

Create a Git patch file that you can apply it

$ git diff --no-prefix > save.patch
$ patch -p0 < save.patch

Git rebase a topic branch

When you work on your own branch and finished the work it should 'put' back to the master branch without create a merge commit that is very disgust.

Our branch name is 'topic'.

git checkout topic
git rebase master
git checkout master
git merge topic  - this create a fast forward merge

And now we're happy.

Visual Studio compiler flags

Here are some compiler flag that is can be useful:

-D_CRT_SECURE_NO_WARNINGS
-D_HAS_ITERATOR_DEBUGGING=0
-D_SECURE_SCL=0
-D_SECURE_SCL_THROWS=0
-D_SECURE_SCL_DEPRECATE=0

C++11 features that I should use it

Delegating constructors
Uniform Initialization