Thursday, August 22, 2019

Kerbal Mission Summary: Kerbed Mun Expedition


Mission: Send 3 astronauts to the mun. Land all 3 on the mun. Collect science. Reenter the lander. Boost to munar orbit. Rendezvous with the station. Refuel.




I flew all the way to mun transfer and then remembered I didn’t pack science. So I reset and started again




I thought my delta V should be enough to get back into orbit, apparently it wasn’t.

Observations: The solar panels and antenna are very fragile and will break off if I hit them with a kerbal flying on his jetpack.

Result: Jeb, Tener and Bob stranded on mun.

Saturday, August 10, 2019

Guide NAS on Raspberry Pi 4

I wanted to get a NAS solution for my apartment. The requirements were simple: it needs to serve my external USB's over the network and to be cheap. So when the Raspberry Pi 4 was announced I was curious if that would be able to be a cheaper alternative.

I ended up going with it because it was the smallest monetary upfront cost. $80 for a computer was not as big a commitment to the $200 i would need to at minimum spend. But if you were to factor in the costs of my external hard drives as compared to a more modern, durable, brand new set of drives. And a more streamlined setup process to boot. I'd say the conventional in store NAS solutions have a strong argument.

For this guide I will step through setting up a new Raspberry Pi 4, installing Rasbian lite and then OMV 5 beta, setting up OMV, ssh, and associated users, mounting an external usb HDD 280 GB and sharing it over SMB. I won't get into RAID configurations or other sharing protocols in this guide.

For this setup you will need:
  • This Guide uses MacOS X Mojave 10.14.5

Process Steps:

Imaging Raspbian
  1. Download the latest version of Rasbian Lite. The version I downloaded is Buster.
  2. Plug in your MicroSD card.
  3. Open Disk Utility
  4. Select your sd card in disk utility and look at the device field to find the device associated with your disk.
    If your device field says Disk2s1 then your dev is at /dev/rdisk2.
    Disk Utility with the system drive selected.
  5. Open terminal.
  6. sudo dd bs=1m if=~/Downloads/2019-07-10-raspbian-buster-lite.img of=/dev/rdisk2 conv=sync
    Obviously matching for the exact img you downloaded from raspbian. Let it run.
  7. When that finishes open the sd card in finder. (mount it in disk utility if its not mounted already).
Enabling SSH and Connecting
Before we start up the new raspbian boot sector on the pi, we need to make sure we can access the pi remotely by enabling ssh.
  1. In terminal navigate to the boot partition of the newly minted microsd card
  2. Mine is in /Volumes/boot
  3. In terminal type touch ssh to create an empty file named ssh
  4. Eject your microsd card
  5. Insert into rpi and power up.
  6. After a min to boot and initialize, in the terminal type  ssh pi@192.168.1.6 (use the address of your raspberry pi. You may need to find it in your by scanning your network or logging into your router and finding the network lease.)
  7. Use the default password 'raspberry'
  8. You should see a new terminal prompt from the raspberry pi. (accept the unsafe connection)
Modify deb repos and install armbian
  1. Follow the steps in this forum post in summary you will:
    • Add an apt repo
    • Install armbian
    • Use armbian-config to install OMV 5
      • Let it run
Log in to OMV web
  1. In your favorite browser go to the ip of your raspberry pi. 
  2. Log in using admin and default password openmediavault.
Configure Users
  1. Add any new users or modify passwords as needed here.
Enable SSH Again.
  1. While in rights management > users, be sure any users you want to be able to ssh in with are a part of the group ssh.
  2. Navigate to services SSH and be sure it's enabled. 
Enable Root Account
  1. While logged into the pi over ssh, in terminal enable the root account and change the password as in here.
Connecting, mounting and configuring external
  1. Plug in your external hard drive.
  2. Go to Storage > File systems
  3. Select your disk, it will have a name like /dev/sda1.
  4. Click Mount
  5. Click the apply changes button.
    Creating shared folder from external
    1. When the task finishes, go to Access rights managment > Shared Folders
    2. Click add, select your file system from devices and configure the share with a path.
    3. Click save.
    Creating SMB share from shared folder
    1. Click services > SMB/CIFS
    2. Enable it and set the workgroup name to something.
    3. Click shares
    4. Click add
    5. Select your shared folder
    Before we connect and access our NAS we need to name it.
    1. Go to system > network and set the hostname.
    2. In finder click go
    3. Click connect to server
    4. Type smb://nas-hostname
    Et voila!

    Pitfalls:
    HDMI
    Dont forget that the rspberry pi 4 uses micro HDMI cables. But you don't need them for this guide since we are able to SSH to the device and configure it remotely without a HDMI attached monitor.
    USB powered external drives
    Raspberry pi will apparently not power external HDD's without their own power source. If yours isn't working that's why.
    Relabeling
    Coming from the windows world my very mass produced external has always been named 'My Book'. But I suspect that space caused a lot of grief as I received the following error when applying the configuration change.
    Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; omv-salt deploy run fstab 2>&1' with exit code '1': /usr/lib/python3/dist-packages/salt/utils/path.py:265: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working if not isinstance(exes, collections.Iterable): /usr/lib/python3/dist-packages/salt/utils/decorators/signature.py:31: DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly *salt.utils.args.get_function_argspec(original_function) raspberrypi: ---------- ID: create_filesystem_mountpoint_0b89de0f-125a-47d9-bbd1-58a3a7da4ef7 Function: file.accumulated Result: True Comment: Accumulator create_filesystem_mountpoint_0b89de0f-125a-47d9-bbd1-58a3a7da4ef7 for file /etc/fstab was charged by text Started: 21:58:46.603232 Duration: 1.485 ms Changes: ---------- ID: append_fstab_entries Function: file.blockreplace Name: /etc/fstab Result: True Comment: No changes needed to be made Started: 21:58:46.606017 Duration: 6.132 ms Changes: ---------- ID: mount_no_bind_mountpoint_0b89de0f-125a-47d9-bbd1-58a3a7da4ef7 Function: mount.mounted Name: /srv/dev-disk-by-label-My Book Result: False Comment: mount: bad usage Try 'mount --help' for more information. Started: 21:58:46.613705 Duration: 539.445 ms Changes: Summary for raspberrypi ------------ Succeeded: 2 Failed: 1 ------------ Total states run: 3 Total run time: 547.062 ms


    Error #0:
    OMV\ExecException: Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; omv-salt deploy run fstab 2>&1' with exit code '1': /usr/lib/python3/dist-packages/salt/utils/path.py:265: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
      if not isinstance(exes, collections.Iterable):
    /usr/lib/python3/dist-packages/salt/utils/decorators/signature.py:31: DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
      *salt.utils.args.get_function_argspec(original_function)
    raspberrypi:
    ----------
              ID: create_filesystem_mountpoint_0b89de0f-125a-47d9-bbd1-58a3a7da4ef7
        Function: file.accumulated
          Result: True
         Comment: Accumulator create_filesystem_mountpoint_0b89de0f-125a-47d9-bbd1-58a3a7da4ef7 for file /etc/fstab was charged by text
         Started: 21:58:46.603232
        Duration: 1.485 ms
         Changes:
    ----------
              ID: append_fstab_entries
        Function: file.blockreplace
            Name: /etc/fstab
          Result: True
         Comment: No changes needed to be made
         Started: 21:58:46.606017
        Duration: 6.132 ms
         Changes:
    ----------
              ID: mount_no_bind_mountpoint_0b89de0f-125a-47d9-bbd1-58a3a7da4ef7
        Function: mount.mounted
            Name: /srv/dev-disk-by-label-My Book
          Result: False
         Comment: mount: bad usage
                  Try 'mount --help' for more information.
         Started: 21:58:46.613705
        Duration: 539.445 ms
         Changes:
    To fix this error change the format label using fatlabel to something without a space, unmount and unplug the USB external.  Delete the reference to the file system. Apply the changes then start over with the new label. It should work fine now.

    Closing Thoughts
    It's simple and cheap and it does what I wanted. But it can't really be taken seriously without looking at it's performance and whether it can manage an effective RAID. Also I'd love to get it all into one case.

    Thursday, January 31, 2019

    An Empty WebStorm Project and Unresolved Require

    When I started an empty Webstorm project to do some light dabbling in Node.js the IDE would not recognize some pretty basic node globals for autocomplete. (version 2018.3.3)


    The resources and posts I found all used solutions which didn't work for me or could not carry them out.


    The solution is to simply go into the Node and NPM settings menu (Settings | Languages & Frameworks | Node.js and NPM) and check "the box". The box which says "Coding Assistance for Node.js".


    Apparently people have also noticed this on other projects which may not have started on empty. Un-checking and re-checking looks like it can help.

    Good Luck!

    - Victor F

    Wednesday, January 30, 2019

    The $27 Mechanical Keyboard from Aukey

    I bought a $27 AUKEY mechanical keyboard with equivalent blue switches.

    I'm actually really proud of those sheets.

    The Aukey KM-G9 feels heavy. Weighing in at 1.83 pounds (according to Amazon) it's the heaviest keyboard I own now, in spite of it being the one with the least number of keys.

    The sound of the clicks are very high pitched. So when typing softly that's primarily all I hear. When typing harder you'll get a deeper thwak (as keyboards do). I'm using this in the office now; It's pretty loud. There's a reverberation after the key strokes, like tapping on a metal bowl, when I listen to it in a quieter place.

    The action is more than I'm used to, having mostly typed on laptop and stock, included for free keyboards.
    As such it feels very different and I'm not having the best performance of my life.

    If, like me, you've wanted a mechanical keyboard but the prices and number of choices are paralyzing you - keeping you from your from your destiny - this one, among other low price Chinese offers, could be the one to get you through the door.

    Good Luck!
    - Victor F

    Tuesday, January 29, 2019

    How to Look Under the Hood at Javascript Code

    I'm finally taking the long overdue step of learning Javascript. Part of the process of learning language is to figure out what it is doing at a far lower level then the luxurious heights at which we get to program. Plus it's just damn interesting.

    In the Node (using v10.14.2) usage description there is an option --v8-options. Run Node with this to see a long list of options to give directly to V8, the Javascript engine running under the hood of Node.

    There are a few options in here that will get us a look at the inner workings of the Javascript code we write.
    --print-code
    --print-bytecode
    
    --print-code prints the code out in x64 assembly, I think.

    --print-bytecode prints the intermediate bytecode.

    For even a simple program like hello world there are a few pages of bootstrapping code that also gets printed out. Your functions are put under a label that looks like this: 
    [generated bytecode for function: myadd]

    Use that to your advantage to find your code.

    Good Luck!

    -Victor F.