True's beaked whale.jpg

Western spotted skunk

Hooded skunk

Yellow-throated Marten

Wolverine

Archive for the ‘Software’ Category

Updated Voronoi diagram Inkscape extension

Monday, June 24th, 2024

Updated jim_voronoi.zip extension to work with Inkscape 1.3! (Original version of the extension.). To install, go to Inscape -> Extensions -> Manage extension -> Install packages tab -> click on file icon and select the zip file.

Takes as input a shape to fill with a Voronoi diagram. The number of levels of recursive Voronoi diagrams can be set.

Options

Random seed points: Number of starting points. The distribution of the starting points is set for each level of the diagram.

Options:
Levels of recursion: Within each Voronoi region, a new Voronoi diagram is created.

Level(rand_type):relax,…: Sets of parameters for each Voronoi diagram level.
<level>(<normalization method>[param1=n;parms2 = n.n; params3=foo…]):<Llyod’s relaxation interations>
The randomization type can be ‘normdist’, ‘normdist_edge’, ‘random’. ‘Random’ distributes the seed points randomly. ‘Normdist’ distributes the seed points around one or more ‘centers’ (default is 1 center), distributed around the centroid. ‘Normdist_edge’ moves the seeds away from the centers toward the edge.
Llyod’s relaxation moves each of the points halfway between its current position and the centroid of the Voronoi polygon it is located in with each iteration.

Parameters:
centers = 2 – Number of centers to cluster ‘normdist’ random points around. Centers are spaced at center_dist from the centroid of the input path.
keep_centers = 0,1,3… – Which of the centers to use. Numbering starts at 0.
center_dist = 1.23 – Distance from the path centroid to place the random seed centers. dist = size / center_dist. Default = 2.0. Large numbers push the centers towards the edge.
min_dist = 1.23 – Minimum distance of random points from the edge of the path. In Inkscape units. Default = 5.
sd = 1.23 – Standard deviation of the random points. sd = standard deviation of the random points. sd = size / sd. Larger numbers give a tighter distribution. Default = 2.5.
xy = x1,y1, x2,y2… – Explicitly enter random seed point locations. In Inkscape units. Overrides random dist center parameters.

Return lines or polygons: The Voronoi regions are added to the document as polygons or lines.

Disk mount issue

Monday, November 27th, 2023

I added a new disk, removed one on my workstation. It is running Ubuntu 20.04. Booted up, and the drive letters have changed, and the md number of a RAID 1 array changed. So I updated /etc/fstab and went to mount the /dev/md1 array. The mount command completes without error, but the disk did not mount. Turns out, needed to:

systemctl daemon-reload

Then the mount worked, and I could add the new disk to the RAID 1 array.

Limit Firefox memory

Saturday, November 11th, 2023
  1. Open Firefox, go to about:config.
  2. Go to browser.tabs.unloadOnLowMemory, set it to true.
  3. Go to browser.low_commit_space_threshold_mb, set it to 2/3 or 3/4 of total memory on your computer. (e.g. 32GB -> 24000).

Downloading a video from an ebay listing

Wednesday, March 8th, 2023

Using Firefox, go to the item page, open the Firefox Web Developer Tools (Menu -> More tools -> Web Developer Tools). Click on the Network tab in the Tools section, then on the web page click on the video and play it.

In the Network tab, requests for audio_128kb-0.m4s to audio_128kb-16.m4s appeared, and video_720p-0.m4s to video_720p-16.m4s. I copied the URL for the video and audio requests (all the same but with a different -0 to -16 segment), and used wget to download the files. Each was 1-2 MB:

wget https://video.ebaycdn.net/videos/v1/8f1e79501860a64d9e245434ffffec91/5/video_720p-0.m4s

After 32 wget commands, the entire video was present. I downloaded segments from 0 up until after number 16, I got a ‘not found’ message letting me know I had the last segment.

Then I concatenated the pieces together:

cat video_720p-0.m4s >> video_720p.m4s
cat video_720p-1.m4s >> video_720p.m4s
...
cat video_720p-16.m4s >> video_720p.m4s

And the same for the audio segments. I put the cat commands into a batch file “cat.txt” and ran them using “bash cat.txt”.
Then ffmpeg was used to combine them and convert to mp4 format:

ffmpeg -i video_720p.m4s -i audio_128kb.m4s -c copy ebay_720p.mp4

Using cron to mute sound in Ubuntu 20.04

Wednesday, August 18th, 2021

I wanted to turn off audio at night automatically using cron.

I saw suggestions to use amixer:
export DISPLAY=:0 && /usr/bin/amixer -D pulse sset Master,0 0%
but this gave an error:

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
amixer: Mixer attach pulse error: Connection refused

This works, add this line to /etc/crontab:

* 23<tab>* * *<tab>jiml<tab>DISPLAY=:0.0 pactl --server unix:/run/user/1000/pulse/native set-sink-mute @DEFAULT_SINK@ true

and restart cron:
service cron restart

jiml is the user with the open desktop.
‘1000’ is the uid of user ‘jiml’, this can be found by:

ls /run/user
or
id -u jiml

and restart cron:
service cron restart


jiml is the user with the open desktop.
‘1000’ is the uid of user ‘jiml’, this can be found by:

ls /run/user
or
id -u jiml

STAR-Fusion

Wednesday, October 24th, 2018

STAR-Fusion is a program that detects RNA fusions events in RNA-Seq data. According to the paper describing the program, STAR-Fusion is much better than the dozen or so other callers under active development.

Still, reading the paper left me with some questions. As descried by the authors, STAR-Fusion is not just a good caller, but the best caller by a wide margin. See Fig 3A. The next nine best callers have AUC values of 0.5 to 0.3, but STAR-Fusion has a value of 0.8 in the author’s testing.

And what is the source of this incredible result? The authors are silent on the subject. They don’t know, or perhaps didn’t notice how remarkable their achievement is, and so don’t remark on it. The description of the STAR-Fusion algorithm seems very similar to the algorithms used by every other RNA fusion caller. Some do better than others, so details of implementation must matter.

So what is the critical advance STAR-Fusion makes? Is better sequence alignment key? Is the filtering approach? The paralog handling seems like it cuts down on false positives, is this key? Discovering the critical factors for RNA fusion calling would be an important result.

Or are the performance results in the paper dependent on the synthetic test data set the authors use? Will subsequent papers comparing STAR-Fusion to other methods find that it is only average, or sub-par?

Saving streaming audio on Linux

Saturday, January 30th, 2016

MONITOR=$(pactl list | egrep -A2 ‘^(\*\*\* )?Source #’ | grep ‘Name: .*\.monitor$’ | awk ‘{print $NF}’ | tail -n1)

goes to alsa_output.pci-0000_00_1b.0.analog-stereo.monitor on my system

LAMEOPTIONS=’ -s 44.1 –preset cbr 192′
FILENAME=foo.mp3

Record currently playing audio:
parec -d $MONITOR | lame $LAMEOPTIONS -r $FILENAME

Split into separate 1 hr files with a 3 sec overlap:
ffmpeg -ss 00:00:00 -t 01:00:03 -i foo.mp3 $1.01.mp3 -acodec copy
ffmpeg -ss 01:00:00 -t 01:00:03 -i foo.mp3 $1.02.mp3 -acodec copy

Commands from here

App game idea

Friday, February 15th, 2013

Flip it

This game board is an array of tiles. The tiles have letters. The game play involves flipping a pair of letters, as if the two tiles can move through the screen on the axis that connects them. In any case, they move switches them. The goal is to rearrange the tiles to spell words.
Move:

cat --flip c:a--> act
dog ------------> dog

cat --flip c:d--> dat
dog ------------> cog

The game can be played different sized boards, and with boards with cutouts.
Variation 1: Have the tiles have both color and a letter, to distinguish common letters.
Variation 2: Have the tiles be two sided, so that flipping them exposes the other sides.

What is interesting about this is that it is a class of games easy to implement in the computer but which is hard or impossible to implement as a physical game. There is a whole class of variations on pen and pencil or board games that haven’t been tried because of this!

Switched to the Cinnamon window manager

Sunday, January 13th, 2013

I run Ubuntu on my main home machine, but the latest 12.04 LTS release has a terrible, barley useable window manager.

I’ve switched to Cinnamon, following the instructions here. Now it all works like it is supposed to.

Postscript site

Friday, August 27th, 2010

Here’s a site with a good Postscript library for drawing variable width lines.

To add a rounded end I added an arc command after the bolt function:
20 setlinewidth
newpath 0 0 moveto
0 -50 200 -150 200 0 rcurveto
currentpoint
reversepath bolt
5 0 179 arc
fill

I used two of these curves to draw a stylized pear.