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.


    Tuesday, October 16, 2018

    Silicon Valley Code Camp 2018


    This weekend I attended Silicon Valley Code Camp. Code Camp is a conference on its 12th year held in San Jose California and put on by volunteers. I’ve known about it for many years (I found the earliest email I got from them is from 2009), but this was my first year of attendance.

    In this post I give quick play by play of my weekend, with summaries, impressions and/or takeaways from each of the talks I attended.

    Saturday I arrived late and had no problem getting my pass as I had registered early. I arrived late to my first talk. It was about IoT with Edge. I’m very disappointed I missed as much as I did. I was able to glean how Edge devices and routers interact to communicate with the cloud. How twins of the device status are mirrored on the cloud and what role hubs perform when connection to the cloud is severed. It seems that it runs on raspberry pi, I was not aware of that. 

    The second talk was on C++ server API’s. The speaker was really entertaining and explained things well. He went on a few tangents which took a lot of his time, but they were entertaining so I forgive him. However, he couldn’t finish the talk on time so a few things were skipped over. I’m really not criticizing him for this. I don’t think that not getting the full talk made my experience on Saturday any less vaLuable. More than anything this talk was more a discussion on best practices when beginning new projects.

    The third talk I went to was on java and Kubernetes. This one was tough. I do not know enough about docker to have gotten as much as I’d like from this. I got a general idea of workflow, of setup, of Java through docker with Kubernetes within IntelliJ.

    Next was a talk on Recursion and Dynamic programming for technical interviews. This was really just a talk. It represented recursion and dynamic programming with simplified language as opposed to any detailed implementation or code. Dynamic programming fit into the talk really smoothly. Again, it used the same simple explanation technique as used for recursion. What’s more it seemed very natural to explain DP directly after explaining recursion as he had built up the concepts in such a way that the two example problems were nearly identical.

    The final talk was not technical. It was about human learning techniques. Worth the time and part of the reason I’m writing this. The speaker was really good and covered some things that hold back learning, techniques students and educators could use (like a learning journal) and some myths.

    Sunday was more laid back: fewer people, less prepared speakers, for lack of a better description, less popular topics.

    I started by going to an intro to mongoDB. My take from the talk was that It sounds like a great way to get away from SQL tables and a carefully planned DB before implementation aka. prototyping. 

    For the rest of most of Sunday I attended a series of talks by 3 gentlemen. The series was ostensibly about creating drivers for android. That’s not what it was. It was implement Android’s Binder Inter-process communication as a linux device drivers.

    The first talk was the best for anyone who went for an education on android. It covered concepts of binder which would help any Android programmer to better understand and better utilize the technology.
    The second in the series was an introductory tutorial on writing kernel mods for linux and a bit on the Android Linux kernel.

    The third talk was the curve ball. Where the speaker showed his implementation of Binder on an Ubuntu AWS machine. A little bit of a letdown but overall a really excellent series but for the expectations set. Now looking at the schedule I can see the signs. 

    Finally a talk on interfacing with C from Lua and Ruby. in all directions: Lua to C, C to Lua, Ruby to C, and C to Ruby. It’s apparently really easy to call C libraries in Ruby. The speaker spent more time than was needed on summarizing each language. I don’t believe anyone actually attended the talk which didn’t know one of the languages and so the subject of actually interfacing seemed to not get enough attention while the majority of the talk was used to educate everyone on the properties of Lua and Ruby which weren’t necessarily relevant to interfacing with C.

    Food and drink were provided in the morning, at lunch each day with occasional snacks set out, and ice cream in the afternoon on Sunday. There were raffled prizes donated by the event’s sponsors. It was well worth the money paid. In fact it was worth far more than the money paid. I’m really kicking myself for 9 years of stupidity for not attending.

    - Victor F.

    Wednesday, November 8, 2017

    Experiments in Basing I

    The release of the 8th edition rules of 40k has brought me, as it has many others, back into the terrifying depths of the Warhammer 40k hobby where time is wasted never to be seen again. Having a great looking army is a distant dream of mine and though it may take until the god emperor of mankind reveals himself to start his crusade across the stars, my Waaagh! will be ready and goddammit it will look good.

    A few types of bases caught my eye, particularly those with cracked earth, so I picked up a bottle of Agrellan Earth from Citadel. Now what to do with it?
    As a young Warboss I put my army on bases as soon as I glued them together. I thought that's how it was done. I soon found out that was not how one became the flashiest git on the table. So instead of tearing my army apart and having my boyz unplayable while they undergo a makeover I picked up these cheap wooden 25mm bases. I don't know how well they work on the table compared to the plastic ones, but as for putting paint on them, I like 'em fine.
    I slapped on my slate and the small basing accessories that I got in some basing kit years ago (using liquid elmer's glue & super glue).
    I went straight to this color, I got this idea from someone I played a game against, but he used automotive primer. Go with something like that, don't go with this paint; it sucks. It drips than a hungry squig.
    I shouldn't have to say "After it dried," but for any young warbosses reading this I will say: always wait 'til a coat fully dries before moving on to the next one.
    After the coat dried I put on the Agrellan Earth.
    Here, I did not put a varnish on the painted wood before applying Agrellan Earth like I should have and almost sorely paid for it. A varnish will help make sure the Agrellan earth stays stuck firmly to it. Wood without varnish performed will in this manner in my experience, the paint above did not.Something flat and hard works better than a paint brush for this; I used sculpting tools. I spread it all over the flat wood portions and got it all the way to touching the base of the rocks and bits.
    I did not wait long enough for it dry (around 4 hours) and I noticed some of the paint had shrunk more after I started the next step. The next step is applying a wash. I used both sepia colors they both look great. I used another red wash and went much lighter. This one is intended to be (but was not in practice) applied superficially to the surface of the paint flakes and not to run into the cracks as the sepias should. The red wash is for color variety.
    The last step was dry brushing. I dry brushed gray onto the rocks and then oiled leather on everything, including the rocks. I might come back and dry brush an even lighter tan color for a dryer desert look. The oiled leather isn't very noticeable.

    I am liking how they turned out and they definitely look better than what I did previously. It's not too time consuming which I like a lot. You get a great look out of a little bit of work. But my original idea was not satisfied and I may have found a way to make it as fast as this.

    Here's all the photos in an album.
    And here are a bunch of youtube videos I saw before trying this:
    https://youtu.be/tWm38GgtGVs
    https://youtu.be/iHWo8RG1NuY
    https://youtu.be/P3zpcTHKS9U