A website to make the meal math easier on the parents

https://yum.akrin.com

List of current features:

  1. It uses the USDA National Nutrient Database as the basis for all the foods you can search (your tax dollars at work).
  2. You can add your own recipes, ingredients whatever else is not in the base database. We find that we add all the foods we use even if it’s just bread because a bread with a label is always more accurate than the generic/average bread as defined in the USDA database. It’s also nice for adding your family specials once and for all and never have to do the math again.
  3. What you add is not shared amongst users and it only visible to you.
  4. It tries to learn which foods come back to help pick them later on.
  5. It remembers which amounts you last used
  6. Calculates insulin dose on the fly
  7. Very simple & streamlined navigation for the least work for the parents

This is still very much a work in progress but has made our meals a lot more agreeable already.

Markov chains music generation

Here’s a project I’ve had on the back-burner for many years. Following the natural progression of generating stuff based on Markov chains, I decided a while ago to port the algorithm to music.

Music presents many challenges that I haven’t been able to address well so far. As a result, what the algorithm produces always had a bitter unfinished aftertaste to me, hence why I haven’t published anything about it for years.

  • Music is multidimensional, time is relevant and needs it own analysis and subsequent generation
  • The interconnectedness of different instruments from the piece is important as well.
  • Random generation even based on Markov chains fails to produce any structure. The pieces all sound like a long solo without chorus or any other repetition that would give us what we strive for: anticipation. In other words, it’s perfect for jazz.

I’m hoping that publishing this will give me the kick in the nuts necessary to keep improving it. Without further ado, here’s what I have so far.


Future improvements:

  • add to corpus
  • clean pieces analyzed of noise
  • try to infuse structure

FreeBSD manual multipath script

I recently ran into an issue installing FreeBSD on a system that already had some disks & zpools. Because the disks were partitioned previously, automatic multipath was not an option as the last sector of all hard drives isn’t available to store an ID. The remaining option is to do manual multipath, and it needs to be done every time the system boots.

Here’s an rc script that will run early in the sequence and create a multipath “link” between drives based on their serial number.

/etc/rc.d/manual_multipath

#!/bin/sh

# PROVIDES: manual_multipath
# REQUIRE: sysctl
# BEFORE: hostid

. /etc/rc.subr

name="manual_multipath"
start_cmd="${name}_start"
stop_cmd=":"

manual_multipath_start()
{
        echo "> manual_multipath script started"
        echo "> linking drives with the same serial number with gmultipath"
        counter=0
        serials=""
        devices=`/usr/bin/find /dev -maxdepth 1 -regex '.*da[0-9]*' | /usr/bin/cut -d '/' -f 3`
        for device in $devices
        do
                echo $device
                serial=`camcontrol inquiry $device -S`
                substring=`echo "$serials" | /usr/bin/sed -n "s/|$serial|.*//p" | /usr/bin/wc -c`
                if [ $substring -eq 0 ]
                then
                        found_multi=0
                        arg1="$device"
                        arg2="$device"
                        for newdevice in $devices
                        do
                                newserial=`camcontrol inquiry $newdevice -S`
                                if [ "$device" != "$newdevice" -a "$serial" == "$newserial" ]
                                then
                                        echo "  same as $newdevice!"
                                        counter=`expr $counter + 1`
                                        found_multi=1
                                        arg1=$arg1"$newdevice"
                                        arg2=$arg2" $newdevice"
                                fi
                        done
                        if [ $found_multi -eq 1 ]
                        then
                                gmultipath create $arg1 $arg2
                        fi
                fi
                serials=$serials"|$serial|"
        done
        echo "> manual_multipath script finished, found $counter matches"
}

load_rc_config $name
run_rc_command "$1"

Don’t forget to “chmod 555 /etc/rc.d/manual_multipath”.

Lastly, when importing a zpool from the drives you just multipathed, make sure to specify where to look for devices or you might end up importing a mix of multipath and regular devices. Make sure to “zpool import -d /dev/multipath”.

I’m delving pretty deep into FreeBSD, time to grow an epic beard.