Warning: mysql_get_server_info() [function.mysql-get-server-info]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory") in /srv/disk4/bhall99/www/sosguy.net/wp-content/plugins/advanced-category-excluder/advanced-category-excluder.php on line 128

Warning: mysql_get_server_info() [function.mysql-get-server-info]: A link to the server could not be established in /srv/disk4/bhall99/www/sosguy.net/wp-content/plugins/advanced-category-excluder/advanced-category-excluder.php on line 128
sosguy.net – Chronicling the life, work, and thoughts of Zach Hall Press "Enter" to skip to content

sosguy.net Posts

Code Snippet: Extracting a 24-hour time from a 12-hour time string in MySQL

The snippet:

HOUR ( STR_TO_DATE ("2:30pm" , "%h:%i%p") ) = 14

Why I needed it:

I’m currently working on a time and date filter for ClassGet. If you’ve ever wanted to find a morning class that meets only on Tuesdays, this tool is for you! The main problem, however, is that Furman’s course listings file has the start and end dates for classes in this format:

Start Time: "12:30pm", End Time: "1:20pm"

and my import script doesn’t convert these into a DATETIME format in SQL. I want to be able to look at courses from If I want to find a class starting from 12:00 to 14:00, I’ll need to do some conversion. On the front-end, I’m using a jQuery UI slider for my hour control that goes from 5 (5:00 am) to 21 (9:00 pm). Why anyone would have a class starting at 9:00 pm is beyond me, but hey, it could happen. I’m not going to worry about minutes, and I know that no class will ever be offered overnight so I’ll never need to worry about a start time being later than an end time. My script will search for classes that start from one hour to another, so I’ll need to convert the dates to match. You would think I could just do something like this:

SELECT * FROM classes WHERE `Start Time` BETWEEN 12 AND 15

But it doesn’t work like that. The dates are stored as strings, e.g. "2:30pm". We’re lucky, though… MySQL has an HOUR function that will solve that!

SELECT * FROM classes WHERE HOUR(`Start Time`) BETWEEN 12 AND 15

But still, no classes are showing up that start at 2:30. How come? As it turns out, HOUR("2:30pm") returns 2, not 14! How do we fix that? The answer lies in MySQL’s STR_TO_DATE function, which is the reverse of the DATE_FORMAT function. Now, take a look at the final version:

SELECT * FROM classes WHERE HOUR(STR_TO_DATE(`Start Time`, "%h:%i%p")) BETWEEN 12 AND 15

There we go! Now without doing any PHP or JavaScript or modifying the database structure, I was able to create a date filter for class data.

Weekend Project: Video Poker in C# and Silverlight

I’m working on building an electronic piggy bank style box like this one I’ve seen that will count my spare change, and I wondered if I could make it more interesting. I thought back to coin-operated arcade machines and thought that I could make a pretty cool video poker software that would read my piggy bank and let me play poker with my change as well. I decided to learn a new language to do it: Microsoft’s C# (sharp).

A few good friends of mine use C# in their jobs, and its an interesting choice because it’s a .NET language and the same code can be used on the Windows desktop and online using Microsoft Silverlight.

I ported some old Python code I had over to C# to learn about what makes it different, and after a bit of searching through the Microsoft Developer Network (MSDN) I found out the correct ways to do some things, and after some more tinkering and learning WPF, the Windows Presentation Format, I had my application.

Now, I don’t want to break any gambling laws so all the “credits” earned are 100% virtual, and have no cash value. In the future I can wire this up to the coin acceptor I’m building to accept more credits into the machine, but once they’re there, they stay there. I did make a rudimentary user account system that saves ones balance in-between sessions, so I can reboot my computer and I can still play later.

I still need to learn how to cache the card images somewhere, because every time I draw the cards the images are pulled from my server again and again.

To the web!

As I said, I’ve heard that Silverlight makes it easy to cross-compile applications for the web. It’s true for the most part, but there are some discrepancies. First, some controls such as the Label that work in WPF don’t work in Silverlight. Also, any Class Library DLL files that you’ve compiled for the desktop won’t be able to be added to Silverlight, so make sure if you’re compiling for both that you save your .cs files!

I make a few changes to my application since that screenshot was taken, and have made a web-playable version. This lacks user accounts, and you’re awarded 100 credits every time you visit the page! If you go below 0 credits, I don’t know what happens, but I think you just go into the negatives. It’s a prototype, and it’s controlled entirely via the keyboard for now. Make sure to click the blue background before using the keyboard to make sure the program has focus! I might improve it later, but my focus is on the desktop implementation for now.

I’ll be on Spring Break for the next week, but I’ll update once I get back!



What a great trip it was! Over the weeks I have accumulated a great number of thoughts that don’t constitute enough content for a full post, but I didn’t want to leave anything out, so I’ll combine them into one. Let’s ‘a go!

Things the Japanese don’t believe in

  • trash cans
  • napkins
  • soap in public restrooms
  • towels in public restrooms
  • eating while walking
  • keeping your key when you leave a hotel each morning

Things the Japanese believe in

  • cleanliness
  • the same 4 notes over and over in traditional music
  • fish for breakfast
  • fish for lunch
  • fish for dinner
  • convenience

Top things America could learn from Japan

  • convenience is awesome. There should be more vending machines and convenience stores around America
  • embrace cleanliness. We’ve been to some cramped places in Japan (Sakura Hostel) but I’d much prefer them to dirty American motels (I’m looking at you, Travelodge.)
  • ticket ordering systems. Eliminate tips, eliminate cashiers. Have vending machines that print tickets with your order on them, give them to any waiter, get your food without the hassle. Pay the waiters more also.

Top things Japan could learn from America

  • trash cans are good
  • credit cards are also good. accept them everywhere
  • portions. I ordered a large soda, gimme a large soda

Most helpless moment: Ordering a meal at McDonald’s. It sucks to know exactly what you want, but not how to put it into words. I want 1 meal and 1 extra sandwich, not 2 full meals!

Most awkward moment: Visiting a few of the shops in Akihabara. Strange, strange things to be seen.

Best experience of the trip: Making new friends and getting to know old ones better.

See you next time! さよなら!(^_^)/~

San’ya Grays


Before sunrise each morning, business is already being conducted in San’ya. The daily job auction determines who will work, and who will go hungry over the next 24 hours. One of the members of our group wanted to go to the auction, but since it starts at 5AM, it was hard to muster enough energy to rouse oneself to catch the 04:15 JR train. Instead, we decided to head out at 09:30 with a professor who knew a bit about the area. It started out as a nice sunny day, but the sky got increasingly dark as day went on. By the time we were leaving, a rainstorm was brewing, which struck later when I was at Akihabara.

Walking around San’ya, we first arrived at a free clinic / support center for people without insurance. It was quite awkward being there, as we were just standing around listening to one of the support workers talking while workers sat behind us and chowed down on free food. We were given a very strange warning before we arrived in San’ya: “remember that these are people, and this isn’t a zoo. Be respectful and don’t take their pictures without asking.” It made sense once we got there, as it probably looked like we were rich college students on a trip to the zoo to the workers. Sad, really. I’m glad we went in groups.

After going down a few streets in San’ya, I started to notice that not many bikes were locked up. I asked about this, and found out that even though most bikes are left unlocked, there’s not much of a problem with theft. The crime rate is surprisingly low everywhere in Tokyo, and San’ya is no exception. Remembering New York and the “Bicycle Bermuda,” I must say that it’s quite impressive.

We also passed by a few government-run apartment buildings for welfare recipients. You are required to have an address to collect welfare, so it’s a good thing these apartments exist. There are some apartments for students and those with jobs in other parts of Tokyo in San’ya, but the students and the workers don’t associate with each other. The average age of San’ya residents is approaching 60, so its nice to see some students living there. In 40 years when the current generation has passed, I wonder if San’ya will still be the construction-oriented community it is today. I don’t think so.

Posters promoting the JCP were posted all over San’ya. I didn’t know what the JCP was until someone pointed out to me that it stood for the Japan Communist Party. She was quick to point out that it was a propaganda poster and that it was pretty strategic placement, a movement promoting worker unions in a neighborhood consisting of lots of workers. I agree. I’ve seen the posters all over, including in Okinawa, and even saw a car with megaphones on the sides shouting about joining the party. Hopefully a message that won’t catch on.

Overall, I’m glad that we left San’ya without diving too far into it. I’m sure it was pretty safe, but I’m not sure I’d like to be there alone, knowing what I read in San’ya Blues.

So eight guys walk into a room…


No, it’s not the start of some silly bar joke, it’s the Sakura Hotel in Ikebukuro! All I can say is that it’s neat, clean, and would be an absolute blast if I were on a backpacking trip and not carrying 15 days worth of clothes and souvenirs. Guess which situation applies.

Today we met with students from Waseda University. The group consisted of only a few Japanese people, with many being exchange students from China, Korea, and even the United States. One of the students in particular was a Korean native who is coming to Furman next year as part of an exchange program Furman has with Waseda. She spoke to me briefly during a pizza powered reception, and told me that she was learning Japanese just as I was, though I’m guessing she’s quite a lot better at it thus far.

After introductions, we headed over to the Waseda bookstore to get some t-shirts and other swag. Since the shirts were around $40, I’m still only thinking about getting one. Seems like a nice souvenir, though a bit expensive. After that, the whole group split off into interest groups. Some people went to a soccer game, others went back to the hotel, and as for myself, to Akihabara I went.

The Waseda students I went with were quite knowledgeable of the area, and were able to lead our group of 2 guys and 3 girls to all sorts of weird spots in Akihabara. Starting out as a hobby and electronics neighborhood where people would go to buy computer parts, the area has morphed into a video game and “Otaku” style area, but we were lead to a few model airplane shops and a 9-story electronics mall. One of the students commented on technology in Japan and repeated what Dr. Jenkins had stated: Japan used to be the center of technology in the 60s, with Sony being the top-of-the-line in electronics, but over the years they’ve lost their top engineers to Samsung and other companies in Taiwan and such that will pay twice as much and allow the engineers to research whatever they want, unlike the Japanese. I wonder if it coincides with Dr. Jenkins’ argument that the Japanese aren’t as creative as other countries, and aren’t innovating but rather refining.

We visited quite a few arcades while in Akihabara, and as they pointed out, Sega is one of the leading names in the arcade business. We saw a few rows of Gundam piloting simulators, and it would seem that the whole display is similar to an E-Sports layout, in that there are scheduled events and prizes for those who do well. Very competitive arcade gaming.

We went to a few weird shops as well, all ones that the students knew about and presumably had been to before. There was one store that resembled an American flea market, but people could rent out glass boxes, stock their own merchandise and name their own price. When a sale was made, they would get the profit but the store would sell it and take a commission. A bit more organized than in America, but all over Japan there seems to be organized chaos.

For lunch, we had fried octopus. It tasted… interesting. Not very much taste to it, in fact. Mostly tasted like barbeque sauce with a strange texture. I left the students with gifts: Jelly Belly’s. They’re only sold in America, so I figured it’d be pretty exotic. Overall, it was a very fun day!

Tour the world, meet exotic people

Today we went to the Okinawa Convention and Visitors Bureau, AKA the OCVB, or as I like to call it, the tourism bureau. Upon arrival, we were presented with slide show and some interesting facts about Okinawa. There are only 1.38 million citizens in Okinawa, but 5.52 million tourists visit each year. Looking on the street or on the monorail, you would think that’d mean on average 1 of every 6 people would be a tourist, but it doesn’t look that way to me. In fact, almost everyone I’ve seen appears to be Japanese! Where are these 5 million tourists hiding?

Surprisingly, the answer is that 95% of tourists are from mainland Japan. 5.22 million tourists are domestic compared to 301,000 international visitors. The number of domestic tourists has been declining this year though, and that’s why the bureau is trying to attract more foreign tourists. They’ve had some great successes so far in terms of media publicity and their own in-house advertisements and brochures, and have been pitching Okinawa to airline and cruise companies (China Airlines and Holland America to name a few) as great ports of call and flight destinations.

Apparently most of the Okinawa’s tourists are repeat customers, as 79% of survey respondents indicated they’ve visited previously. The bureau staff explained that a big challenge for Okinawa is to create more reasons to keep people coming back. Indeed, many people in our group indicated to me that since the nightlife isn’t very big they may not want to come back, as they felt they had done everything already. In the video that we were shown on Okinawa’s tourist attractions, it felt a bit like a debriefing video on the sights we had already visited during the week. Almost every attraction highlighted in the video was something that we had seen already, though the beaches pictures were a lot nicer than the one that our bus dropped us off at days earlier. Personally, I’d like to come back and see what’s up in Okinawa in the future, but when asked on the questionnaire we were given about when I’m planning to return, I couldn’t give them a straight answer. I feel like maybe in the next few years, but what would I do? The group says nightlife, and we were given a complimentary copy of the nightlife guide in Okinawa for our enthusiasm. I wish the theatre didn’t close at 22:00, but the whole society seems to close down at night. There are only a few stores I’ve seen that are open 24/7, and 90% of them were McDonalds. It goes back to a point the group identified about Okinawa’s citizens: they seem to be very laid back. I haven’t seen a lot of people darting across the street or dashing up escalators to catch trains. The monorail isn’t extremely crowded, even at 17:00, and it was even 30 seconds late once.

Overall, I think that the OCVB has it right in what they’re doing. They mentioned their presence at several international travel conferences, and the fact that they’ve had so strong media presence in the last few years is also a good way to attract people to the island. It’s true what they said about Okinawa being close to everywhere in the east, and I’m sure if they keep on the path that the are they could probably create a travel hub between mainland Japan, China, Korea, and the Philippines. The island is really a very scenic area, and they’re able to collect healthy fees when Okinawa is used in movies. Since there are so many tourists, it sounds like more entertainment is a good way of generating interest in the island, but it also seems that a lot of people vacation in Okinawa to get away from it all as well and simply relax.

Just 3000 low payments!


Today we had quite an interesting visit to the Okinawa Prefectural Archives. The collection is similar to a public library, in that there are a lot of freely available materials, and it houses a lot of government documents from the USCAR period of US rule and more recent documents, as well as over 2500 motion pictures and 3,000 still pictures. Lots of the materials were purchased from the United States archives. Dr. Sakamoto of the University of Maryland showed us around the archives, and told us that the photographs cost on average $50 per photo, and that the prefecture itself has spent over $1.5 million on the pictures alone. The budget hasn’t been as good in recent years, however, and that’s why they haven’t been able to get more photos. The first thing that I noticed about the collection indeed was that it was smaller than I imagined. Only 2 main rooms held archives and one smaller room for videos. When looking at pictures of the US national archives and at the high price they charged for copies, however, I can see that money is probably part of the reason it isn’t larger.

We watched a film produced during the war by the US military about their various war strategies against Okinawa. It was very US biased and portrayed very strongly the idea of idea of us against “the enemy,” who was also referred to as a single “him.”

Later on in the night we listened to a great presentation by Dr. Jenkins of the Okinawa Prefecture University of Arts on Bernard Bettelheim, a Jew-turned-Christian missionary on a mission to bring western medicine and Christianity to Okinawa. A naturally gifted linguist, he knew over 16 languages and thought of Okinawa as the place to spread his religion because in Isaiah there was talk of “far away lands” and Bettelheim decided that meant Japan. He wasn’t extremely successful during his time, in part due to the harsh penalties for paying attention to his evangelizing. He published a journal, however, which has come to be quite famous, and Dr. Jenkins has transcribed it in 2 volumes. Part of his lecture discussed his practice of editing and how to be a good editor, and it was interesting to see inside the profession. I never knew what [SIC] or meant in editing, but I know now.

Overall, a very good and informative day.

Obligatory Beach House Episode

OI! I thought I was good with technology, but nobody is safe from stupid mistakes. I had easily hundreds of words written here, but they all went away because I didn’t press SAVE.

Anyway, we left the hotel and went to ECOPAR, a park and campsite. Upon arriving, we went kayaking in a lake. There were some beautiful sights to be seen, but I didn’t have a camera. Thankfully, Nicky was my kayaking partner and she was also the only one with a waterproof camera!

Stating overnight in a Japanese cabin was quite the experience. I’m not sure if big empty rooms are the norm in Japanese architecture, but big empty room were what we found. Tatami mats were there for us to sleep on, and though they weren’t very comfortable when trying to fall asleep, they were Tempur Pedic quality at 07:15 when we had to awake for a 30 minute breakfast at 07:30.

Back on the road right now and headed to a beach island resort! We passed the most photogenic spot in Okinawa, but the rain is cruel to cameras, and the fog covered the rest of the area.

We passed a military base and saw lots of “AMERICAN AUTO” lots, as well as some pizza places. Guessing it’s a bit like ports in Mexico where Americans tend to gather, though a bit more practical.

Anyway, after arriving at the beach resort we saw quite a few sights. For starters, the aquarium. It featured all varieties of ocean life, most prominently the whale shark. I liked the coconut crab myself, partially for the name alone. I actually ran out of space on my phone with all the picture taking I was doing.

Afterward, we went to a planetarium and a dolphin show. The dolphins were really smart!

Shaking hands with an amputated arm

After reading the grim recollections from student nurses in the Battle of Okinawa, I got pretty depressed. All of the reading we’ve read so far is depressing. It’s unfortunate that the battle had to end the way it did, I wish the Japanese had just surrendered. Of course, if they had, would this carnage have been avoided? Would a worse fate have befallen them if they had? It’s impossible to say.

The testimonials included some terribly vivid images. One that particularly stuck with me was the account about soldiers being incredibly hungry and their only food when in the hospital was other soldiers’ amputated arms and legs. The mass suicide orders reinforced the idea for me that the soldiers were horribly low on food. Lighten the load? Barbaric. As the nurse said, however, “that’s war.”

When the nurses were disbanded, they shouldn’t have been forced to leave the caves. Over 200 dead from the 216 that went in, and the loss could have been completely prevented. The morale was low, though, and in the War Memorial museum that we went to today, I saw in an exhibit that the Japanese military would murder soldiers who were too weak to recover by giving them milk laced with cyanide. That isn’t following the Hippocratic Oath. The Japanese suicide tradition is one that I hope died with the end of the war.

On top of being caught in the middle of a warzone and being denied basic water and food, the student nurses weren’t really treated all that well by the Japanese soldiers. In the student nurse museum I read a few quotes about the soldiers being ungrateful for the help that was being offered, probably due to the pain that they were in. There weren’t enough pain-killing drugs to go around, and thus the soldiers suffered unnecessarily during procedures. The descriptions of the soldiers in testimonials described that they were covered in lice, and one nurse was described to have maggot infested wounds of her own. The American soldier who captured her was cutting away all her clothes and behaving as if he enjoyed torturing her. No matter what side of the battlefield you were on, it seems that monsters existed.

I’m glad that the war memorial includes the names of all who died, not just the Japanese. It has been called by some authors the decisive battle that helped to end not only the war, but the entire style of high-casualty warfare, but its terrible that it had to end like this. At least respects can be paid at the memorial and at the various museums. If we arm ourselves with knowledge, it should help to stop history from repeating.