Skip to content

Instantly share code, notes, and snippets.

View makotokato's full-sized avatar

Makoto Kato makotokato

View GitHub Profile
@makotokato
makotokato / sensor.cpp
Created April 4, 2012 07:15
Windows Sensor API test
#include <olectl.h>
#include <sensorsapi.h>
#include <sensors.h>
#include <stdio.h>
#pragma comment(lib, "sensorsapi.lib")
#pragma comment(lib, "PortableDeviceGUIDs.lib")
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "user32.lib")

RustでのTCP/IPネットワークアプリケーション

RustではTCP/IP通信を利用するためにいくつかの組み込みオブジェクトが用意されています。この章では簡単なTCP/IPアプリケーションを実装する上での基本的な方法を説明します。

まずTCP/IPアプリケーションを作成するにはいくつかの方法があります。

  • rust標準のstd::rt::io::netパッケージを利用する
  • rustで利用されるlibvuをffi経由で利用する
  • OS標準のライブラリwinsocketやBSD socketをffi経由で利用する
@makotokato
makotokato / emojiinfo.cpp
Created March 7, 2014 07:59
Access Color Emoji Font on Windows 8.1 with DirectWrite
#include <dwrite.h>
#include <dwrite_2.h>
#include <stdio.h>
#pragma comment(lib, "dwrite.lib")
int main()
{
HRESULT hr;
IDWriteFactory* dwriteFactory;
@makotokato
makotokato / colorglyph.cpp
Created March 10, 2014 03:16
Draw Color Glyph with DirectWrite 1.2
void DrawGlyphRun(ID2D1RenderTarget* target, IDWriteFactory factory, IDWriteFont* fontFace, ID2D1Brush* defaultBrush, DWRITE_GLYPH_RUN* glyphRun)
{
bool isColor = false;
IDWriteColorGlyphRunEnumerator* colorLayer;
IDWriteFont2* fontFace2;
fontFace->QueryInterface(reinterpret_cast<IDWriteFontFace2**>(&fontFace2));
if (fontFace2->IsColorFont()) {
IDWriteFactory2* factory2;
factory->QueryIntarface(reinterpret_cast<IDWriteFactory2**>(&factory2));
<?DOCTYPE html>
<html>
<head>
<script>
var crypto = window.crypto;
var data = convertStringToArrayBufferView('ABCDEFGHIJKLMNOP');
var vector = crypto.getRandomValues(new Uint8Array(16));
function convertStringToArrayBufferView(str)
{
@makotokato
makotokato / vsync.c
Created March 6, 2016 12:17
get vsync using libdrm
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#include "xf86drm.h"
// gcc -I/usr/include/libdrm/ -ldrm vsync.c
int64_t get_time(void)
{
@makotokato
makotokato / update_command.sh
Created January 19, 2018 03:34
Update ICU for Gecko
PYTHONPATH=../python/mozbuild ./update-icu.sh http://source.icu-project.org/repos/icu/trunk/icu4c
./configure --host=x86_64-pc-mingw32 --build=x86_64-pc-mingw32 --disable-shared --enable-static CC="$(pwd)/msvcc.sh -m64" CPP="cl -nologo -EP" SHELL=sh.exe LD=link
@makotokato
makotokato / setup-nss.sh
Created June 11, 2019 04:54
Setup NSS build environment on Amazon AMI
sudo yum groupinstall "Development Tools"
sudo yum install ninja-build
wget https://www.mercurial-scm.org/release/mercurial-5.0.1.tar.gz
tar xf mercurial-5.0.1.tar.gz
cd mercurial-5.0.1.tar.gz
make all
sudo make install
cd ..
/usr/local/bin/hg clone https://hg.mozilla.org/projects/nspr
@makotokato
makotokato / GeckoViewOnWindows.md
Last active May 10, 2023 01:55
How to build GeckoView on Windows workstation

How to build GeckoView on Windows workstation

Actually, we can build GeckoView on WSL and VMs. but since Android Studio runs under Windows, not WSL, if using WSL, you cannot use Android Studio to debug GeckoView. We have limited support to build GV on the mozilla-build environment.

Using WSL (Bash for Windows, Windows Subsystem for Linux)

Same as Linux. But,

  • You cannot use Android Studio to debug GV
  • WSL doesn't support USB. So ./mach install or ./mach run doesn't work. But this has workaround (see using ADB).
  • WSL2 (comming in Windows 10 20H1)'s filesystem is fast, but if using NTFS filesystem's directory, it will be too slow (microsoft/WSL#4197).
  • WSL2 may have limited USB support, but I don't know about adb (microsoft/WSL#2195)