Category: Computers

Downloading a video from an ebay listing

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:


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

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
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
id -u jiml

URL forwarding

Forwarded my blog from my old server to this one. Added a Rewrite rule to httpd.conf on the old server in the main site <VirtualHost *:80> section:

RewriteEngine On
RewriteRule ^.*/blog(.*)$$1

Postscript site

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
reversepath bolt
5 0 179 arc

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

Putting video clips on my blog

Putting video clips on my blog was a bit harder than I expected. I first tried converting the .MOV files the camera writes into .avi files using ffmegX and posting them using <embed> tag code. The files showed up great on my Mac but not at all on a Windows computer.

Flash format files, .flv, are the easiest cross-platform way to post video clips. Flash does require that the site supply a Flash player. There are many Flash players available. I tried OS FLV and it worked nicely.

To edit video files I used avidemux, then ffmegX to convert them to .flv, and I put them on the site using the ‘noscript’ <embed> code suggested by OS FLV with the OS FLV player.swf.

Scanners for macro photography

Scanners can be used for macro photography, at least the ones with a great depth of focus. The scanners with CCD sensors tend to have a good depth of focus while the thin scanners with a CIS sensor can only focus on objects a mm or two from the glass.

I collected a list of scanners recommended for macro photography.

from here:
EPSON Perfection 3170
from here.
Microtek ScanMaker X6 EPP
Artec AM12S, AM 2400-U Pro
Epson Expression 836XL
3D Pro Scanner
Memtek Memorex SCF 9360P 3D
from here:
Epson Perfection 1240U Scanner
Epson Perfection 1200U

Checking specs, these also look well suited:
Epson Perfection 2480
Epson Perfection V300
Epson Perfection 2450
Epson Perfection 3490

256 colors in vim on OS X

Terminal colors are broken out of the box in OS X terminals. In part due to a poor OS X terminal implementation, part due to problems with vim. I try new colorschemes and get strange, random looking results.

After many fruitless searches I finally got 256 colors working in vim in a terminal. This post and the GVim site were very helpful. It turns out that the included Terminal app in OS X only supports 16 colors. The terminal background can be set to any color which confuses the issue. The colortest Perl script available on the Gvim site makes this clear.
OS X Terminal colortest:
colortest run in Terminal

The free GNU licensed iTerm terminal does support 256 colors.
iTerm colortest:
colortest run in Terminal

OK, now the terminal supports 256 colors. There are still some hoops to jump through to get vi to show colors though. Most colorschemes are built for gui (using 24-bit RGB colors), so vim needs to be built with gui support. This can be checked with :echo has(‘gui’). It reports 1 for yes, 0 for no. The vim I had (default or Fink installed) didn’t have gui support, so I downloaded GVim and copied it over the old vim:

cp /Volumes/Vim-7.2.148/ /usr/bin/vim

and now vim has gui support.

I copied /usr/share/vimrc to /usr/bin because the downloaded vim didn’t know to look in /usr/share and added a few configuration lines:

” Doesn’t get set right.
set t_Co=256

” Needed because the new vim doesn’t know to look in /usr/share
set runtimepath=~/.vim,/usr/share/vim/vim72_2,/usr/bin/vimfiles,/usr/bin,/usr/bin/vimfiles/after,~/.vim/after
let $VIMRUNTIME=’/usr/share/vim/vim72_2′

syntax on
colorscheme LightTan

OK, so now 256-color support works and I can set colorschemes. They still don’t look right because colorschemes made for the gui don’t look right on a 256-color terminal. There’s a great vim script called CSApprox that converts gui colors to the closest of the 256 colors and makes gui colors look pretty good in a terminal. Download it, unzip it, and copy files to the vim directory:
sudo cp plugin/CSApprox.vim /usr/share/vim/vim72_2/plugin
sudo cp autoload/csapprox.vim /usr/share/vim/vim72_2/autoload

and now when I load colorschemes they look pretty close to what the Vim colorscheme test site shows, with the only difference due to font differences.

To get full color support when I log into a linux machine I need to do some more setup. To get gui support in terminal:
yum install vim-X11
and then add to /etc/profile:
alias vi=’gvim -v’
and “source /etc/profile” to enable it.
and add:

set t_Co=256

if &t_Co == 256
colorscheme LightTan

to /etc/vimrc to force 256-color mode and pick a colorscheme.

I also copied the CSApprox files to /usr/share/vim/vim70 and now it works when I ssh to this machine as well!

Indie games

I ran across the independently produced game World of Goo. Fun game, the stylish graphics caught my eye.

So I wondered what was involved in creating a modern game. What’s done? Tech wise, graphics engine, physics engine, AI, etc. Art and sound. Looked around, found these two sites:

Indie Game Developer Links

Never found the a straightforward answer to my question though.


Reading the ‘how we made it’ articles on their site, it looks like World of Goo was made using the open source PopCap framework. PopCap includes two physics engines, the 2D Chipmonk Physics library and the 3D ODE physics library!