Tag Archives: tutorial

Learning C#

So I’ve been quiet the last few weeks, and that’s because I’ve been busy learning C#. I never got into it because I was always worried that it’d be archaic and obtuse to learn. That was compounded by the fact that I had tried C++ a few times, with Code::Blocks and I always got stuck with choosing a compiler or something. I really didn’t know what I was doing. Luckily, a friend of mine, sec_goat, convinced me to try out C#.

I’m really glad he did, because the whole language really isn’t as nasty as I was expecting. The compiler issue was taken care of by Visual Studio 2010 Pro, which I get for free from Microsoft DreamSpark, since I’m still in College. I’m actually still pretty fuzzy on the stuff that’s going on under the hood in C#, so I probably couldn’t compile my own project, but hey, it’s only been a few weeks.

Another reason I’m pretty stoked is that I’ve always wanted the be able to develop some games, and that just wasn’t easy in Python, because of how it runs. It’s super easy to get the design going, but unless you’d optimize the shit out of it, it’s going to run a bit slow. Now, not only can I develop games that’ll run at a decent pace, I can actually make games for the Xbox 360 too, with the XNA package.

It’s similar to PyGame as far as I can tell, but allows you to develop for the Xbox 360, and it’s integrated into Visual Studio quite nicely. It’s only a shame that I can’t use Visual Studio 2012 with it, without tweaking some files around; but that’s not a huge issue, since VS 2010 is pretty great anyways.

Relatedly, I’m using the VSvim plugin for Visual Studio, so a great majority of the vim controls are allowed. This greatly helps me learn vim. I have also set up gVim as an external tool, so whenever I hit F1, the code gets loaded into gVim for editing, should I ever need to do some extreme vimming.

Right now, we’re toying with the idea of making a Facebook pet raising game. Sec_goat is seeing what he can do as far as setting up a networked leaderboard, and I’m experimenting with making a tamigotchi clone. I’ve got a little console game going now that allows you to feed and do damage to your pet, along with an inventory system so you can store the food and a rudimentary status system where you can get buffs and debuffs such as happy or sick etc. I’m now trying to move the Console game to XNA, so I can make a graphical interface for it, along with having a true game loop, rather than just one prompt after another.

As far as tutorials go, that’s going to be put on the sidelines, if you can’t tell already. Like most people, I’m motivated by my own interests, so I just jump from project to project when it suits me. But if you’d like to get a simple tutorial on a Python feature, send me an email at tankorsmash@tankorsmash.com or on reddit under the username tankorsmash and maybe it’ll be the motivation I need to write another!

Thanks for reading, and as always,  I love hearing feedback. Ask me some questions or something!

Reddit API Tutorial Part 2: Getting all the submissions to any given subreddit

What’s up? Today we’re going to look at how to retrieve the stories (official term for submissions or selfposts) from any given subreddit. What we’re going to do is pretty simple, essentially just customizing a url with the proper subreddit and reading the JSON object returned. It’s going to be a pretty short one. I’m going to attach the login code I’ve written along with the code we’ve looked at today so that you can just copy and paste it into your IDE and start playing with it, right away. Just make sure you’ve got all the required module installed, mentioned here.  Hit the jump to get started!

Tinypaste Link for entire code

Continue reading Reddit API Tutorial Part 2: Getting all the submissions to any given subreddit

How to find your Public-facing IP with Python, requests and BeautifulSoup

In this entry, we’re going to look up what our public facing IP address is, using the Python modules, re, requests and BeautifulSoup. It’s going to send a request to whatismyip.com with requests, then we’re going to parse the returned HTML in BeautifulSoup, so we can break it up, and navigate through it a lot easier, and then finally, use re to grab the IP address and print it to the screen.

Hit the jump for the tutorial!

Continue reading How to find your Public-facing IP with Python, requests and BeautifulSoup

reddit API Part 1: Logging In

Welcome to the first part of my reddit API tutorial for Python 2.7! In this short tutorial we will just focus on signing in to reddit’s API so we can interact with it later.

Hopefully you’ve read the introduction on the modules we’ll be using found here, so if you’re a beginner, you won’t be that lost.

Before we start, I am just going to give you a brief overview of what we are going to do: create a python DICT that has your reddit account name and password in it, so that we can send it to the API with our request. Then, armed with our modhash that we received from the API, we can move on to interacting with reddit, which we’ll check out in the next part of this tutorial!

Tinypaste of the entire code as seen at the bottom of the page

Hit the jump for how to login to the reddit’s API. As usual, the full code will be shown at the end of this page.

Continue reading reddit API Part 1: Logging In

Imgur API part 2: Downloading a Gallery

This is the second installment of my Imgur API: ‘How to entire download Imgur Galleries’. Check out part 1 here in case you missed how to log into the API and upload an image!

I’m actually sort of cheating here, because we don’t actually need to use the API at all here, if we don’t want to. That is because we’re only going to deal with the galleries that are built from the images submitted to reddit. This means after you’re done with this tutorial, you’ll be able to just set the script to a given subreddits name, and grab all the images that have been submitted to /r/aww or /r/wallpapers.

I will be writing another tutorial soon for galleries and albums unrelated to reddit.com as well as grabbing gallery information, such as the title and other descriptive things like that, but that’s less related to the actual downloading of the gallery, which is what we’re interested in today!

Please note that I’m working with Python 2.7 on Windows 7 64-bit, so you might have to modify the code slightly to accommodate for your platform, or OS.

Anyways, hit the jump to get started!

Edit: reddit user: easttntoppedtree caught that it maxes out at 56 images, so you’ll have to add /page/PAGENUMBERHERE.json to the end of the url to get the next 56 images like so: http://imgur.com/r/scarlettjohansson/top/page/1.json’ while keeping in mind that 0 (zero) is a valid page number

Tinypaste link for the full working code, as seen at the bottom of the page

Continue reading Imgur API part 2: Downloading a Gallery