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)

I'm not sure what version of Emacs that was for, but here's what I had to do (a couple times, actually) in version 23.1.1...

M-x global-font-lock-mode

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...

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!

Sunday, January 22, 2012

Android Emulator | Android Developers

I can never find this when I need it, i.e. when I forget which keys simulate the menu and search buttons. Note to self, they're F2 and F5.

Android Emulator | Android Developers

Friday, January 06, 2012

(Semi-) Auto-complete your declarations

Too lazy to type the class name of the variable you're declaring? Or maybe you can't remember the exact name of the class.

Well let's say you're declaring and assigning, like this:

SomeTypeName foo = something.getFoo();

But you can't remember the SomeTypeName part. Try this instead:

String foo = something.getFoo();

Eclipse will underline the error (oh yeah, you have to be using Eclipse, but who isn't??) and all you have to do it press Ctrl/1 (or Cmd-1 if you're on a Mac) and the quick fix will pop up,

Change type of 'foo' to 'SomeTypeName'

Just hit Enter and you're done! You're welcome!! :)

Saturday, December 10, 2011

SQLite.delete with args workaround

This Android SQLite code wasn't working:

    getContentResolver().delete(LogProvider.URI, LogDatabase.COL + " < ?", new String[] { Long.toString(lval) });

But this code does:

    getContentResolver().delete(LogProvider.URI, LogDatabase.COL + " < " + Long.toString(lval), null);

Don't know if it's a bug in SQLite or in the way I was calling it. Doesn't matter, it's an easy enough workaround. Hope this saves somebody else some trouble!

Monday, December 05, 2011

Ballot Experiment

GraniteGeek at the Nashua Telegraph is doing an experiment with multi-choice ballots, and anyone can participate! Wish you could endorse Buddy Roemer's effort to get money out of elections? Afraid to vote for the candidate you truly like best because you would be "throwing your vote away"? Here is a chance to play with a system that fixes all that... Give it a try!

Survey

Friday, October 14, 2011

how to get screen to stay on when plugged in? - Android Forums

Want to listen to music with your Android device plugged in and keep the screen from shutting off? I did, and it was driving me crazy! I found the answer at Android Forums -- it's in Settings under Development, of all places!!

Thursday, October 06, 2011

createElement + iframe = NO

Don't use createElement to create IFRAME elements.

IE doesn't like it. Click here for the details and a workaround.

Wednesday, August 31, 2011

Droid2 Unrooting

I'm unrooting my Droid2 in case I ever need it to have that new-droid smell.

Anyway, here are some links I found useful:

Here are the instructions for getting RSD Lite and the SBF file you need:
http://droid2hacks.com/droid-2-hacks/how-to-unrootunbrick-droid-2-back-to-factory/

And here is a tip on what to do when you're stuck at "Please manually power up this phone" -- just go back into the bootloader (up-arrow/power) and plug back in if you became unplugged. Part of my problem may be that I was running under Parallels and I goofed when it asked me to retain the USB connection to the phone.

Anyway, here's the other thing. When you're done, if you go to your settings and it has forgotten your phone number, no need to panic. From here I learned that by dialing *228 and hitting SEND you'll connect to the automated programming system. You'll hear stuff in the earpiece but if you pull the phone away from your face, you'll actually see the phone telling you it's being programmed. As in activated.

And Here's something else I didn't know. When I was done, I still had all of my apps. I'm not sure how this is possible. I expected everything to be wiped out. Did I do it right? Did the flash really happen? I'm assuming that it did, since my phone had to be reactivated onto Verizon's network. Oh well, it does seem to have worked!

Thursday, August 11, 2011

Add UIBinder widget to root panel

This page from the GWT doc is very helpful for getting start with UIBinder.

And they give this example for adding your UIBinder object to your application:

Document.get().getBody().appendChild(helloWorld.getElement());

Maybe that's OK for an HTML UIBinder. I haven't tried that.

Instead, I was using GWT widgets in my UIBinder, and I wanted to add a ClickHandler to one of my buttons. But nothing ever happened when I clicked it. Turns out, as I read on Stack Overflow, that indeed the handlers aren't initialized properly unless you add to the root panel.

So here's what I did that worked just fine:

RootPanel.get().add(helloWorld);

Thanks, Hilbrand!

Wednesday, August 10, 2011

Got default constructor?

got this error?

was not included in the set of types which can be serialized by this SerializationPolicy

could be you're missing a default constructor, like I was.

thanks, holyjeez!!

Sunday, July 31, 2011

sls (combination of ssh and ls)

Here's a little bash script I just wrote and thought somebody might find useful. I'm always moving files around using scp and also needing to ssh around to ls them. So why not combine the ssh and the ls into sls -- just like scp, right?

Here are the usage and help text...

usage: sls [ls-option]... user@host[:file]...

sls is a magical combination of ssh and ls. Simply give the sls command some (or no) ls options and one or more remote locations and you'll get a listing for each. The remote spec is the same user@host:file specification you would use with the scp command, and the file part is optional.

And here is the script itself. If you have any fixes or improvements, please let me know.

p.s. Blogger, when I write a post in HTML, please let me edit it the same way... thank you. And to visitors from the future, if you find yourself needing to edit your HTML-written post, it's actually easy now that I think about it. Just ask your browser to show you the source, grab what you need, and paste that back into the post editor.

Thursday, July 28, 2011

Deploying GWT

I'm ready to try deploying my GWT app to WLS... so how u do dat?

I found a handy how-to on elitecoderz.net.

Thanks, Erik!

Tuesday, July 26, 2011

GWT widgets with radio buttons

Here's something I learned today.

First the problem, which was that setValue didn't seem to be doing anything -- my radioButton's weren't getting set. This isn't actually true. It turns out that if I scrolled down, one of the radio buttons on the page WAS getting set. Can you guess what was going on? That's right, all of the radio buttons from all sets all had the same name.

Heres the lesson: If you make a GWT widget that has radio buttons in it, and you use more than one of these widgets on a single page, you're going to need to make the name of each radio set unique.

And my solution: What I did was to use the hashCode of the panel that contains the buttons, and this worked just fine.

You're welcome!