Monday, April 16, 2012

Emacs Colors Begone

Thanks to Bjørn Hansen, I now know how to rid my Emacs of the annoying syntax coloring!

(setq-default global-font-lock-mode nil)

Monday, April 09, 2012

Database Dropped

If you're like me, you will someday experience that terrifying, dreadful feeling upon reading these words on your phpMyAdmin screen:

Database `whatever` has been dropped.

...having apparently ignored the warning that just appeared saying:

You are about to DESTROY a complete database! Do you really want to: DROP DATABASE `whatever`

...and blithely pressing Enter.

When this happens, and it will, there are a few things you should do:

  • refrain from panicking
  • take a few deep breaths
  • go back and time and BACK UP YOUR DATABASE
Fortunately, in my case, only the first two steps were necessary, because I use Time Machine on my MacBook and hadn't made any updates to the database since the most recent backup.

I should say that I'm running MAMP, and while I don't know if all MySQL databases are stored this way, I can't imagine there would be much a difference in how you would restore your own database from backup.

All I had to do was open the /Applications/MAMP/db/mysql folder in Time Machine, select the directory that used to be my database and click Restore. That's it.

And after popping into phpMyAdmin to make sure that my data was actually safe, there were just a couple more actions required:
  • thanking my lucky stars
  • vowing never ever ever to blithely click another alert without reading it.

Wednesday, March 07, 2012

Fun with words

What do each of the following have in common?

  • something
  • tenletters
  • eighteencharacters
  • two words

Sunday, March 04, 2012

layout.xml -> Activity.java

I made a bunch of changes to a layout file this morning and wished I had a quick way to get all of those elements into my java code so I could make it go. So I popped into Emacs and wrote a little function to do it! And here it is. Enjoy!
(defun xml-to-java ()
  (interactive)
  (progn
    (setq tmp (buffer-string))
    (switch-to-buffer "tmp")
    (insert tmp)
    (goto-char (point-min))
    (save-excursion
      (replace-regexp "[\n\t ]+" " ")
      )
    (save-excursion
      (replace-regexp
       " *<\\(\\w+\\)[^>]*android:id=\"@\\+id/\\(\\w+\\)\"[^>]*>"
       "\nprivate \\1 \\2;\n\\2 = (\\1) findViewById(R.id.\\2);\n")
      )
    (save-excursion
      (replace-regexp " *<!-- \\([^>]*\\) -->" "\n/* \\1 */\n")
      )
    (save-excursion
      (replace-regexp " *<[^>]*>" "")
      )
    (save-excursion
      (replace-string "\n\n" "\n")
      )
    )
  )

Thursday, February 23, 2012

Facebook Subscriptions

Here's another link I can never find when I need it... maybe you need it to!

Facebook Subscriptions

Very handy if you want to unsubscribe from annoying f-book friends.

Hat tip: Quora

Thursday, February 16, 2012

Google Calendar v3 Entry Update

Here's something that would make a nice addition to the Google Calendar Developer's Guide (v3)...

I've been trying to update an event and all I've been getting back is a cryptic 400 error, "unsupported output format" -- BIG HELP!!

Well maybe if it had said input format... I don't know what made me try this, but when I set the Content-Type header of my PUT request (application/json) -- IT WORKS!!

Saturday, January 28, 2012

HTTP Clients for Android

Android Developers Blog: Android’s HTTP Clients

I read the above post back in the fall and thought, "yeah yeah, I'm using HttpURLConnection, so need to think about this at all."

Well this week I found some odd, frustrating behavior and decided to try the Apache HTTP Client to see if it gave different results. And oh boy, does it -- it always just works!

OP Jesse says Apache has "fewer bugs" on Froyo, which is my target release. I guess I should have switched sooner. But now I have!