Archive for category Programming

Visual Studio Won’t Create a New C++ Project

I had a problem with Visual Studio after a service pack update. I was unable to create a C++ project. The project dialog would just disappear and then come right back. I'm not sure if the SP1 update caused the issue, if it was a combination of SP1 and a custom installation directory of Visual Studio, or something entirely unrelated. I searched for a fix all over the internet and came up blank. I decided to try uninstalling and reinstalling Visual Studio. However, once the uninstaller opened I decided to give the repair a try. After repairing the installation and rebooting, I can now create C++ projects again. So if you are having a similar problem, give that a shot. It worked for me. Sometimes it's a simple fix.

, ,

No Comments

GM48 #6 Submission – Ant Agonists

Last week I decided once and for all that I'm going to get into game development. I have a lot to learn, don't get me wrong, but it's a real fun thing to get into and I'm nearing the point where I have the skills to do it. My main problem is my art skills are lacking quite a bit at the moment. I'm concentrating on sprite creation for 2D games and modeling/texturing for 3D games. Monday of last week (April 8, 2013) I found out about Unity3D. I fell in love with it. Up until this point, I've been working with Java to make mini-games, as a learning experience, but I don't really like mucking about with setting up Java. I dislike working with class paths, and I don't particularly care for the distribution side of software that is created with Java. I may still venture into that but I want to turn out some actual games first.

Unity3D allows you to create your games in a GUI environment and it handles scripting quite well using your choice of C# and Javascript. It is actually quite nice. I was amazed that I could write some C# and the variables turned into interface options inside Unity itself. The problem for me at this point is that I don't have great modeling skills, but I've started watching Blender tutorials to develop that skill. So for a couple of days I was working on Blender. Then I happened upon a post about Game Maker. I've always been interested in many types of games 2D as well as 3D, and I wanted to get my hands dirty with some 2D sprite making. It occurred to me that it would be a good idea to make a few 2D games before diving into 3D.

I tried out the free versions of both Unity3D and Game Maker Studio. At this point I should point out another feature of both of these products that really drives me toward utilizing them instead of hand-coding games from scratch. They both offer exporting to various platforms. With Game Maker you have to pay for the ability, but you can write your game once and export to Windows, Windows 8, Linux, Mac OSX, Android, and HTML5. With Unity3D you can export to a ton of things with the free version, including XBox360, Windows, Mac, Android, and iOS. However, there are some things you don't get with the free version like some shaders. The cost of the non-free version of Unity3D is also $1500. For some reason I think that price point is a little high for their maximum profit. I could be wrong, but if Unity went for $200, I would have already bought it, and I'm sure there would be thousands of others who would fork over that much for it.

At any rate, after using Game Maker for a couple of hours I decided it is something I want to devote some time with, so I purchased the pro version on Thursday (April 11). The next day I found out that there was going to a 48 hour Game Maker competition on the /r/gamemaker subreddit. I entered it and after 48 hours of writing a game with a tool that I had just bought, this is what I came up with. I give you Ant Agonists.

»crosslinked«

No Comments

PHP Singletons

It has been quite some time since my last post. However, I will be posting a few object oriented PHP tips over the next few days, especially in regard to design patterns. My first post on the subject will deal with Singletons. As a side note, don't overuse any of these design patterns. They have their purpose and even though you may be tempted to use them in everything after you learn them, notice their benefits and work with them where they can benefit your overall system design.

Singletons are useful when you want only one instance of a class. Thus their name. You may scratch your head and wonder why you'd want to use this design pattern. There are some advantages to it. Firstly, you will reduce resource requirements for your application. It guarantees that you will only have one object taking up memory. Secondly, a singleton can be useful for simulating global variables. You can set a property of the object and access it anywhere in your application.

In a PHP application this can come in handy when you are using controllers in your own MVC framework, when you have a helper class that you only need a single instance of ever, and in any other case where only one object of a class is needed/wanted.

Here is an example of a PHP Singleton:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
  class Singleton {
    private static $_instance;
    private function __construct() {}
    public static function getInstance() {
      if(!self::$_instance) {
        self::$_instance = new self();
      }
      return self::$_instance;
    }
  }
?>

We have a private static property called $_instance. This will hold our single instance of the class. The constructor for the class is private so it can never be called from outside of the class. Thus, it can not be called directly. We call the constructor inside the public static method getInstance(). The whole purpose of this static method is to check to see if there is an instance of the class and if not, create it. It then returns that single instance. So the $_instance property of the class holds the single instance of itself. The recursion can be confusing.

In order to use the singleton, you simply call the static getInstance() method and assign the reference to a variable, or if you only need to execute a single method, you can call the method in a chain. Here is an example each:

1
$mySingleton = Singleton::getInstance();
1
Singleton::getInstance()->someMethod();

No Comments

404 The entry or revision was not found in the repository. Git Repo in Redmine

If you are getting this error when trying to add a Git repository to your Redmine installation, you could be running into the same problem that had recently. The quick and easy solution for the exact issue I was running into is as follows...

The path was incorrect. I'll give a quick example.

Let's say the path to your Git repository is /home/user/repo, when you add it to the redmine installation use: /home/user/repo/.git as the path. It's that simple. This is here as a simple reminder to myself of the correct way to set this up.

1 Comment

New Session Cookie Created on Every Page Refresh in CodeIgniter

CodeIgniter's way of handling session data is slick, and I use it a lot. However on my current project, I went overboard on my configuration changes and accidentally caused a problem that had me scratching my head for a few minutes. I noticed that session data wasn't persisting and that my sessions table (I opted for database storage of my session data) was filling up with new rows of session data every time I reloaded a page in my project. This prevented my login functionality from working.

The solution to my problem was a configuration detail. I had set $config['cookie_domain'] to the domain name I will eventually use for the site. CodeIgniter didn't like this because my development environment is not on that domain. So it was creating new cookie/session data every time I loaded a page. The problem made sense after I thought about it for a bit. I remembered that I had set a few extra settings in the config, and sure enough, that was the winner.

The problem can happen when other settings are incorrect as well. So pay close attention to those settings, and look there first if you notice that sessions are being created on every page load.

, ,

1 Comment

Clickbank Analytic Software

There's a site called cb-analytics.com which has always been a great resource for information on Clickbank products. However, I've always found the site hard to navigate and I wanted a site that showed some of the "hot" clickbank products. So, I've written a site called cbniches.com which I hope will rectify these issues.

The site shows all the latest products in each category and shows gravity and earnings per sale. It also has a graph for each product to show gravity over time. I think this will be pretty helpful to affiliate markets looking for new products to promote on Clickbank. Check it out at http://cbniches.com. I wrote it with the latest version of my LavaPHP framework, another product I've been developing as open source. LavaPHP can be found on github, but it's still in early development.

, , , ,

No Comments

Gnome 3 + Netbeans Revisited

I wrote at some point in the past about a small bug in Gnome 3 where Netbeans menus behaved strangely. My solution then was to switch to Gnome classic. Well I started using Cinnamon recently and found that it has the same issue. So I wanted to find a better solution.

I came across a strange way to fix the issue. I tried it out, and it worked beautifully, even if it is weird.

Unmaximize Netbeans so that it is in a Window on the desktop. Grab the top left corner of the Window and move it all the way to the top left side of the screen. Now, maximize it. The menus work again.

It's weird, but I'm glad it works. I spend most of my time in Netbeans, and I'm really digging Cinnamon.

, ,

No Comments

Introducing LavaPHP – Yet Another PHP Framework

I've used quite a few PHP framework to varying degrees, and like many other PHP developers, I've decided to make my own. Of all the current frameworks available, I prefer CodeIgniter, because it is easy to use, has great documentation, and generally stays out of your way.

Everyone has their opinion of the best PHP framework, but I like the ones that let me write PHP and don't throw a lot of features that I don't need into the mix. I found that no matter what PHP framework I was using, I was always creating a table for users. I was always creating login functionality for users. I was always creating email confirmation functionality for users. I was always creating an admin interface for working with my configuration. I was always creating classes that helped me work with web services/REST APIs. I always need a small web service of my own for Ajax functionality. I always needed to add curl functionality just in case the hosting provider had fopen disabled (which most do).

Those were the things I needed. ORMs are great and all, but I really didn't want to learn proper YAML syntax just so I could setup automatic object models for my database tables. Creating models for my database isn't that much of a chore. Creating a complete user system can be.

So, I set out to create a framework that I can use for my own projects and have all the functionality that I find I usually need right out of the box.

Another thing about frameworks is that they are designed to make enterprise level sites. They aren't designed to create software system which can be distributed. By that, I mean I wanted to create a software package that could be installed by end users and used by them to create their own websites (custom CMS system with a specific purpose). A normal framework doesn't work well in this area because of the way views are usually handled. Mainly, I wanted third parties to be able to create themes for my CMS systems without much effort. With something like CodeIgniter, I could use a templating engine via a plugin or Codeigniter's own minimalist template engine, but I don't like take one piece of software and adding on a bunch of plugins.

First you have to learn how to use the plugin. Then you have to hope that there isn't a bug in the plugin that will spring up in your app. Then if there is some small customization that needs to be made to the plugin, you could spend days trying to figure out a way to make it work with your system, when it would have taken less time to just write your own. Using plugins also feels a bit like cheating to me, as well. I want to know every little part of my system, so that if a bug comes up, I'll know right where to look or at least have a decent idea where to look.

With all that said, I'm announcing my PHP framework. I've written it completely from scratch and I'm hosting it on Github. I also have purchased the dot com for it. I'm calling it LavaPHP. The motto will be "LavaPHP - Add a little lava to your LAMP" and it will have a lava lamp as it's mascot/logo. If you'd like to help with the initial development, hit me up and fork the project here: https://github.com/lpcustom/LavaPHP

, ,

No Comments

lwjgl.dll: Can’t load IA 32-bit .dll on a AMD 64-bit platform

If you encounter this error while trying to write a game on a Windows 64 bit system using Slick2d, I can give you some insight into how to fix the issue. I'd ran into this issue some time ago, but I don't remember if I posted about it or not. I solved the problem then by using a recompiled version of slick2d. It worked well, but I did something different this time around.

I downloaded the latest version of LWJGL and used it instead. The process of importing the libs is much the same except you use the new LWJGL and its natives instead of the ones included with slick2d. If you need help getting the imports correct, leave a comment and I'll go into it in more detail.

, ,

1 Comment

jMonkeyEngine “An instance of the program cannot access specified user directory”

This is a simple issue and most Linux users can probably figure it out rather quickly. I don't mean to offend anyone, but the error message is pretty straight-forward when it comes to the problem. However, I'll explain it to those who run into it and want to know how to fix it. Then again, I may be the only person who runs into this problem. Either way, I'm posting it for anyone who may need it.

The problem stems with the installation of jMonkeyEngine. The installer is a .sh file which which can be executed like so:

1
sh jME3_SDK_Beta-Linux.sh

However, if you are like me, you may have ran it with sudo like this:

1
sudo sh JME3_SDK_Beta-Linux.sh

The good thing about using sudo is that the program will be installed for all users on the machine. I've not ran it without sudo to see if it will install for only the user running the installer, but I'm assuming that it will.

After the installation occurs, it asks you if you want to start jMonkeyEngine. If you answer yes, it will start it as root, and it will write it's hidden users directory in your home directory. The home directory will have root:root as the owner because the program was first started by the root user.

So when you go back and run the program again, it will not have access to the required folder. The solution is to change the owner of the folder. This is accomplished simply by typing this in a terminal while in your home folder (the terminal should open in your home folder automatically, but just to make sure we'll change directory into it first). In the following example the word "username" should be replace with your actual username.

1
2
cd ~/
chown -R username:username .jmonkeyplatform

You should now be able to open jMonkeyEngine. The -R, for those of you interested, means "recursive", which will change the owner of all files and folder inside of .jmonkeyplatform, not just the folder itself.

, ,

No Comments