Log in

No account? Create an account
Ryan's Journal [entries|friends|calendar]

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

Convert 720p/ac3 mkv to 720p/aac iPad-compatible mp4/m4v on Mac OS X Snow Leopard [29 Jul 2010|11:47pm]
# Video is not transcoded, just demuxed/muxed
# Audio is downmixed to stereo with DRC 
# You need these tools:
# * mkvextract (to demux the Matroska file)
#   * http://www.bunkus.org/videotools/mkvtoolnix/
#   * Just install through MacPorts, it doesn't pull in anything annoying
# * a52dec (to decompress and downmix the ac3)
#   * http://liba52.sourceforge.net/
#   * Compile from source
# * faac (to recompress the audio to mp4a/aac)
#   * http://www.audiocoding.com/
#   * Compile from source
# * MP4Box (to remux into MPEG-4 container) 
#   * http://kurtnoise.free.fr/mp4tools/
#   * Pre-compiled standalone OS X executable

mkvextract tracks ${BASE}.mkv 1:${BASE}.ac3 2:${BASE}.264
a52dec -o wav ${BASE}.ac3 > ${BASE}.wav
faac -b 96 --mpeg-vers 4 -o ${BASE}.aac ${BASE}.wav
MP4Box -add ${BASE}.264:fps=23.976 -add ${BASE}.aac ${BASE}.m4v
rm ${BASE}.{264,ac3,wav,aac}
Update: Here's a gist of an mkv2m4v script that automates the process: http://gist.github.com/502844
7 comments|post comment

repos.rb [04 Oct 2009|01:36pm]
The RubyCocoa project makes Ruby an incredibly powerful scripting language in Mac OS X.

As an example, here's a script that I used to rearrange windows when switching between various monitors. Based on the width of the main screen (something which I couldn't find a robust way to query outside of the NSScreen Cocoa API), it applies my preferred size and positioning to specific windows I care about. If you run it with '-q', it instead dumps a structure with those windows' current sizes and positions, for feeding back into the script as configuration.


Source code follows …Collapse )
2 comments|post comment

Dollhouse [15 Jan 2009|07:10pm]
Somebody remind me in early Feb to set MCE to record Dollhouse. It's not showing up in the guide yet and I'm afraid I'll forget.
post comment

Livejournal lays off 70%, including all tech staff [06 Jan 2009|10:15am]
Backing up my LiveJournal with LJDump http://bit.ly/OkR2 due to their 70% layoff http://bit.ly/knUB (thanks, @jeresig).
post comment

Finished Buffy [20 Oct 2008|01:30pm]
Finished BtVS.

My reactions, with mild spoilers ...Collapse )

Oh, and as far as I know, angel_grrl never warmed up to it in the least. Still loathes Buffy and friends with every fiber of her being.
5 comments|post comment

(ido-mode 1) [25 Sep 2008|04:27pm]
Ok, remember when I had a cow about how cool iswitchb is?

How is that no one mentioned ido?

Think iswitchb on crack. For files. With history. With fuzzy matching.

Imagine this:
Read more...Collapse )
That's right, it went and found a system header file for me. I only had to find the first one, then it remembered that files I want might live there. No config, no project files, no tag files, nothing. <3 <3 <3
post comment

Buffy DVDs [21 Sep 2008|07:08am]
Um, the Buffy DVDs kind of suck. There's no "play all", and there's no chapter break right after the credits. Anyway, no commercials (unlike Hulu), so still a net improvement.

Update: I forgot to mention the annoying transition animations.
post comment

Objective-C: Does it grow on you? [04 Aug 2008|01:17pm]
(Warning: This represents a mid-learning rant. Opinions are probably under- and misinformed, and subject to change. If you love Objective-C, please tell me why and give me hope.)

So far, only a couple hours into my relationship with Objective-C, I hate it. Perhaps worse than C++.

Mostly, I'm frustrated at weird conventions that work around seemingly braindead problems with the language.

Like the whole weird first argument thing, where convention says you slap WithX onto the message name, so you end up with something like

[locationManager updateWithLatitutde:lat longitude:long]

Then there's the whole issue that in the prototypes you're defining message passing with named parameters, in effect, but you don't get a binding on the parameter name, it's SEPARATE, and convention shoves 'a' in front of the natural var name:

-(void)updateWithLatitude:(float)aLatitude longitude:(float)aLongitude;

It's also plagued with huge flat namespace issues.

In any case, right now I hate brackets.

I can't believe it's 2008 and I'm going against my conviction to never bother learning another language without first class functions and lexical closure.

On the upside, at least there's duck typing and message forwarding. At least, if you can penetrate the syntax.

For anyone who's come out the other end of this tunnel, did you eventually come to enjoy Objective-C or is it just the ugly cross-bread stepchild of C and Smalltalk that should have died with NeXT instead of getting dragged back into OSX?
1 comment|post comment

jQuery sparklines [30 Jul 2008|11:32pm]
The sparklines plugin for jQuery is really cool. But since I'm using it on my admin dashboard, I can't show it to you in action. :-)
2 comments|post comment

How to mitigate CERT VU#800113 on OpenBSD [21 Jul 2008|07:18pm]

New poisoning attack, out early: VU#800113

If I've helped you set up an OpenBSD router, you are vulnerable.

ssh to your router and edit named.conf:

su -
emacs -nw /var/named/etc/named.conf

Modify the options {} block by adding the lines below, which will forward all queries for non-local zones to OpenDNS, who isn't vulnerable to this attack:

forward only;
forwarders {;; };

Restart named:

pkill named

Verify that you've fixed the issue:

ryan@belal ~ $ dig +short porttest.dns-oarc.net TXT
" is GOOD: 26 queries in 0.6 seconds from 26 ports with std dev 17317.56"

If you see POOR instead of GOOD, you're still vulnerable.

UPDATE: xyon points out that you might need to ignore the DNS servers coming down from your ISP via DHCP. Edit /etc/dhclient.conf:

supersede domain-name-servers

Then restart dhclient:

ps aux | grep dhclient # remember the external interface like fxp0 or dc0 or whatnot
pkill dhclient
dhclient fxp0 # or whatever your external interface was

You can check to make sure it worked by looking at /etc/resolv.conf and make sure the only nameserver line is:


UPDATE2: You'll probably want to go to www.opendns.com and sign up for an account to turn off their proxying features.

3 comments|post comment

Games for Children [29 Jun 2008|11:40am]
It seems that a common theme of games for young children is a highly restricted nature. This makes sense. The purpose of early childhood games is mostly to teach children what a game is, how to follow rules, what it's like to win and lose, etc. By restricted, I mean that there is generally a very small branching factor -- for example, in Sorry the only choice you have is which of your four pawns to move, and often there's no choice at all. About the most interesting game we play so far is Mexican Train Dominoes.

What I don't like about these games is that the outcome is largely random - in essence, the games almost play themselves. I'm wondering if there are good examples of early games that aren't essentially random. I might try out backgammon and checkers, but those are quite a step up from dominoes. I think backgammon would be easier to teach, since its long-term goal is easier to understand and translate into short term goals.

An interesting question is whether chess is right out at this point. Is it good to introduce the pieces at an early age so that children can internalize their movements, or to hold off to the point where they might be able to grasp some of the subtleties of the game. I remember being taught chess as a child and thinking that since I knew how the pieces moved, I knew how to play. Nothing, obviously, could be further from the truth.

Now that it's summer there will likely be a lot of time for game playing. What games did you like to play as a child? Which of them were random and which taught that choices affect outcomes?
11 comments|post comment

Using exiftool to fix busted EXIF [12 Apr 2008|09:14am]
I have a large back-log of photos sitting on my mass storage, basically since the kids were born.

I've been working on how to get the stuff out of my private gallery2 instance and onto Photosleeve. One challenge is that some of my EXIF data is inconsistent. Specifically, we rotated some of our original images in a way that did not reset the EXIF Orientation tag. So in newer, savvier, orientation-aware image viewers (like ZoomBrowser or, in fact, Photosleeve) the image gets double-rotated.

As a quick fix, I've just cleared all the Orientation tags on Tall photos.

I did it with almost no effort, thanks to the incredibly wonderful exiftool, which can happily say I've put to use as a stand-alone perl script, a perl library, and a stand-alone Windows EXE.

Anyway, here's the awesomeness:

find . -name \*.jpg -print0 | xargs -0 exiftool -n -if '$File:ImageHeight > $File:ImageWidth' -IFD0:Orientation=

The inherent sexy power of the -if construct is thrilling. It also does super cool stuff like let you offset all the date-related tags by an hour with -AllDates+=1:00.

Don't leave home without it.
post comment

Daniel Day-Lewis == Hugo Weaving [09 Apr 2008|12:46am]
Just watched There Will Be Blood. Did Daniel Day-Lewis's voice remind anyone else of Agent Smith (Hugo Weaving) from The Matrix?
post comment

EXIF orientation - math or lookup? [02 Apr 2008|01:54pm]
EXIF orientation numbers are kind of random. Starting at "normal", here's the number of 90 degree clockwise rotations needed to fix an image:

1 (0) -> 6 (1) -> 3 (2) -> 8 (3) -> 1 (0 mod 4)

So I've got these stuffed into a list (1, 6, 3, 8) and traverse it mod the length to figure out what to do when someone wants to rotate a photo clockwise or counter-clockwise.

Is there some mathy way to avoid the list in this case? For a moment I thought it was just (5*i % 8) + 1 given index i. Although that works for 0 -> 5 -> 2 -> 7, unfortunately 7 + 5 mod 8 ain't 0.
3 comments|post comment

Estimate value of pocket change by volume? [31 Mar 2008|12:14pm]
Google fails me.

Anybody know of a tool or guideline or something that will tell me about how much the slightly more that 2 quarts of pocket change I've accumulated in my bank might be worth? Obviously it would have to make some kind assumption about the ratios of the coins to one another. I don't even know how reasonable this request is.
4 comments|post comment

Server Beach discount/rebate code [28 Mar 2008|07:32pm]
If any of you guys are looking for a web hosting provider, I've been really happy with Server Beach so far. I can refer you and we both get a rebate if you stay a customer for 3 months. They're reasonable but not super-cheap, so it might not be great for personal hosting. They basically just pre-load a box with Debian or RHEL, stick it on a static IP, and email you the root password. Anyway, my code is 6SFCS63VW8. If you have any questions about them, just let me know.
2 comments|post comment

I <3 Linux System Rescue CD [24 Mar 2008|02:10pm]
I have been very pleased with this Linux System Rescue CD. It's a gentoo based bootable ISO that has a host of great tools on it. I have used it several times for fdisk+ntfsresize and it's much handier than booting to a full distro LiveCD. It also has a bunch of different boot modes, including one to an autonuke program to clear off hard drives. Highly recommended.
post comment

[21 Mar 2008|10:55am]
wrexen has a nice write up of How to improve your Scrabble play
post comment

Latest emacs-snapshot renames *some* modeline faces [07 Mar 2008|01:54pm]
Today ubuntu auto-upgraded me to emacs-snapshot 20080228-2~gutsy. Oddly, my modeline became unreadable. Slight investigation shows that modeline, modeline-highlight, modeline-buffer-id have all had a - inserted: mode-line... However, modeline-mousable and modeline-mousable-minor-mode didn't. Weird.
post comment

SMTP forwarding based on sender with postfix on Ubuntu 7.10 [05 Mar 2008|07:50pm]

Ok, so I went ahead and played around with postfix to see if I could get it to forward the mail the way I wanted. This seems like a really bad idea on a true multi-user system, since I'm pretty sure it would let anybody on my box send mail as me simply by specifying my email address in the smtp envelope.

There's an article on setting up two postfix instances to do smtp forwarding where the assumption is that each account on your box should be magically transformed into a single outgoing smtp account. I was able to glean a lot of info from it, but it wasn't quite what I wanted.

I've got postfix 2.4.5-3ubuntu1. Docs suggest that I would have had less trouble with the TLS configuration in 2.5, but I didn't really feel like recompiling it.

Set up sender-dependent relaying

Create sender_dependent_relayhost, which maps sender addresses to outgoing servers (don't forget postmap).

# cat > /etc/postfix/sender_dependent_relayhost
ryandjohnson@gmail.com  [smtp.gmail.com]:25
ryan@innerfence.com     [server1.gambitdesign.com]:25
# postmap sender_dependent_relayhost

Require TLS for the relays

Create smtp_tls_policy that requires TLS with valid certs for our relay hosts. In part this is necessary to guarantee that our passwords aren't sent in the clear, since gmail doesn't support anything else.

# cat > /etc/postfix/smtp_tls_policy
[smtp.gmail.com]:25             secure
[server1.gambitdesign.com]:25   secure
# postmap smtp_tls_policy

Set up passwords

Create sasl_password that configures your username/password for each host.

# cat > /etc/postfix/sasl_password
[smtp.gmail.com]:25 ryandjohnson@gmail.com:nopaste
[server1.gambitdesign.com]:25 ryan@innerfence.com:nopaste
# chmod 600 sasl_password
# postmap sasl_password

Fix TLS certificate validation

We need to link in the openssl roots and take the smtp client process out of chroot. This kind of sucks, but I didn't really see any other way to do it.

# ln -s /etc/ssl/certs /etc/postfix/certs
# $EDITOR /etc/postfix/master.cf
-smtp      unix  -       -       n       -       -       smtp
+smtp      unix  -       -       -       -       -       smtp

Hook it all up in main.cf

# $EDITOR /etc/postfix/main.cf
+# Relay according to the sender address
+sender_dependent_relayhost_maps = hash:/etc/postfix/sender_dependent_relayhost
+# Turn on TLS for the smtp *client* (for relaying)
+smtp_tls_CApath = /etc/postfix/certs
+smtp_tls_policy_maps = hash:/etc/postfix/smtp_tls_policy
 smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
+# Use SASL authentication over smtp *client* (for relaying)
+smtp_sasl_auth_enable = yes
+smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
+# allow plaintext (over TLS)
+smtp_sasl_security_options = noanonymous

Fire it up, test it out

# postfix reload
# sendmail -f ryandjohnson@gmail.com -t ryan@innerfence.com
From: ryandjohnson@gmail.com
To: ryan@innerfence.com
Subject: test message

The quick brown fox jumps over the lazy dog.
# tail /var/log/mail.log

Be sure when you're testing it you view all the headers on the mail you receive, to ensure that you get domain key signatures, SPF passes, and all the other modern goodness which is really why you want to do it.

Next steps

Well, now it's time to figure out how to get mutt to do the right thing. I'm pretty sure that account_hook + envelope_from will save the day.

post comment

[ viewing | most recent entries ]
[ go | earlier ]