How to browse PHP’s print_r output the right way

16 06 2010

I’ve had the pleasure recently of working with some complex object oriented PHP with massive objects or lists of objects. The easiest way to have a look at your data for analyzing and debugging is to print_r it. Unfortunately, skimming through this data can be tedious, especially if you want to skip a couple of large, nested objects that are irrelevant to your data analysis.

When programming, I always keep Notepad++ open so I can keep a bunch of data accesible in tabs, such as notes, texts, data files, etc (and my tabs of saved files are seamlessly preserved between sessions, which is critical, of course). Notepad++ can handle bunches of different file formats out of the box, but PHP print_r isn’t one of them.

So I’ve pasted my print_r output into Notepad++, and the new file language is “Normal Text”. Immediately, bracket matching/highlighting works, which is great. I can go to an opening parens and see where it ends. So that’s it, right? Well, Notepad++ can also do code folding, like when you’re browsing a class, and you want to see all the class functions without all that pesky function code cluttering your view. So if you’ve got a PHP file open, for example, you can either click the [-]  to the left of the code to fold that function, or go to View->Fold All, and then just click [+] to open the class and see the top-level items in the class in plain view.

So what about the print_r? Matlab! I haven’t used Matlab since my first or second year in engineering school, and never thought it would useful, but here it is. I don’t remember what the code looks like, and I don’t care. All I know is that when I select Language->Matlab, it let’s me do code folding on my print_r output, and that’s all that matters. A bunch of the other languages work well too, or the same as Matlab, but it was the first and best for my needs.

FYI, this breaks if you have variable data containing a chunk of text with newlines and whatnot, but so it goes.





How to play an .asf stream on the iPhone/iPod Touch

24 10 2009

I loved adding my Shoutcast, AOL Radio and Last.fm apps to my iPod, but I was bummed when I couldn’t play my favorite O&A stream on my Touch, because it was in .asf format. I’ve never been one to pay attention to file format. I mean, if my winamp lite couldn’t play any audio, Iwas sure there was a plug-in for it. But this darn iPhone…

Anyway, I looked for a bunch of solutions, but none of them worked. I gave up and tried again a few weeks later, and noticed something out the corner of my eye.

My video re-streamer, the only damn solution I could find to being able to browse my network and play networked files, supported re-streaming Internet Radio too, in any standard format my computer can play/decode. Thank you again Orb/Orblive !

It took me a while to figure out how to add it – I did it through the browser, but then I realized I can do it from my iPhone app. Anyway, thanks for almost getting it (almost) right iPhone.

[Yeah, I upgraded from my $12 mp3 player to a Touch - it just made sense for replacing my Palm Pilot too]





What do you get from budget ($12) mp3 players?

11 04 2009

Pretty much what you pay for…

For several years now, I’ve been using my Tungsten Palm for listening to MP3s. I liked being able to test out a few software players, and find one that matched the features I was looking for (I used a combination of pTunes and TCPMP - I especially liked how each would hold my place, so I could pick up where I left off on more than one audio playlist).

Problem was, I went through several Palm devices, mostly because the audio jack was not cut out for extended use, and I’m no good at soldering. The most recent time I lost my MP3 capabilities, I turned for the cheapest solution I could find. I looked online, and found the least expensive 2GB player I could find in Israel (it’s actually gone up in price since I bought it). At about $12, at least I got an inexpensive 2GB stick, and if the MP3 part works too, well I’m good to go.

Here’s my rundown:

  1. Size
    At a little bit larger than my top thumb knuckle, this little sucker is a breeze to carry around without thinking (the ear-buds are the inconvenient part of this mini wonder). Since I’m used to my bulky Palm which I now leave at home most of the time, I’d say I’m ahead here. And with a street name (there’s no branding on the device whatsoever, but I did some research and found some similar looking things online) the Clip, it often stays snugly hanging off my front pocket.
  2. Storage
    It’s got the same space as the SD Card in my Palm. But not all memory is created equal. The player connects to my computer via USB, no problem, but the write speed is atrocious. I think it slows down my computer in general when it’s connected, but certainly any disc access suffers. Deleting and copying data takes at least 10X the equivalent SD transfers using my built-in card reader.
  3. Power
    I use both outlet and USB charging for both devices, but the Clip won’t let me listen while it’s plugged in. Charging goes quite quickly (15-30 minutes for a full charge), but only lasts about 2.5 hours. That means when I’m listening to my 4 hour radio shows, I get more than halfway, then I have to stop, charge, and go again.
  4. Interface
    I already told you about the software on the Palm – the Clip has no screen, and what looks like a wheel, but is actually just 5 buttons for play/pause, volume up, down, forward, and back. And since advancing forward is so common, such as when I want to skip to a track I like (click, click, click) or fast-forward (click and hold tight), that forward button is almost dead. The most frustrating part is when dealing with that forward button – if I accidentally double-click when in the middle of fast forwarding, I skip to the next track, and need to click once to go back, and hold it down all over again. And the fast forwarding is maybe 2X, so you can forget about scrolling to the end of a 4 hour show. I have to pre-slice these recordings every 10 minutes, just in case I lose my place.

After a few weeks, I feel that I already got what I paid for. Maybe I’ll splurge soon on the $25 devices with a screen and see how it goes.








Follow

Get every new post delivered to your Inbox.

Join 261 other followers