Friday, 25 September 2015

NSA325-v2, assemble Raid partition

To check existing RAID partition:

$ cat /proc/mdstat

To assemble the raid array:
$ mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1

To stop:
$ mdadm --stop /dev/md1

Now you can mount the raid array to mount point:
$ mount /dev/md1 /root/md1

Zyxel NSA325v2 How to mount a ntfs as internal disk

First, determine new disk:
$ su
enter your password

$ fdisk -l

$ mount -t tntfs -o iostreaming,noatime,ioblocksize=1048576,min_iostreaming_read_iosize=524288,min_iostreaming_write_iosize=1048576,nls=utf8 /dev/sdb1 /e-data/4T

Wednesday, 12 August 2015

Linux debug tips

Debug dynamic libraries loading:
LD_DEBUG=files ./myprogram

Show all unresolved symbols:
ldd -r -d myprogram

Show mangled symbol names:
nm -C /home/xxx/libs/libxxxdb.so

Sunday, 12 July 2015

VS visualizers and usertype.dat

User type keywords

In Visual Studio you can define custom keywords:
usertype.dat next to the devenv.exe
Example content:
Vec3
Vec4
Rectangle
etc...
One line one word, so simple.
-------------------------------------------------------------------------------------------------------------------
Now about the visualizers

You have to place visualizer files under:
c:\Users\YourName\Documents\Visual Studio 2013\Visualizers\

e.g.:
example.natvis

To enable natvis debugger

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Debugger]
"EnableNatvisDiagnostics"=dword:00000001

Later I will describe it.

Example:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="Rectangle">
    <DisplayString>A rectangle with height = {height} {width} </DisplayString>
    <Expand>
      <Item Name="height">height</Item>
      <Item Name="width">width</Item>
      <Item Name="area">height * width</Item>
      <Item Name="macik">macik</Item>
      <ExpandedItem>macik</ExpandedItem>

        <Synthetic Name="Am I a square?" Condition="height==width">
          <DisplayString>Yes I am. </DisplayString>
        </Synthetic>
        <Synthetic Name="Am I a square?" Condition="height!=width">
          <DisplayString>No I am not.</DisplayString>
        </Synthetic>

    </Expand>
  </Type>


  <Type Name="Rectangle2">
    <DisplayString Condition="height == 4">negy = {height} {width} </DisplayString>
    <DisplayString Condition="height == 3">harom</DisplayString>
    <Expand>
      <Item Name="height">height</Item>
      <Item Name="width">width</Item>
      <Item Name="area">height * width</Item>
    </Expand>
  </Type>


  <Type Name="std::vector&lt;*&gt;">
    <Expand>
      <Item Name="[size]">_Mylast - _Myfirst</Item>
<!--      <Item Name="[capacity]">(_Myend - _Myfirst)</Item>-->
      <ArrayItems>
        <Size>_Mylast - _Myfirst</Size>
        <ValuePointer>_Myfirst</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>


</AutoVisualizer>

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