Sunday, September 17, 2023

Rift on Linux: A Decade Later


It's been almost a decade since I last tried running Rift on Linux. Back then, the experience was sluggish due to state of Direct X emulation.

However, I recently decided to give Rift another go, since it's now available on Steam via Proton. To my surprise, the performance was perfect! Steam has packaged the emulation so well that almost all of my games run smoothly.

What a difference a decade makes for gaming on Linux!




Running well on the potato APU 



Sunday, February 19, 2023

Enabling TRIM in Virtualbox VM

I'm back to using Linux as a desktop for the umpteen time since the days of RedHat 5.2. This time it looks like I might just stick to it since it finally feels "right" as a desktop (most importantly my Windows games and apps runs under Wine).  

This time Linux feels right as a desktop.

One of the first things after moving is to install Virtual machine manager for development.  In goes Virtualbox, and then tried to "fstrim -v /" and got "discard not supported".

Turns out that discard has to be explicitly turned on using "VBoxManage storageattach <VM name> --storagectl "SATA" --port 0 --device 0 --nonrotational on --discard on"





Friday, November 4, 2022

using UMT to create virtual machines using Apple Virtualization on M1 macbook

 

I'm documenting this mostly for myself so that I the steps to redo if I forget.

Background:

Setup up VM using Apple Virtualization (as opposed to QEMU) using UMT https://mac.getutm.app/


We need  ARM64 versions of:

1) linux kernel

2) ramdisk

3) linux image

I use Ubuntu and the cloud images has all the items ready for use.

Linux Kernel file

in https://cloud-images.ubuntu.com/jammy/current/unpacked/

Look for "jammy-server-cloudimg-arm64-vmlinuz-generic" and download

rename the file to gz and gunzip the file.

```mv jammy-server-cloudimg-arm64-vmlinuz-generic jammy-server-cloudimg-arm64-vmlinuz-generic.gz && gunzip jammy-server-cloudimg-arm64-vmlinuz-generic.gz```

Ramdisk

Look for " jammy-server-cloudimg-arm64-initrd-generic" and download

Virtual Disk Image

Download image file from https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.tar.gz   and untar the file






Optional: resize img file  

(This assumes you already have qemu installed via brew)

If you want to add additional 80G to the disk space for example.

```/opt/homebrew/bin/qemu-img resize -f raw jammy-server-cloudimg-arm64.img +80G```


Obtain iso file for cloud init



My personal setup

system login credentials are baked into user-data.yaml

which builds an iso file called 'seed.iso'. which will be used for below instuctions.


alternatively for a basic one see this version

additional reference : https://github.com/frederickding/Cloud-Init-ISO


Finally, set up VM

Launch UTM

1) Add VM
2) Select Virtualize


3) Select Linux




4) select Apple Virtualization
5) Uncompressed Linux kernel select "jammy-server-cloudimg-arm64-vmlinuz-generic"
6) Linux ramdisk select "jammy-server-cloudimg-arm64-initrd-generic"
7) Linux Root FS image select "jammy-server-cloudimg-arm64.img"
8) boot iso select "seed.iso" ( for user and package provisioning)
9) boot argument enter :    console=hvc0 root=/dev/vdb (depends on the order of your storage devices, in this instruction /dev/vda is the iso file, and dev/vdb is the disk)
10) continue and set the rest of the VM resources or leave it default, 












11) save, then start VM

12) you will see a prompt, shortly, the cloud init scripts will update, provision the user and my cloud init will restart system 







13) log in with configured user  and verify diskspace ```df -h```
as with the hyper-v version, I don't seem to require to resize2fs













Sunday, October 31, 2021

Error building gotk3 in Msys2 [Golang]


While building Go program that requires Gotk3 under Msys2, this error may appear during the build.

go build github.com/gotk3/gotk3/gdk: invalid flag in pkg-config --libs: -Wl,-luuid

Run this command to fix the misconfiguration in the packaged gdk PC file and rebuild.

bash -c "sed -i -e 's/-Wl,-luuid/-luuid/g' /mingw64/lib/pkgconfig/gdk-3.0.pc"

Saturday, July 31, 2021

Hyper-v integration with Debian: how to get IP address via powershell

For powershell query to obtain network adapter information of the Debian Buster vm I've installed,

I need to install hyper-v daemon 


```sudo apt-get install hyperv-daemon```


Powershell will be able to query the network information  once it's installed in the guest.

get-vm | ?{$_.State -eq "Running"} | select -ExpandProperty networkadapters | select vmname, macaddress, switchname, ipaddresses


VMName   MacAddress   SwitchName     IPAddresses

------   ----------   ----------     -----------

buildVM 00155D7B6A07 Default Switch {172.25.28.124, fe80::215:5df0:f37b:6a07}

Friday, August 2, 2019

tailing mongo oplog with Perl

I haven't used Perl for over a decade, and I recently got curious to see  how Perl is with respect to the popular languages like Go and Python. Turns out Perl is far from stagnant with nice stuff such as carton package management.

As a practice I decided to try tailing the mongo oplog with Perl. I've written the code with Go and Python to deal with Mongo oplog  not long ago so it's still fresh. Turns out it's fairly easy to do for Perl


Fun!




use MongoDB;
print "hello ";
use feature ':5.10'; # for say
use Data::Dumper;
my $mongo_client = MongoDB::MongoClient->new(host=>'192.168.106.195',port=>7017);
=begin comment
obtaining oplog from "local" db
Every mongod instance has its own local database,
which stores data used in the replication process,
and other instance-specific data. The local database is invisible to replication: collections in the local database are not replicated.
=cut
my $db = $mongo_client->get_database('local');
my $ops_col = $db->get_collection('oplog.rs');
my $cursor = $ops_col->find({});
$cursor->tailable_await(1);
while(true){
say "polling\n";
while ( my $doc = $cursor->next ) {
say Dumper($doc);
}
sleep(2);
}

Saturday, January 14, 2017

Tiny-DNN: Development "as fast as possible" guide

I'm writing this as a simple instruction/refernce to get started using Tiny-DNN to build stuff as fast as possible.

I'm doing this on Ubuntu on Windows 10, Any recent Ubuntu system should have similar if not the same methods of starting.

if you don't have cmake and the gnu c++ compiles:
sudo apt-get install build-essential
sudo apt-get install cmake

(Optional)
if you want to build tiny-dnn with Intel Threading Building Blocks:

sudo apt-get install libtbb-dev

1) clone repo:

git clone https://github.com/tiny-dnn/tiny-dnn

2) Build
cd tiny-dnn

the most simple option is
cmake . 


If you're building with TBB then:
cmake -DUSE_TBB=ON

the build should end with no errors.


3) Building a program:

create a simple program 

for my system, I have to add "#include " to get the program to compile or it will start emitting build errors such as:




I'm going to use one of the sample code in the documentation that constructs a MLP.

// filename: sample.cpp
#include 
#include "tiny_dnn/tiny_dnn.h"
using namespace tiny_dnn;
using namespace tiny_dnn::activation;
using namespace tiny_dnn::layers;

void construct_mlp() {
    network net;

    net << fc(32 * 32, 300)
        << fc(300, 10);

    assert(net.in_data_size() == 32 * 32);
    assert(net.out_data_size() == 10);
}
int main()
{
        construct_mlp();
}

once done compile it (/mnt/e/linuxbuild/tiny-dnn being the directory that was cloned from github and built in #1 and #2)

g++ -pthread -std=c++11 -I /mnt/e/linuxbuild/tiny-dnn sample.cpp

The compiler should build a.out binary successfully.