wesley tanaka

Tech

Turning an external monitor on by default in Ubuntu

()

To use a specific resolution, or turn on or off certain displays by default when you log in, you can create an .xprofile file in your home directory which runs xrandr commands.  For example, this .xprofile will turn on an external VGA monitor and set it to 1280x720 resolution and then turn off the internal LCD monitor on a laptop.

xrandr --output VGA1 --mode 1280x720
xrandr --output LVDS1 --off

Dropping partial InnoDB tables left from a crash

()

It's possible for MySQL to orphan temporary, partial InnoDB tables if the MySQL server crashes during an ALTER TABLE operation.

When this happened to me, I would get cryptic error messages when trying to create or drop certain tables, or create certain foreign key constraints, like:

mysql> CREATE TABLE foo (. . .) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
ERROR 1005 (HY000) at line [. . .]: Can't create table 'my_database.#sql-509_5a' (errno: 121)

Using a VPN in Ubuntu Linux when your network is controlled by ifupdown

()

According to this bug and this bug, it's not possible to use a VPN through NetworkManager (the GUI for managing networking in Ubuntu) if your wireless or ethernet networking is configured using ifupdown aka /etc/network/interfaces. An example of this situation is if you're using NFS shared folders in Vagrant.

Using a Cisco compatible (vpnc) VPN from the command line in Linux

()

There's a command line program, vpnc which can be used to log into a cisco-compatible VPN on the command line. Enter the server address for the "gateway address", the group name and group secret for the IPSec ID and IPSec secret, and then the username and password, and it will start a vpnc daemon process in the background that connects you to the vpn.

To install it:

sudo apt-get install vpnc

 

Robolectric in gradle

()

Robolectric is a unit test framework that allows you to test Android code in a normal JVM without an emulator. There are several versions of gradle plugins that are supposed to allow you to run robolectric tests in a gradle project, but none worked out of the box for me. Instead, this approach did:

Shared variables in Gradle's buildscript block

()

Gradle documentation on the internet has numerous examples of global variables that are defined at the top level of the file like this:

androidPluginVersion = '0.8.+'
buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "com.android.tools.build:gradle:$androidPluginVersion"
  }
}

adb force install

()

If you get Failure [INSTALL_FAILED_ALREADY_EXISTS] or Failure [INSTALL_FAILED_VERSION_DOWNGRADE] when installing an .apk on your Android emulator, you can run:

adb install -r -d path/to/the-debug-unaligned.apk

to force downgrading and replacing of the existing .apk package.

Elasticsearch Concepts

()

The Elasticsearch guide has a useful map from relational database terminology to Elasticsearch terminology:

Vagrant setup for Drupal on Ubuntu

()

Vagrant lets you run a single command, vagrant up which will download an operating system image, install it into Virtualbox, boot a virtual machine, and then run shell scripts or Puppet to install software packages or make other changes to the operating system after it boots up the first time.

Most compact way to store UUIDs in sqlite

()

If you want to store a UUID in sqlite and use the minimal possible amount of disk space, it seems like the best solution may be to represent each UUID as a 16 byte binary string and store it in a BLOB column.  I tested inserting 100,000 UUIDs into a table using three strategies with Sqlite 3.7.9, and the resulting file sizes were:

Syndicate content
by Wesley Tanaka