Use PHP to get all images in a folder

This:

$images = glob($directory . "*.{jpg,gif,png}", GLOB_BRACE);

is awesome.

Posted in Code, Tech | Tagged | Leave a comment

iOS Training: Day 2

This is going to be a short one. After spending a ton of time at a computer the last couple days, writing a blog post isn’t the thing I’m dying to do at the moment. [Ed: Nevermind. Got rolling and cranked it all out.]

We didn’t build as many apps today, but they started to get more in-depth. This morning we wrapped up some of the things we started last night using the iOS Core Graphics APIs. This involved creating a view and using code to draw vector graphics on the screen. We started out with concentric gray circles, and progressed to using the accelerometer to move the circles as you move the phone around in space. I later added the ability to change the color of the circles depending on the angle of the phone and the ability to change the background color by shaking the phone.

After that, we got into some more realistic, useful classes like the tab bar that is at the bottom of tons of iOS apps, which gives you one way to move between views in an app.

The next app we built was all about screen rotation. We learned how to handle orientation changes and how to rearrange views to fit both shapes of the screen.

The last app we worked on for the entire afternoon included our first introduction to the UITableView, which seems to be the basic building block of almost everything in iOS. The app we built basically created a table view of items. We then learned how to add, reorder, and remove items in the list. We also added a navigation bar at the top of the screen to enable us to edit items in our list. The code was pretty easily to implement, but extremely complex. It’s going to take a few more looks at it to really get the hang. [Ed: Nevermind. Got rolling and cranked it out.]

I wrapped up a little earlier today, because I was getting tired of being in the lab, so we bailed around 8 and shot a few games of pool before coming back to the rooms and relaxing with some TV. Hopefully I’m refreshed and ready to get it done again tomorrow. I think we’re tackling the camera first thing tomorrow morning.

Posted in Apple, Code, iOS Bootcamp, Tech | Tagged , , , , | Leave a comment

iOS Training: Day 1

Today was the first real day of class. Over the course of about 12 hours working, I went through the first six chapters of the book we are supposed to make it all the way through this week.

Today’s chapters got me through three different apps, two of which made it to my iPhone. Nothing super exciting, but it is definitely impressive to see how fast these things can be put together.

The first app we built is called Quiz. It basically has a button to show a question from an array and another button to show the answer to that question. Then you show a new question, and a new answer. So on and so forth. It was a good tutorial to learn about building interfaces and connecting them to the code through the Interface Builder, or whatever you call it now that it’s part of XCode.

The second program we built today was basically a console program with no interface that was kinda like an inventory app. It was a little more in depth on the code and introduced a lot of memory management stuff, but not being able to deploy it to my phone made it a lot less interesting.

Where Was I ScreenshotThe last program of the day was called Where Was I. This was where things started getting interesting. It included a map view and used CoreLocation and MapKit to acquire the device’s location and display it on map. After that, you can type a string into a text field and drop a pin on the map with that label. Again, nothing too complicated, but neat to see it all come together. After dinner, I went back to the lab and did some of the “extra credit” work on that project. I used some more functionality in MapKit to reverse geocode the location of my pin, and add the city and state to the pin’s label as a subtitle. I also added a segmented control to my map that lets me change the map type to satellite and hybrid, along with the standard map. It took me a couple hours to figure it out, but now that I know how it works, it seems pretty easy. It was nice to have the instructor there to get help with questions and help to find problems. It’s super impressive to see how quickly he could read the code and get oriented.

I got back to my cabin tonight around 10, and I’m sitting here watching a ballgame while I type this up. Even though it was such a long day, it really didn’t seem like it, so I hope the rest of the week goes the same way.

Posted in Apple, Code, iOS Bootcamp, Tech | Tagged , , , , | Leave a comment

iOS Training: Day 0

I left home in Indianapolis at 1:30 this afternoon and hopped a flight to Atlanta. After that, I took a one hour ride to Historic Banning Mills, Georgia, home of the Big Nerd Ranch. I got checked into my cozy cabin in the middle of nowhere around 6:30 and headed back to the main building for dinner. Most of the students had arrived by this point, and we had a nice dinner of spinach-stuffed chicken, mashed sweet potatoes, and broccoli.

After dinner, we went downstairs to the lab, our home away from home for the next five days, and did some quick introductions. I also got a look at the 300 page book we’re going to attempt to go all the way through in the next five days, and generally just chit chat with some of the other people in the class.

After introuductions, we went upstairs and shot some pool, in what could prove to be the last leisure time of the week. We’ll be kicking off the real business tomorrow morning at 8:30.

Posted in Apple, Code, iOS Bootcamp, Tech | Tagged , , , , | Leave a comment

Workout Plan

I’m developing a new plan to get healthy, and the biggest part of that is a workout plan. I decided that coming up with something super-specific that has every single day planned out has been a losing proposition every time I’ve done it, so here’s what I’m going with this time:

  • 30 minutes of physical activity every day.

I’m prescribing to the KISS plan, and hoping that the flexibility of that makes it easier to stick with. If it’s warm enough to run, I might run. If it’s not, I moved my bike into the house and put it on the trainer, so I can ride the bike for 30 minutes. I’ve also got the dumbbells, so I can lift. So I’m just going to try to get a good rotation of different activities. Everybody says 30 minutes is the magic number, so that’s what I’m going with.

I imagine my plan for reigning in the diet is going to be pretty similarly simple, so maybe I’ll write that up tomorrow.

Posted in Fitness Challenge | Tagged , , | Leave a comment

Health and Fitness

For the past year, and especially since winter started, I haven’t been doing a very good job of staying fit or doing much physical activity at all. Between the bad weather and a new job that takes up more of my time, I haven’t had the motivation to get it done. I also haven’t really had the daylight in a while. I know these excuses all suck, so I’m not going to use them anymore. I’m going to create a plan over the next couple days, post it here, and stick to it.

I spent a lot of time and effort in college staying in perfect condition, and it’s pretty disappointing to think about where I am now. So it’s time to work my way back, and I’m committing to it here so there’s some accountability. Weather, work, and laziness are no longer good enough reasons to skip out on some kind of physical activity.

Stay tuned.

Posted in Fitness Challenge | Tagged , , , | Leave a comment

iOS Alarm Debacle

Honestly, this alarm thing hasn’t affected me in the least, but I can imagine it did affect a lot of users. And really, there can’t be many things that are more frustrating than an alarm clock that doesn’t work.

However, what bothers me is that the situation speaks to a bigger (not big, just bigger) weakness of iOS right now that no one is talking about. Why hasn’t Apple decoupled it’s default apps from iOS and put them into the App Store? The way it is right now, in order for Apple to patch even a broken alarm clock, they have to push out a new build of iOS at 300-600MB and every single user has to plug their phone into their computer, download the software update (which could take a decent amount of time depending on connection speed), and go through the entire sync and update process.

If Apple would make all its apps the same as any other app, then they could push a ‘Clock’ update to the front of the iTunes line, and anyone who wanted the update would get it the next time they opened the App Store. They would be more likely to know about it, and they would be able to download it over any network, including their 3G signal. Hell, AT&T could even send out a free text to all users suggesting they download it. Just like that, problem solved.

As an added bonus, maybe we would all be allowed to delete some of the Apple apps that we’ve replaced with better third-party apps. Sounds like a win-win to me.

Posted in Apple, Tech | Tagged , , | Leave a comment

Technology in Sports

Anybody and everybody who gets paid to yak about sports has an opinion on the use of technology to improve officiating. I grew up a Cubs fan, having words like ‘tradition,’ ‘pristine,’ and ‘old-school’ dominate my sports world. Wrigley Field didn’t even get lights until my 8th birthday, and they still don’t have a fancy scoreboard or video board.

So with that in mind, I was always on the side of the argument against adding technology to sports. Umpires are “a part of the game.” They make the sport charming and “add a human element” to the game.

I’ve changed my mind. I’ve decided that that argument doesn’t even make sense. We want our games to be called correctly. Who cares who makes that call? The yellow first down line has been a part of television for so long that I think we forget it’s not actually on the field. The Boise State-Nevada football game was decided by a missed field goal. Because it went higher than the uprights, we have no real way to know for sure that it missed. So why not have a laser upright that extends infinitely into the air. That would be the easiest way to know for sure. The same goes for baseball. MLB.com has had pitchFX for quite a while now. We know everything about every pitch: where it starts, where it ends, how much it breaks, how fast it’s going, and exactly where it crosses the plate. So why wouldn’t we have pitchFX calling balls and strikes?

I think there are valid arguments against using instant replay. You don’t want to slow down a game (especially baseball, which is already way too slow). So, don’t have replays. Just use better tools to get the calls right in the first place. If pitchFX is calling balls and strikes, there’s no umpire for the managers to argue with and cause delays in the game. If the laser goal post is also used as laser foul poles, we don’t have to argue about whether a home run was fair or foul. If you can put a chip in a soccer ball and know, for a fact, whether or not it crosses the goal line, how stupid do you have to be to not do it?

Even though I’m a Cubs fan, I’m also a technology enthusiast, and I have reached the point where I don’t understand why we’re not using this stuff. I don’t think anyone really wants calls to be wrong, so if there’s a way to get calls right and take human imperfection out of it, why not get it done?

Posted in Sports | Tagged , | Leave a comment

Five Oceans?!

First, they get rid of a planet, and now, apparently, they’ve added a new ocean. I have no idea when it happened, and Wikipedia doesn’t even definitively state that it did. Apparently it’s mixed up in some kinda ratification process.

Anyway, for those of you whose social studies books told you there were seven continents and four oceans, you better get your facts straight before your kids get to school. Say hello to the Southern Ocean. Yeah, it even sounds stupid.

Here’s the part where I quote some funny things from what I learned about the Southern Ocean:

The International Hydrographic Organization (IHO) published the third edition of Limits of Oceans and Seas (S-23), the global authority on the names and locations of seas and oceans, in 2000. The third edition in 2000 established the existence of the Southern Ocean as the fifth world ocean.

I don’t know whether to make fun of the International Hydrographic Organization or the fact that there are three editions of that publication. Obviously, they had to make up an ocean to get from the second to the third, so I wonder what they did to get from the first to the second. Discovered the Earth was round?

Anyway, five oceans now kids. Wanna learn more? Here’s a couple links:

Posted in Random | Tagged , | Leave a comment

Conflagration of IE6, PHP session_start, and blank pages

Yesterday, I was troubleshooting a problem that (only) showed up in IE6 where anytime I click a link that goes to a page with session_start() in it, I get a blank page with no errors and the address bar shows the old address, and when I hit refresh, it goes to the new page and works perfectly. Bizarre.

It seems that lots of other people have run into this situation. Not a lot of people seem to get to a solution, or alternatively, they don’t post it. So, I have finally found the culprit, and I’m posting my “solution,” even though I don’t think it’s perfect. If you comment out the character encoding meta tag on the first page to start a session (in this instance, the login page), it seems to make all the problems go away.

Not having a character encoding meta tag is definitely invalid code, so I conditionally commented it out for only IE6. Not perfect, but neither is IE6. (W3C standard says to falls back to UTF-8, which is what I want anyway, so it’s getting where I want it to, just not explicitly.) Please let me know if you run into this post and come up with a better solution.

Posted in Code, Tech | Tagged , , | Leave a comment