Pages

Wednesday, January 23, 2013

Tweevio - What and how?

I really like doing something with Twitter API. Last year, while I was trying to learn Python, I wrote a script that receives the trending topics in Twitter. (You can see the code here.)

Now I'm planning to do a project with using Twitter API again. Actually, I'm thinking on it very long but I have a chance to make it happen at this moment. I even gave a name for it: Tweevio.

Tweevio will show the last Youtube videos that are shared in Twitter. Yes, that simple.

After this convincing explanation of the project, let see how I'm planing to do this project:

I think I have to use Youtube API for playing videos. Also, I'm planning to use jQuery library. Actually, I don't know jQuery but in CodeAcademy there are really good tutorials. I will follow those tutorias to have an idea. The reason I choose jQuery is to make my job easier on sending HTTP request and JSON parsing.

Before starting this project, I separated the things that will be done into simple tasks. Here they are:
  • Send HTTP request to Twitter Search API. And store the response in a variable. (Youtube.com, youtu.be will be searched in tweets.)
  • Parse the JSON which will come as response and extract Youtube links from it. (Maybe using regular expressions.) 
  • Write a simple website which just has an input box and button. This website will show the Youtube video whose url is entered in input box.
  • Prepare a very simple website with Twitter Bootstrap. (Use placeholder images.)

This is the design of the site created with Balsamiq Mockups.

Tuesday, January 22, 2013

Plans for semester break

  • I want to follow Scala course on Coursera which is given by Martin Odersky. I have no functional programming experience. I want to enter into this area with this course.
  • I will look over Play! framework which is used to build web applications with Scala and Java.
  • I will also follow jQuery and API lessons in CodeAcademy. In CodeAcademy, in order to pass a course, you have to write codes and complete missing parts. I think it's a great way to learn.
  • I have a little project which uses Twitter API. I want to complete it. Also I will write a blog post about it.
To accomplish all the things above can be difficult. Because, I have bad experience about these kind of todo lists. I can get bored and leave the things that I'm working on. Related to this, a few days ago I saw a video on Facebook. I think the guy in the video has a point. I will give ear to things the guy emphasizes. I think you should check this out, too.


Friday, January 18, 2013

Download Manager Project - Bash scripting

The download manager is the project that I made for UNIX Scripts and Utilities course. I used bash scripting and dialog. Dialog is for the GUI of the project.

The reason that I chose this project is sometimes I download lecture slides of courses that I'm interested in. For example, since MIT opened the most of their courses, I want to download the lecture files to see how they go over the courses and what the homeworks are. Downloading whole files by clicking every link was exhausting. At this point my project is lending a hand to make things easier.

Actually you can download files from a web site by using wget command. To download specific types of files like pdf files, you can give the extension of the file with -A parameter. Let's see an exampe of this.

       wget -r -A.pdf http://www.cs.ozan.edu/~yildiz/prog101/

This command will download all pdf files in the given website which is supposed to include lecture slides or homeworks.

Since the aim of the project is using grep, sed, awk, cut and provide GUI to the user, I should have used something else. And I came up with this:

How does the script work?
  • After a user enters comma-separated urls of web pages, the script keeps a list of urls by using awk command.
  • The script has a loop to iterate over those urls.
  • Then, the source of a web pages is downloaded with wget -k -O command. -k parameter is to convert all relative paths to absolute path.
  • Then, grep extracts these absolute paths by looking file extensions and write them into a file. (The extensions of the files that are going to be downloaded is predefined.)
  • Another loop downloads all files one by one. Also download bar is increasing when a file is downloaded.
  • The script also keeps the history of the downloaded files.
And of course images of the project:

This is the part that user enters links.

Downloading screen. We are able to see the file that is being downloaded.

I put the codes to my gist. Click here to see the code. You can add new file extensions to be downloaded by modifying extensions variable.

Sunday, December 2, 2012

Visualization of A* Algorithm - A Java Project

As I mentioned in the last post this semester I'm doing a Java project which is Visualization of A* Algorithm. Because of the exams, I couldn't spare time to improve it. I did some in this weekend. I redesigned the class structure because a class was doing things that it shouldn't do. I added one more class and it is more object-oriented right now.

When I did the first version - before the improvements above - I showed it to my professor. He wanted me to add the spreading of the algorithm in every step. In this way, we are able to see how the algorithm works. To do this, I had to sleep the algorithm for awhile in every step. And I added sleep into the function which finds the path. But it didn't work as I expected. Because GUI slept, too. After a little search, I found that I had to make thread programming to fix that problem. My program was executing in a single thread, when I sleep a function, GUI was sleeping, too. The thing that I have to do was dividing the program into two pieces, first is the piece that shows the GUI elements and the second is the piece that does calculations for algorithm.

I know a little bit of thread programming from my Operating Systems course. We also did a lab to learn better. We were using C, you can find the code for that here. In Java, thread programming was easier than I thought. After doing that, program was working correctly.

Now, I have to study to understand algorithm better. I am little bit confused because of heuristic part of algorithm. The heuristic is directly affecting the algorithm, choosing the right heuristic is the main issue of A*.

Here is some images from the project;


Initial position of starting and destination nodes. Later, users will be able to change their positions.



Spreading of algorithm. Light gray nodes are in closedList. Dark blue nodes are in openList. Calculating g value of neighbors is like this:
currentNode.g + 10 for horizontal and vertical neighbors
currentNode.g + 14 for diagonal neighbors
And Manhattan heuristic is used.

When I finish this project, I'm planning to open the source code. I will probably share the codes on Github.

Saturday, November 3, 2012

Long Time No See

I haven't written something for more than a month. I have reasons for that. I've been busy with some paperwork for senior-year project which I will give more information in another post later.

What am I doing?

I'm busy with loving my Unix class. I always wanted to go little deep on the subjects of Unix. This is being happened in my Unix class and I'm happy with that. Moreover my professor gave me a GNU sticker. Woohoo!


I'm also spending time on my Java project which is a course project. I'm doing Visualization of A* Pathfinding Algorithm. We'll submit this project at the end of the semester. But I started early and did some improvements. Actually, this algorithm was another thing I always wanted to learn. I knew that this is also highly used in games. That's why I wanted to learn.

Finally, I will share a screenshot of that project which is an inevitable ending of my posts.


Sorry about the color choices. Green node is the starting node, red one is the destination node. Yellow ones are the walls that the path cannot pass through. Pink ones show the shortest path. User will be able to change the places of starting and destination nodes. Also they will be able to put walls wherever they want. 

Thursday, September 20, 2012

G.I.F.T.

As I promise, I'm going write something about my new game: G.I.F.T. actually new version of the ice cube game. In G.I.F.T. we are controlling a kid and helping him to get his gift. Base mechanics remained same. We are controlling him by sliding on the surface. I've uploaded the game on kongreate and newgrounds. (Kongregate link - Newgrounds link to play the game.)

Here is how I converted an old game to a new one.

First, I started with changing the character. I wanted it to be a kid. And I started to draw something. First, I thought the kid as a stickman figure. But I didn't like that and I changed my idea. Then I applied some colors and I got this result:


This was my first attempt to draw something for my game.

Than I started to make tiles. In my mind, there was winter atmosphere for the game. For that reason, I made snowy tiles. And I used gradient effect for the background image. This is the tileset that I've made:


And a snowball which is an obstacle:


I know that they're not so good. But making them was so fun for me. Also, using them in a game was a great experience.

I also made some jumping sounds. It can be hardly noticed because its volume is low. That's because I recorded them by using a cheap microphone.

Now, some technical stuff:

I made all the levels as a different class which derives from FlxState. I chose this way because reseting was too easy. Just a line of code which is FlxG.resetState(). But I couldn't put a loop music to the game, because when it resets the game, it also resets the music. For that reason, maybe this decision wasn't that useful. I think whole game must be in just one state to fix this problem. Reseting can be done with setting all variables' values to thier first values. Another bad thing is that I wrote almost same things for the all of the levels. In the ice cube project, I wrote a Level class and derived all levels from this class. I think this way is better and more object-oriented.

I hope you have fun while playing G.I.F.T. and please rate and leave comments.

Monday, September 17, 2012

Ice Cube Has Gone

From the beginning, I didn't like the idea of ice cube game. But I liked the base mechanics of it. For that reason, instead of making new game I wanted to change and enhance it. I've been working on it for more than a week. The game has changed entirely. I think it's better than the previous idea.

I will give more information about the new idea soon. For now, I'm putting an image which reflects the game directly.