CentOS: httpd invalid command

Was configuring a CentOS 6 server recently, and I decided to comment out all httpd (i.e. Apache) LoadModule directives. Upon restart, there were several invalid commands, so I took the time to note ‘em down as it wasn’t obvious (to me, at least) which commands were provided by which modules.

I liken this to a cheat sheet to http://httpd.apache.org/docs/2.2/ then:


Invalid command 'AddHandler': mod_mime
Invalid command 'Alias': mod_alias
Invalid command 'BrowserMatch': mod_setenvif
Invalid command 'DirectoryIndex': mod_dir
Invalid command 'IndexOptions': mod_autoindex
Invalid command 'LanguagePriority': mod_negotiation
Invalid command 'LogFormat': mod_log_config
Invalid command 'Order': mod_authz_host
Invalid command 'TransferLog': mod_log_config

Android: FBreader screen grabs

I’ve bee doing quite a bit of reading nowadays. Every now and then I happen upon good writing. These resonate with me, so instead of taking a screen capture, I’m re-posting here instead where someone, someday might perhaps admire (and go read the book). This is a sticky post, so it’ll be updated as I slowly move these into text…

The Cuckoo’s Calling (Robert Galbraith): A lie would have no sense unless the truth were felt as dangerous.

The Elfstones of Shannara (Terry Brooks): Give thought to the purpose for those questions. Give thought to their source. Hurt gives way to bitterness, bitterness to anger. Travel too far that road, and the way is lost.

The Elves of Cintra (Terry Brooks): Her presence comforted him as nobody else could, and he was grateful for her beyond anything worlds could express.

Ender’s Game (Orson Scott Card): I didn’t want to see you. They told me. I was afraid I’d still love you. I hoped that you would. My fear, your wish — both granted.

Ender’s Game (Orson Scott Card): I am not a happy man, Ender. Humanity does not ask us to be happy. It merely asks us to be brilliant on its behalf. Survival first, then happiness as we can manage it.

The First King of Shannara (Terry Brooks): Time stole away commitments and loosened ties. Friendship were reduced to tales of the past and vague promises for the future, neither strong enough to recover what was lost. But that was what life did – it took you down separate roads until one day you found yourself alone.

The First King of Shannara (Terry Brooks): That’s how it is with parents and children. Each disappoints the other n ways that neither recognizes nor intends, and it takes time to overcome that disappointment.

The First King of Shannara (Terry Brooks): But it marked you. For a time, but not in any lasting way. Perhaps it even helped toughen me. I don’t pretend to know. We grow as best we can under the circumstances given us. What good does it do to second-guess ourselves years after the fact? Better that we simply try to understand why we are as we are and then better ourselves by learning from that.

The Gypsy Morph (Terry Brooks): He says nothing in response, but words are not necessary when she feels the gentle squeeze of his hand over hers. He understands. He is happy, too. They walk for a long time, content just to be with each other, like father and daughter, like family. She thinks of them this way, of herself as his daughter, him as her father. There is more to family than shared blood. There is trust and friendship and commitment. She is only eight years old, but she already knows this.

A Knight of the Word (Terry Brooks): I was just in the neighborhood, and decided to stop by, share a few laughs, maybe see if you’re in the market for a boyfriend.

A Knight of the Word (Terry Brooks): The horror of what had happened enveloped and consumed him. It haunted his sleep and destroyed his peace of mind. He could not function. He sat paralyzed in small rooms far away from San Sobel, trying to regain his sense of purpose. He had experienced failure before, but nothing with consequences that were so dramatic and so personal. He had thought he could handle anything, but he wasn’t prepared for this.

A Knight of the Word (Terry Brooks): He cried often, and he ached deep inside. He replayed the events over and over in his head, trying to decide what it was he had done wrong.

A Knight of the Word (Terry Brooks): We are homeless in the streets and we are homeless in our hearts as well. We have no purpose in the world. We have no center. Our way of life was changed for us long ago, and it will never return.

A Knight of the Word (Terry Brooks): We are a people under siege, walled away from each other and the world, trying to fend a safe path through the debris of hate and rage that collects around us. We drive our cars as if they were weapons. We use our children and friends as if their love and trust were expendable and meaningless. We think of ourselves first and others second. We lie and cheat and steal in little ways, thinking it unimportant, justifying it by telling ourselves that others do it, too. We have no patience with the mistake of others. We have no empathy for their despair. We have no compassion for their misery.

A Knight of the Word (Terry Brooks): What we have in life we can count our own is who we are, and where we come from, she thought absently.

The Ocean at the End of the Lane (Neil Gaiman): An admission about myself: as a very small boy, perhaps three or four years old, I could be a monster. “You were a momzer,” several aunts told me, on different occasions, once I had safely reached adulthood and my dreadful infant deeds could be recalled with wry amusement. But I don’t actually remember being a monster. I just remember wanting my own way.

Running with the Demon (Terry Brooks): Doubts set in. Had he dreamed it all? Had he imagined her? Or worse, had he mistaken her intent? What if the great purpose he had envisioned, the purpose for which he had searched so long, was a lie? Doubts turned to mistrust. What if he had been deceived? He was beset by nightmares that woke him shaking and chilly on the hottest nights, sweaty and fiery on the coldest nights.

Ten Pieces of Inspiration #158 (Trent Hamm): Some of the biggest mistakes in my life have come from giving up on relationships because they happened to not be easy at the moment.

OS X: Icon^M file

When I use Terminal, I’ve noticed that the OS creates this Icon^M for folders that I created. It’s quite irritating (I’m not sure what it’s for), and Eclipse was choking on it last semester. I never figured out why until today. So apparently it is a custom icon (but I didn’t set one!), so I can delete ‘em via Terminal; e.g.

woteba:~ kzhiwei$ find . -name Icon*
./Icon
woteba:~ kzhiwei$ find . -name Icon* | xargs rm -rf

More reading: http://superuser.com/questions/298785/icon-file-on-os-x-desktop

Android: restoring app data via adb push

So after taking CI6230 I decided to encrypt my phone storage. I was running CyanogenMod (CM) 10.1.2, which is awesome. But I digress. So the encryption went fine. It took awhile, and things were A-OK until I decided to tinker with my phone — despite all of the horror stories and downtime I’ve endured (my colleagues can attest to that) and try Paranoid Android (PA) 3.94. I mean, we’re explorers aren’t we?

So I downloaded the ROM and Google Apps zip files after doing Titanium Backup (of course!) and copied everything to my Mac (in hindsight, this was what saved me, even though I didn’t realize it at that time), and then rebooted to recovery.

In recovery, I realized the storage couldn’t be accessed as it was encrypted. I seem to recall unrooting (and rooting) the phone, and then it wouldn’t even boot into the ROM. OK, so I’d rendered my phone unworkable (again). I was stumped for awhile, but luckily Google provides Nexus factory images and the Android SDK so I used that to reset things. Now I had a working device, but I was unhappy because my app data was now lost. All the save games… and then some.

So I figured that I could just flash PA and then restore using TitaniumBackup, as I’d always done before. The problem was, it didn’t work. I got a parse error message. I decided to ignore the error, and reinstalled via Google Play, following by a data-only restore; i.e. just the .properties and .tar.gz files. Now this caused the applications to crash, leading me to think that my files were encrypted. I was sidetracked by the fact that the applications crashed repeatedly, and Liya could only display the Liya the table structure, but there was no data.

So I pretty much did a ton of research trying to find out what happened:

https://santoku-linux.com/howto/mobile-forensics/how-to-brute-force-android-encryption

https://www1.informatik.uni-erlangen.de/frost

I even used openssl to attempt decrypt, since I remembered my pin, and I knew the cipher; e.g.

$ openssl aes-128-cbc -d -in financisto.db -nosalt -out financisto.db.clear

I am ashamed to note that I’m a noob. Vim gave me a hint, in that the DML was not enciphered. I could see something like ‘create table foo…’, but I ignored it. Then I realized then AES 128 ciphertext didn’t even look like what I had, and then I opened it using the sqlite3 tool:

$ sqlite3 financisto.db
SQLite version 3.7.7 2011-06-25 16:35:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from transactions;
1|1|0|0|0|0|Opening amount (MYR)|53400|0|1300572979084||0.0|0.0|0.0||0||||UR||0|1300572979086|0|0|0|0
.
.
.

OK, nothing was encrypted after all, but my apps wouldn’t work. The trick was to use adb push to individually push files into the device. It’s pretty tedious, but in the end it worked for me. Just tar -xof the .tar.gz, and then descend into data/data for the list of files to push over:

$ FOO=/data/data/ru.orangesoftware.financisto/databases/
$ BAR=financisto.db
$ adb push ~/Dropbox/Mako/TitaniumBackup/$FOO/$BAR $FOO

Setting the envvars will help things move along a lot faster, then after that you should have app+data.

Hope this helps some poor paranoid soul like myself sometime soon. Of course, your mileage will vary.

Android: XML layouts

So, I’ve been fiddling around w/ ADT for a couple of hours now. It’s possible to programmatically create layouts (i.e. an Android UI), but it’s not a great solution. It’s way easier to define the layout in XML, and then bind whatever event handlers are required. Here we have a simple class:

package com.waynekhan;

import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
import java.util.*;


public class HWA extends Activity implements View.OnClickListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);
Button b = (Button) findViewById(R.id.b);
b.setOnClickListener(this);
}

public void onClick(View v) {
switch (v.getId()) {
case R.id.b: {
Button b = (Button) v;
b.setText(new Date().toString()); break;
}
}
}
}

As you can see, it’s quite bare. Load an XML layout (R.layout.main), define a button (R.id.b) and then bind a click listener to said button. Then we have onClick() which simply sets the button text to the current String-ified date. Our code is really clean, and we do all the UI-related stuff in /res/layout/main.xml, and put all our conveniently l10n strings in /res/values/strings.xml. Unfortunately, I can’t post the content of the XML files, since WordPress groks ‘em and all I get is an empty code block.

Android: Developing w/ the SDK ADT bundle

This semester, I’m taking a course on Android development. So I’ll be posting a bit more Android-related stuff as we go along. I’m developing on the MacBook Air, so get comfy w/ the command line.

To get started, grab a copy of the Android SDK. The Android Development Toolkit (ADT) bundle is pretty awesome. It comes w/ Eclipse and the plugin all setup already:

http://developer.android.com/sdk/index.html#mac-bundle

I unzipped the .zip file in Downloads; i.e. /Users/kzhiwei/Downloads, so the full path would be something like:

/Users/kzhiwei/Downloads/adt-bundle-mac-x86_64

Now you need to connect up your Android device (I use the Nexus S). The truth is, the ADT plugin comes w/ the Android Virtual Device (AVD) Manager. So you could, theoretically emulate any Android device, but the emulated device takes too long a time to boot up, it’s insane not to use a real hardware device. You’ll need to setup Android debugging: Settings > Developer options > On > Android debugging. There are two other useful options here: Stay awake and USB debugging notify. I keep them on, but it’s not mandatory.

Now, we’ll need to find out what is our device serial number. Fire up Terminal, and navigate to /Users/kzhiwei/Downloads/adt-bundle-mac-x86_64/adt/sdk/platform-tools:

woteba:platform-tools kzhiwei$ pwd
/Users/kzhiwei/Downloads/adt-bundle-mac-x86_64/sdk/platform-tools
woteba:platform-tools kzhiwei$ ./adb devices
List of devices attached
3xxxxxxxxxxxxxxx device

I’ve masked out my device ID, of course. Just remember the starting digit, and then you are basically ready to start working w/ Eclipse. I do this by using the Finder, and then navigating to adt-bundle-mac-x86_64/eclipse. There’ll be an Eclipse.app somewhere, so double-click, and then wait a bit. Now we’re ready.

File > New > Android Application Project. Under Application Name and Project Name, input “Foo”. Under package name, input “com.wordpress.kzhiwei.foo”. So it’s basically my domain name in reverse, plus the app name (foo). Next we’ll need to define SDK levels. The defaults are good enough:

Minimum: Froyo
Target: Jelly Bean
Compile with: Jelly Bean
Theme: Holo Light w/ Dark Action Bar

Stay with me! Click Next (just use the defaults for the next few pages). You should see your newly created project (Foo) in the Project Explorer. Right-click the project, and then Run As > Android Application. The first time you do that, there’ll be an option to choose either an AVD, or an Android hardware device. We’ll check our device, of course, and then check “Use same device for future launches”, and then go. There’ll be some activity on the device, and then your new application should run. It just says “Hello world!”. Awesome, we are done here.

Hopefully I’m really hardworking and I’ll continue posting up stuff w/ real code in a bit.

Web: Google Reader send to Springpad

Awhile back I decided to start using Springpad for bookmarking and notes. It’s worked out pretty well so far (but it’s a bit slow).

Springpad has various ways of saving stuff; e.g. browser extensions, a bookmark-let, email but I was looking a way to feed stuff from Reader (which I love); i.e. without opening a new window, waiting for the page to load and then finally using either the extension or bookmark-let to save it to Springpad. It’s just so… slow.

So I extracted the URL from their bookmarklet, and I found that it works well w/ a custom Reader’s “Send to” option. There are a bunch of defaults (e.g. Blogger {of course}, Delicious, Instapaper) but none for Springpad. Fortunately, it is possible to manually setup a custom link. 3 fields are required: Name, URL and Icon URL, plus there’s some documentation about field mapping. If all this sounds a bit alien, that’s ok, here’s what you want for each field:

Name: Springpad
URL: https://springpad.com/clip.action?url=${url}&title=${title}
Icon URL: https://springpad.com/favicon.ico

Voila:reader-send-to-springpad

Follow

Get every new post delivered to your Inbox.