Friday, May 29, 2009
On Indianapolis
Wow, so Indy is actually a really fun city. It's big without feeling as cramped as cities like SF. If you ever travel to within 100 miles of Indianapolis, you are required to stop at Yats on College St. and try the amazingly cheap, amazingly good creole food. Seriously, what a cool place.
Friday, May 22, 2009
Skip every other frame with mencoder
Recently I sped up a video by dropping every other frame. Here's how to do it with mencoder: multiply the original video's framerate by 2, then specify the same fps as the original for the output fps. So mencoder starts by "playing" the original video at 2x speed, then has to drop every other frame to work with the "lower" frame rate:
mencoder -fps 60 -ofps 30 -ovc lavc -oac copy in.avi -o out.avi
mencoder -fps 60 -ofps 30 -ovc lavc -oac copy in.avi -o out.avi
Sunday, May 17, 2009
Android: millisecond resolution time
The only mention I could find of time in the android docs was android.text.format.Time. It has a tomillis() function that returns things in units of milliseconds, but the time only increments in values of 1 second, so that's pretty useless.
These guys mention android.os.SystemClock, which works for me:
These guys mention android.os.SystemClock, which works for me:
package com.example.benchmark;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.util.Formatter;
import android.os.SystemClock;
public class BenchmarkActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
long before = SystemClock.uptimeMillis();
long i, j=0;
for(i=0; i<23456780; i++) j+=i;
long after = SystemClock.uptimeMillis();
long millis = after - before;
Formatter f = new Formatter();
String foo = f.format("%d", millis).toString();
TextView tv = new TextView(this);
tv.setText(foo);
setContentView(tv);
}
}
Android: "ant install" complains about INSTALL_FAILED_ALREADY_EXISTS
The android docs about writing apps without eclipse say to run "ant install" to upload an app to the emulator that's currently running. What they don't tell you is that after you've tweaked your code and recompiled, running "ant install" again will complain that the application is already installed. You could use the virtual phone's Settings... Applications... Manage Applications... [click on your app]... Uninstall each time, but that sucks. There appears to be an "ant uninstall" command, but that doesn't actually remove the app on my emulator.
What they should have mentioned is that you can merely run "ant reinstall".
(The other thing the docs suck at is making it clear what classes are in what versions of the API. So for example, android.text.format.Time wasn't found when I picked --target 1 (the original API), and I had to start a new "hello, world" app with --target 3 before it'd work. Very frustrating for a new android developer).
What they should have mentioned is that you can merely run "ant reinstall".
(The other thing the docs suck at is making it clear what classes are in what versions of the API. So for example, android.text.format.Time wasn't found when I picked --target 1 (the original API), and I had to start a new "hello, world" app with --target 3 before it'd work. Very frustrating for a new android developer).
Wednesday, May 06, 2009
Behavioral confirmation
I was astounded to hear about this principle years ago, but could never remember the name. Apparently it's also called "expectancy confirmation". It takes a second to realize what's so amazing about the idea: when you expect somebody to behave a certain way, not only will you treat them differently, but *they'll subconsciously help you confirm your bias*. So expecting somebody to lie to you makes them more likely to actually do so!
http://books.google.com/books?id=m1O9PHDwfxAC&pg=PA86&dq=behavioral+confirmation
For such a mind-blowing principle, it's documented really poorly online. The book search result was the closest thing I could find.
http://books.google.com/books?id=m1O9PHDwfxAC&pg=PA86&dq=behavioral+confirmation
For such a mind-blowing principle, it's documented really poorly online. The book search result was the closest thing I could find.
Tuesday, May 05, 2009
Enable external monitor on a thinkpad t41 for older ubuntu linux
In newer ubuntu distros, the t41 laptops seem to do the right thing, but in this old feisty release I couldn't figure out how to turn on the external monitor. This did the trick:
aticonfig --enable-monitor=crt1
Friday, May 01, 2009
Ubuntu "a camera has been detected" dialog checkbox "always perform this action" doesn't work
Whenever ubuntu detects that you've plugged in a camera, it opens an annoying dialog box. It's sad that this bug still hasn't been fixed, since it's been known for so long. But here's what to do, as reported by hammer89 in this bug. I'm posting it here to make it easier to find:
It's amazing how many hits I've gotten on my "fix gutsy" post. It seems that lots of bug fixes don't get good visibility, so little public services like this are actually pretty useful.
Open a terminal and type gconf-editor ... then in the list on the left navigate to / --> desktop --> gnome --> volume_manager --> prompts... then change the value for "camera_import_photos" to "1"
It's amazing how many hits I've gotten on my "fix gutsy" post. It seems that lots of bug fixes don't get good visibility, so little public services like this are actually pretty useful.
Subscribe to:
Posts (Atom)