2018年2月19日月曜日

VinoでVNC

XubuntuでVNCサーバを設定するノート

VNCサーバ

vinoをインストールする.
#vino-preferences
で設定起動.
以下のチェックを入れる.
[Sharing]
Allow other users to view your desktop
 Allow other users to control your desktop

以下のチェックを外す.
[Security]
You must confirm each access to this machine

暗号化を使わない場合,
#gsettings set org.gnome.Vino require-encryption false
とする.
サーバーの場所は以下,
#/usr/lib/vino/vino-server
スタートアップに設定しておくと楽.
VNCクライアントからは, IPアドレス:ディスプレイ番号で接続する. ディスプレイ番号が0なら省略可能.

Wake On LAN

まず, BIOS設定からそれっぽいものを有効にする.
ethtoolをインストールして, ツールにインターフェイス名を指定して情報を表示する.
以下のように, ステータスがdになっていれば無効になっている.
#apt install ethtool
#ethtool enp1s0
    ----
    Wake-on: d
    ----
以下のように有効化, 必要なら適当な箇所で有効になるように設定する.
ステータスがgになっていれば有効.
#ethtool -s enp1s0 wol g
    ----
    Wake-on: g
    ----

.Netから叩き起こす
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;

namespace WakeOnLAN
{
    class Program
    {
        static void Main(string[] args)
        {
            if(args.Length<2) {
                System.Console.WriteLine("Usage: <global ip address> <mac address>");
                return;
            }
            try {
                IPAddress globalAddress = null;
                if(!IPAddress.TryParse(args[0], out globalAddress)) {
                    return;
                }
                PhysicalAddress physicalAddress = PhysicalAddress.Parse(args[1]);
                using(MemoryStream memoryStream = new MemoryStream())
                using(BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
                using(UdpClient client = new UdpClient()) {
                    for(int i = 0; i<6; ++i) {
                        binaryWriter.Write((byte)0xFF);
                    }
                    byte[] bytes = physicalAddress.GetAddressBytes();
                    for(int i = 0; i<16; ++i) {
                        binaryWriter.Write(bytes);
                    }

                    binaryWriter.Flush();
                    byte[] sendData = memoryStream.ToArray();
                    client.EnableBroadcast = true;
                    client.Send(sendData, sendData.Length, new IPEndPoint(globalAddress, 0));
                    client.Close();
                }

            } catch {
                return;
            }
        }
    }
}

2018年2月7日水曜日

Morton Codeの計算とLBVH

Morton Code

概要

Z階数曲線(モートン符号)は, Z字型に空間を符号化します.
下図のように左上を原点とした場合にZ字型に空間を1次元に符号化します.

2018年1月20日土曜日

Simple zlib Decompression

概要

zlibフォーマットを自力で伸張するライブラリszlib(Github)を作成しました.
できるプログラマはこのようなものを簡単に作ると思いますが, 私は大変苦労したため,
ノートを残しておこうと思います.

2017年11月13日月曜日

Learning of Vulkan Part 01

はじめに

Vulkanを段階的に, 私のために学習していきます.
私のための学習ですので, プログラミング, CGの基礎, 概要は省略します.
画面のクリアまで行いました.

2017年11月4日土曜日

XCBでウィンドウ表示まで

XCBは, Xlibを置き換えるために開発されている, X Serverとお話するためのCライブラリです.
私の目的はVulkanのためなのですが, ノートを書いておきます.

2017年10月29日日曜日

Learning of Vulkan Part 00

はじめに

Vulkanを段階的に, 私のために学習していきます.
私のための学習ですので, プログラミング, CGの基礎, 概要は省略します.
始めにライブラリのロードを行いました.

2017年10月25日水曜日

Overgrowth

Overgrowth have been released.
I've read some articles of their blog, thought that it's great work, i agree with their spirit of inquiry.