new “php-htm-mode” for emacs — intermixed PHP, HTML, JS, and CSS using multi-modes

I finally formalized, cleaned up, and packaged up my current emacs editing setup for files with intermixed PHP, HTML, JS/javascript, and CSS code all in the same file.  It uses an existing but rarely used technique called “multi-mode” and sets “trigger points” for switching the “major mode” of the buffer as your cursor moves through the code.

A nice thing about this approach is that you can always glance down anytime you are editing to see which mode you are in (or the emacs lisp code *thinks* you are in).  You can also fork/edit the single “.el” lisp file to add/update the triggers for various modes.

https://github.com/traceypooh/php-htm-mode

Screenshot:

screenshot of php-htm-mode
screenshot of php-htm-mode

Morgan Territory Motorcyclin’ — 85 mile east bay loop around Mt. Diablo with Honda CB400A “decaf”

After months of work, Russ finally gets his Ninja 600cc working!

Hunter, Russ, and I celebrate with an 85-mile day trip during the three day weekend around Mount Diablo, through the legendary Morgan Territory.

Ridden over: Oakland, Canyon, Moraga, Lafayette, Walnut Creek, Clayton, Morgan Territory, Danville, San Ramon, and home!

today I did my first oil and oil filter change, ever! (Honda CB400A “decaf”)

Russ and I changed our motorcycle’s oil and oil filters today.  This was the first time I’ve ever changed oil in a vehicle — I guess it sort of was a life goal I figured I’d never get around to — part of understanding cars/bikes more!   So it was a nice way to kick off the start of our 3-day holiday weekend.

The actual work on my bike was quite simple:

  • 1 ratchet-able bolt as the drain plug to release most of the used oil into oil drip pan
  • 1 ratchet-able bolt underneath to release the bike’s oil pan and oil filter section

 Russ helped figure out those bolts which I could confirm with a shop manual PDF.  Harder was sorting out what oil and filter to get/use and getting them.  I went with:

  • Valvoline SAE 10W-40 Motorcycle oil (for 4-strokes; non-synthetic; ideal for wet clutches) (AutoZone/Walmart)
  • K&N KN-111 oil filter (local motorcycle shop)

Putting everything back couldn’t be easier — slipped on new filter to bolt/cover, ratchet-ed the two bolts back in, and poured in ~3 quarts of oil.  I was happy parts were all in good shape and aside from some relatively dirty oil, no badness or surprises for my 35 year old bike.  Phew!

my first oil change
my first oil change
removing bottom bolt and filter
removing bottom bolt and filter
garage work overview
garage work overview

How to turn Time Machine from disk with many partitions to single partition (logically “extending” Time Machine partition)

The high-level answer is:  

  • use macosx Disk Utility
  • make a .dmg of Time Machine partition (to another disk)
  • wipe out disk
  • restore .dmg
  • extend partition to full size (or whatever size you want) of disk

Detailed steps:

  1. backup one last time with Time Machine
  2. turn off Time Machine via preferences
  3. open Disk Utility (builtin mac app)
  4. select the partition where your Time Machine backups are
  5. hit the “New Image” icon in top bar — use the default options (with “.dmg” suffix, no encryption)
  6. save the .dmg to another disk that has space (this takes awhile)
  7. once that’s done, you can re-partition using Disk Utility the disk that originally had your Time Machine partition on it.  (WARNING THIS WIPES OUT ENTIRE DISK AND ALL PARTITIONS!)  Select each partition on the disk and hit the [-] icon near the bottom of the partition list.  BE VERY CAREFUL AND MAKE SURE YOU HAVE IDENTIFIED THE RIGHT DISK!
  8. your disk is now empty…
  9. repartition the disk however you like — since Time Machine uses its own subdir, I suggest partitioning the disk to a single partition, full extent of the disk
  10. with the emptied disk still selected, hit “Restore” button/tab to the right
  11. find the .dmg you made previously as your Source
  12. drag the emptied partition (where you want Time Machine backups to go) to the Destination
  13. hit the “Restore” button (bottom right)
  14. it will ask you to approve scanning/verifying .dmg (yes/OK)
  15. (this takes awhile)
  16. resize your restored Time Machine partition to full disk (or whatever size you want)
  17. turn back on Time Machine backups
  18. approve the question about “disk has moved…”

PS: you can also you this technique to move an entire set of Time Machine backups from one disk to another disk (without losing all your backups!)

simple way to make h.264 mp4 web and iOS/mobile playable video mp4 files for linux and macosx using ffmpeg

Greetings video geeks! 😎

At my job, I’ve updated the process and way we create our .mp4 files that are shown on video pages on archive.org

It’s a much cleaner/clearer process, namely:

  • I opted to ditch ffpreset files in favor of command-line argument 100% equivalents. It seems a bit easier for someone reading the task log of their item, trying to see what we did.
  • I no longer need qt-faststart step and dropped it. I use the cmd-line modern ffmpeg “-movflags faststart”

Entire processing is now done 100% with ffmpeg, in the standard “2-pass” mode
As before, this output .mp4:

  • plays in modern html5 video tag compatible browsers
  • plays in flash plugin within browsers
  • works on all iOS devices
  • makes sure the “moov atom” is at the front of the file, so browsers can playback before downloading the entire file, etc.

Here is an example (you would tailor especially the “scale=640:480” depending on source aspect ratio and desired output size; change or drop altogether the “-r 20” option (the source was 20 fps, so we make the dest 20 fps); tailor the bitrate args to taste):

  • ffmpeg -y -i stairs.avi -vcodec libx264 -pix_fmt yuv420p -vf yadif,scale=640:480 -profile:v baseline -x264opts cabac=0:bframes=0:ref=1:weightp=0:level=30:bitrate=700:vbv_maxrate=768:vbv_bufsize=1400 -movflags faststart -ac 2 -b:a 128k -ar 44100 -r 20 -pass 1 -acodec aac -strict experimental stairs.mp4;
  • ffmpeg -y -i stairs.avi -vcodec libx264 -pix_fmt yuv420p -vf yadif,scale=640:480 -profile:v baseline -x264opts cabac=0:bframes=0:ref=1:weightp=0:level=30:bitrate=700:vbv_maxrate=768:vbv_bufsize=1400 -movflags faststart -ac 2 -b:a 128k -ar 44100 -r 20 -pass 2 -acodec aac -strict experimental -metadata title='”Stairs where i work” – lame test item, bear with us – http://archive.org/details/stairs’ -metadata year=’2004′ -metadata comment=license:’http://creativecommons.org/licenses/publicdomain/’ stairs.mp4;

Happy hacking and creating!

PS: here is the way we compile ffmpeg (we use ubuntu linux at work, but this script works on macosx, too).

honda CB400A — fixing turn signal and neutral LEDs (to new speedometer)

Whups, my new speedo’s turn indicator LED was only going on when left signal was running.

Thankfully, found this post on hondatwins that mentioned the orange and light blue bike lines were actually active lines for when left or right turn signal was on — not that they were positive and negative general lines. It also mentioned a (cheap/simple, yay!) fix to use two 3-amp diodes and tie them in together. A quick putt-putt to Radioshack and $2 later…

Success!

I focus mainly on that in this image, but also some other related notes.

annotated picture of wiring behind headlight

 

I also have my new speedo’s neutral LED light now turning on when bike is on (but not running) — will see tomorrow if it *also* properly goes *off* when shift up when bike is running.

decaf 1978 honda CB400A speedometer and instruments replaced!

OK, so I sorted out all my re-wiring and was able to replace my stock honda huge instrument cluster with a much smaller and streamlined single mini-speedometer with four instrument lights combined in it.

I used a CB400A wiring clymer manual image that I found online to sort out which wires connect where. I also cleared up quite a few wire clusters that no longer needed to leave the headlight wire storage area and made space for the new connections.

VERY satisfying! Can’t wait to fire her up tomorrow and hopefully the speedo/odometer work properly and track accurately. The indicator lights I could test (blinkers, hi-beam, as well as instrument backlight) work. Will see if my neutral light works tomorrow too (and hopefully will not see the “oil pressure” light come on ever 😎 )

replacing CB400A instruments to smaller cafe racer style

Today I did much more than I thought I would — I pulled out and disconnected all instruments and relocated the ignition/key switch.

The plan is to combine the current speedometer/odometer with four of the seven indicator lights (neutral, high beam indicator, oil warning light, turn signal indicator) into a smaller chrome combined unit, and just plain omit the other three lights (parking brake, 1st gear, 2nd gear).

Now that I’ve done more than I had planned (“oh, maybe just two bolts today to see if I can figure out more what I’m up against…”) it is time to order parts! 😎

decaf! Honda CB400A automatic cafe racer. I’ve been a bad girl today….

Today Hunter helped me inspect, test-drive, buy, and drive 100+ miles home from a mom-n-pop custom bike modifier in California’s central valley.

We avoided the 5 and all freeways and started out with about an hour of “country roads” and farm roads that were mostly straight and flat. Next we nearly ran out of gas but recovered thanks to the “reserve switch” to fillup in Tracy. Finally, we started the fun curvy and up-and-down stuff through the northwest backside of Mt. Diablo and had a late lunch in Clayton. We wrapped it up through Moraga, and then our favorite twisty mountain pass up Pinehurst to Skyline Blvd and home

What an wild day!

I’ve named her “decaf” since she’s an automatic (with just “lo” and “hi” gears, no clutch) *and* a cafe racer style modified bike. I’m really pleased she did so well on the first ambitious ride all the way home.

Here’s some bike porn / pix!

20121013-200557.jpg

20121013-200621.jpg

20121013-200645.jpg

convert yuvj420p to yuv420p (chrome playable!) mp4 video (eg: canon/nikon video)

hooray!

found a nice (video lossless, best i can tell) way to convert the video from cameras like my Canon ELPH SD1400,
which is *already* h.264 video + PCM mono audio

to a new mp4 container with aac audio. that part’s easy/cake w/ ffmpeg — but the trick to get the h.264
video part to play in chrome browser and/or with a flash plugin is to get the flagged “yuvj420p” colorspace pixels
to be considered “yuv420p”. it seems like the former is >= 8 bits-per-pixel and has a range wider than the 256 values;
while the later is 8 bit per pixel. ( brief info/notes/background )

at any rate, finally found this nice post:

https://blendervse.wordpress.com/2012/04/02/waiving-the-fullrange-flag/

which refers to this modified MP4Box/gpac tree, to switch the “fullrange” color-related flag off:
https://github.com/golgol7777/gpac

and then, voila! i have a nice little script where i can convert my canon ELPH videos to a html5 video tag and flash plugin compatible mp4:


#!/bin/bash -ex

IN=${1:?"Usage: [input video] [output video]"};
OUT=${2:?"Usage: [input video] [output video]"};

# make a hacked version of "mp4box" that can toggle a colorspace-related flag in our video!
if [ ! -e $HOME/scripts/mp4box ]; then
(git clone https://github.com/golgol7777/gpac.git && cd gpac) || \
( cd gpac && git reset --hard && git clean -f && git pull && git status );

./configure --enable-pic --static-mp4box --enable-static-bin
make -j4;

# bonus points: make a *static* binary so if we change linux/OS versions, dont hafta worry!
cd applications/mp4box;
gcc -o $HOME/scripts/mp4box -static main.o filedump.o fileimport.o live.o -L../../bin/gcc -lgpac_static -lm -lpthread -ldl -lz
fi

# demux
ffmpeg -y -i "$IN" -an -vcodec copy video.mp4;
ffmpeg -y -i "$IN" -vn -acodec copy audio.wav;

# convert yuvj420p to yuv420p the cheater way (for chrome and flash plugin playback!)
rm -fv tmp.mp4;
$HOME/scripts/mp4box -add video.mp4#:fullrange=off tmp.mp4

# convert wav audio to aac
ffmpeg -y -i tmp.mp4 -i audio.wav -acodec libfaac -ac 1 -ab 256k -vcodec copy t2.mp4;
qt-faststart t2.mp4 "$OUT";
rm -fv video.mp4 audio.wav t2.mp4 tmp.mp4;