I finally decided to sit down and learn game development. From my research there is only one way to do it, and that is SDL. If it’s good enough for Valve and Steam, it’s good enough for me. As it turns out, it’s surprisingly easy to get up and running with SDL. There are plenty of tutorials about the basic SDL game setup, so I won’t repeat the ubiquitous info and go straight to some basic problems of making a game that no one really seems to discuss. There are two main problems when designing a game: How do I save and restore game state? How do I make my game configurable? C is a great language for speed and algorithms, but it is really shitty when you want to handle data. Games are both algorithm and data intensive. So for half the game development, C rocks. But for the other half, it’s a slog. Saving and restoring game state means populating a structure in your C code with values from a human editable, dynamically loaded file. Things like the x,y or even z coordinates of the player in game space, their health, equipped weapon, inventory items and so on. One solution for solving this problem is to use some kind of config file format like INI, or XML. INI is a good choice for very simple games, and it’s dead simple to write an INI parser in C. The other common option is XML, which means something like libXML, which means I’d rather have […]
I have been trying to write my own programming language off and on for about 5 years now. That doesn’t mean I have spent 5 years on a single project. Only that I have been toying with the idea and educating myself for that amount of time. Writing your own language is kind of the Holy Grail of computer science. Well, writing a language that is actually useful. Over the years, my experience in Ruby, PHP, C/C++, Python and even LISP, has informed my idea of what a good language would look like. Note I didn’t say perfect language. There is no such thing. I have come to believe that all languages are good in some way or another, and bad in other ways. Emotionally I like Ruby, and I like C. The elegant syntax of Ruby makes you happy to program, while the Do-Anything attitude of C makes it the ultimate language. I have been looking at Java( due to it’s cross platform nature ) and have to say at first I hated it. Now I hate it less. The number one reason I hate it less is ANTLR. I love the code generated by ANTLR because it looks like code that a human being would actually write. It’s very dense, but it’s alive. It’s hackish and clever. I have been following along the book The Definitive ANTLR4 Reference. This is a first time for me. Normally I, quite wrongly, just jump in and get it done. This time I am going to RTFM. […]
It’s been a hobby of mine for that last few years to try to create my own programming language. Don’t ask why, I just want to. Over the years I have tried and failed multiple times. This is mainly due to the fact that I am a self taught programmer with no CS background, or Math background, or any real education. When you set out to learn how one makes a programming language you will receive a series of answers similar to this: Use flex to generate a lexical analyzer. Use Bison to generate a Parser Forget both of those and use ANTLR To understand what you need to do to create a programming language, you will need to understand that in general all programming languages have a set of modules that take turns with the users input (i.e. the script). The Lexer The Lexer, or Scanner is the first component of a programming language. It reads a stream of characters and groups them together into meaningful parts. The Lexer adds no semantic meaning to the stream. Lexers create “meaningful” tokens. They generally, but not always, do not create whitespace tokens, they “ignore” them in the sense that they do not lead to the emission of a token, but they “use” them to delineate tokens. Flex has a simple interface for creating a lexer, a simple Scanner will look like this: If we save that as test.y and run: flex test.y cc lex.yy.c -o example -lfl ./example We can then start entering in some text. […]
Once you’ve installed apache2 and mysql on your server, you might want to try these configuration changes to make it perform a bit better: In /etc/mysql/my.cnf key_buffer = 16K max_allowed_packet = 1M thread_stack = 64K table_cache = 4 sort_buffer = 64K net_buffer_length = 2K And in Apache2′s config, /etc/apache2/apache2.conf, find the section for MPM prefork if yo have it and: StartServers 1 MinSpareServers 3 MaxSpareServers 6 ServerLimit 24 MaxClients 24 MaxRequestsPerChild 3000 The above are just some things to try if you encounter a situation where apache is using too much memory, or the same for mysqld.
Well, with mysql, it’s pretty hard to overwrite your dbs, but with sqlite, it’s real easy. I did this, luckily I only lost about a days worth of work, but nevertheless, I have instituted a new rule for sqlite3 dbs: Hourly backups. Here’s the script: #!/bin/sh D=`date +%H` cp -f /var/www/app/db/production.sqlite3 /var/www/fapp/db/production.sqlite3.bak.$D
Introduction to deploying Rails Applications to the Desktop Some things you’ll learn in this series of articles: How to distribute a Rails App to an Ubuntu Desktop How to Compile a custom Ruby installation to avoid conflicting with an existing Ruby install Get automatic updates to all users for free by virtue of being a Debian Package How to organize a build environment to make and distribute all Debian packages with a single command. How to build your own custom dumb browser in QT C++ (QT Creator now includes the ability to generate an HTML5 App, it didn’t when I started building Salor…) This is not a step by step tutorial, it’s a broad discussion, though I plan to make an example video with a hello world style app at a later date. Deploying Rails applications to the desktop, specifically unbuntu, though I plan to figure out how to do it with windows very soon, turns out to be much easier than I ever thought. While deploying Rails apps can kind of suck in comparison to other types of web-applications, it’s hardly any more difficult than any other kind of executable deployment. The reasons for using Rails for a desktop application are pretty obvious, ease of development, ease of maintenance, and Ruby can pretty much do anything you need it to do. For instance, in our application we use ruby to connect to a receipt printer and print out receipts, reports, labels and barcodes and more. Before you deploy a Rails app, you might give […]
I just finished reading this post from m.onkey.org on how to put your session into your models. First off, I love this guy, and his site, and most of what he says, but I’ve had it up to here with this nonsense. I also kind of felt a little dissed by the PHP comment. I understand he was joking, and it was kind of funny, PHP programmers are NOTORIOUS for using $_SESSION to store EVERYTHING. At the same time, as Voorhaus says, all comedy is truth and pain, and the truth is that PHP programmers do that, and the pain is that many programmers coming to Ruby and Rails feel alienated by that community because they are so opinionated (And not always right). Rails is kind of Opinionated by design, and that’s okay, but more often than not, the Rails and Ruby community is uneccessarily sadistic in its treatment of contradictory opinions, they have a “my way or the highway” kind of speech when in fact, you can do it anyway you want, and all they are doing is looking like douche bags for treating you as a sub-human for having a contradictory opinion. As I see it, at the core of the above issue, sessions in the model, is global variables, and the irrational fear of them. Phear Globalz There is some practicality in not depending on global variables, especially when you are TALKING about programming. When you are doing it, it’s another story. They can theoretically be the source of problems. Yes I […]
Wow, google really fell down on the job with this one, using the basic windows/IE connection settings for the internet, I know it’s easier that way, but that’s an inconvenience I don’t need. Chrome is faster, but lacking such a basic feature really makes me not want to use it. It’s almost the principal of the thing.
I had this problem while running sudo gem install anything, like sudo gem install sqlite3-ruby or what not, albeit while running Ubuntu in VirtualBox. The fix that worked for me was editing /etc/resolv.conf and using google’s public dns nameservers of 22.214.171.124 and 126.96.36.199 Now it works fine… Go figure.
Here’s the best and quickest solution I could find: dpkg -r dovcot-common dovecot-pop3d etc… apt-get install popa3d And you’re done. Not, etc.. isn’t a package, just dpkg -r the ones you installed, like dovecot-imapd or such. Fixes the issue everytime.