My Other Sites

Friends

Rincon Limeno June 6th, 2009

So yesterday I took everyone out to eat Peruvian food for their first times. I have to say I was impressed with the line up. They actually had Ocopa here, which is something I look for at all Peruvian restaurants and never find. On top of that, the food was fairly cheap for a typical Peruvian restaurant (minus the Pollo a la Braza places, but those are supposed to be fast food-ish). I ended up ordering a Papa a la Huancaina and an Ocopa for everyone, plus an Aji de Gallena for myself. One of my friends got some Yuca frita for everyone to try and a carapulcra, and everyone ordered Inca Kola, which is good stuff. One of my friends braved the Chicha Morada and merely tolerated it. That’s better than me however; I can’t drink the stuff at all.

Overall I was pleased with the place, and I’d go again if it werent all the way into Boston. I’m glad I can actually get Peruvian here however, so that’s pretty solid. I still haven’t determined if I can actually buy my own Inca Kolas around here, but I have a feeling the Super Stop n’ Shop in Boston probably carries the brand.

Boston! June 4th, 2009

So I’ve finally mostly settled in to my new apartment in Chelmsford. So far, I think the area is fairly decent. The apartment is pretty good, and a lot of people I know are actually in the area for both summer and fall. I’m still in the process of getting a bit more furniture so that I can actually sit on something other than the floor and so my desktop isnt lying on the ground.

I haven’t actually been to Boston yet, but I’m going tomorrow. As a bonus, three of my friends and I are going to a Peruvian restaurant so they can finally get a taste of what Peruvian food really is. The place is called Rincon Limeno which first of all is a fairly Peruvian name, and also the menu looks fairly good. They even have Ocopa, which I have never seen at any of the Peruvian restaurants where I live. I definitely plan on ordering some for everyone.

As a side note, I’ve finally installed Django on my machine along with Apache server, PostgreSQL, and FastCGI. I’ve created the example blog in chapter two of my roommate’s “Python Web Development With Django” book, and I must say I’m pleased with the framework so far. My next plan is to move away from using Python’s built in server/database solution and use Apache and PostgreSQL along with FastCGI. If I can successfully move the example blog to those technologies, I should be good to go for following the rest of the examples in the book. Wish me luck.

Java Scanner Weirdness May 11th, 2009

The most common problems I see in Java amongst newbies to the language is the use of the Scanner class. This particular class was created in order to make reading in data input from the command line easier for those new to the language. However, I fear it only half worked. Scanner is still a big pain to use.

First of all, do not even ATTEMPT to mix data types with the same scanner. It will not work. Having a Scanner read in a line of text and then read a single integer will cause an exception to be thrown, and then the person first learning Java gets a big headache and hasn’t a clue about what is wrong with the code. The fix for this by the way is to simply have different Scanners work over System.in, making sure each one reads the data in only one format.

The next biggest problem with Scanner that I see is the use of the hasNext() method. You cannot use the hasNext() method effectively when reading keyboard input from the command line. Usually I see this kind of code:

while (input.hasNext()) {

System.out.println(input.next());

}

If you cannot see the problem with this while loop, it’s because you have not realized that in this case, input is a scanner looking at System.in . The only way this loop will stop is if the end of the file is reached, and well, the command line can never reach the end of the file. This means the only way to stop this loop would be to input the EOF representation into the keyboard, which most people do not know.

Scanner has its problems, and if you want to advance as a programmer, I highly suggest using a BufferedReader. It’s a little more complicated but much less of a hassle later on, especially when you begin getting into much more complicated streams of data.

Pythonic CGI Up And Running May 3rd, 2009

Success.

Please visit my projects page if you want to see my Othello AI program, written purely in Python. I should add that some of my teacher’s code from high school is buried within my modifications so he deserves credit as well, which I’ll fix shortly. For now you can give it a whirl. I’ll be posting a download link with a template for creating your own Othello-playing AI that will work with my program. I still have to work out the security issues of having people upload their own code, so that won’t be available for now. I can also post the non-web source code for download.

Learning about CGI with Python brings me one step closer to delving into Plone and Zope. I could have just gone at it right away, but I don’t have too much time yet as I’m still in school and I needed to brush up on my Python. Now that I’m all set, I can start playing with web frameworks. Should be fun.

Python Code Recovery A Success May 1st, 2009

I’ve recently begun a mini project to get my old high school AI code working once again. We created AI’s to play the game of Othello against each other, and these programs were written in Python. For some stupid reason, I only saved the .pyc files of pretty much all of the AI’s I had except for one, which happened to be not that great (loses to randomness). But I digress.

The point is I got the Othello referee (the program which lets AIs battle each other) to work once again by letting it read from .py files and by cleaning up its display code. I also fixed up the only AI file I had so that I could test the referee once more. It really does bring back memories.

I’ve created a template AI file which contains the code needed for any AI to function, and has comments for which defs were left blank. One of my goals here is that anyone wanting to learn Python and work on something a little more interesting can use the template to create as complicated or as simple an AI as he or she wishes. This of course leads me to my other goal: to integrate this Python script into my website and have people be able to upload their AI’s and battle their creations against those on the system. It’s bold, but I like it a lot. I really do want this as I feel it would be something cool that people could do to make learning Python fun. It’ll also allow me to play with programming web with Python, working with a GUI framework for Python (I’m gonna look into wxPython), and will let me test the Python capabilities of my host (Dreamhost is awesome).

I’ll keep logging my Python successes and failures as I progress through this little project of mine. Wish me luck.

« Older Entries Newer Entries »