Kohana 2.x Autoasset – Automatically include relevant javascript, css and more
I’ve set up about a half dozen Kohana 2.x sites now, and one problem that I constantly run into is including javascript / css based on the controller and method for the current page. For instance, if you go to “/user/view/1″ on a Kohana site, I would like to automatically include “/javascript/user.js” or “/javascript/user/view.js”, if the files exist.
To solve this problem, I created an autoasset module for Kohana 2.x. It will not work on Kohana 3.x due to the removal of events and hooks. To use autoasset, simply load it like you would any other module, and then go into the config file and specify which kinds of assets to load. Just input the directory that these assets are stored in, the file extension, and a callback to use when rendering. I put in example entries for javascript and css as a demonstration. You can then render the autoloaded assets by calling autoasset::render(); where you want to include the assets, such as the html head tag.
On a similar note, modules like this are one of the main reasons why I am launching ko23.net. I think Kohana 2.x is a fantastic framework, and if a large community arose to provide modules that are just generally useful, then Kohana 2.x could really shine.
Kohana 2.3 community
I’ve been a Kohana user for about a year now, and every major update pleases me less than the last. I’m considering starting a community dedicated to Kohana 2.3, built around maintaining documentation (since the official site already pulled the Doxygen docs, how long until they pull the documentation wiki?), creating new modules and generally working on preserving the Kohana 2.3 legacy. Would anyone be interested in being a part of this community?
I’d like to stress that I am in no way trying to insult the developers and maintainers of Kohana through this project. Their work has been absolutely amazing, but just as they forked from CodeIgnitor when they felt it was no longer serving their needs as developers, so now am I feeling that Kohana no longer serves my needs as a developer.
I’m setting the project up at ko23.net. I’ll begin adding some functionality such as forums and module hosting / rating.
The joy of tech support
This series of emails happened about 6 weeks ago, but I wanted to store it here for posterity, because it amuses me and I can do that.
I had recently obtained dedicated hosting for a work project and was having some bizarre issues with .php files throwing a server error, even if the file was a single “phpinfo();” command, so I contacted tech support.
One remaining problem that I am encountering is getting PHP scripts executing on the site. I have a simple file, just running phpinfo(), but it is causing a server error for reasons I have not been able to figure out. I have checked file permissions, recreated the account a few times with all features enabled, and checked PHPMyAdmin to ensure PHP does work on this server, but nothing seems to be working to get this file to work. Is there a setting somewhere, in either WHM or cPanel, that I am missing to enable PHP on this account?
The response was fairly speed, but utterly bizarre.
Hi,
Please try it now. I commented out a line in your .htaccess file and it’s working now. Let us know if you need any further assistance.
How could my .htaccess file, which was blank during most of these errors, have been a problem? I inquired.
Did you do anything besides that? I added that line after I sent you the support request. When I sent you the support request, the only file on the server was a simple phpinfo() file. Afterwards, I began toying around with the Apache handlers, both in cPanel and in the .htaccess, with nothing working.
Ah, he forgot to mention something.
I did re-compile PHP on the server for good measure since the file should have worked, but the error log was still showing an issue with the .htaccess file so I commented out the handler line and it started working. Please let us know if you need any further assistance.
Amazing!
MySQL dump of every country and state in the world
As part of a recent project, I needed to compile a list of every country and first level administrative subdivision in the world. I started with the ISO 3166-2 list, but later cleaned up certain countries that had inaccurate data. I also needed timezones for every state, so I put all of those in as well.
This zip file contains a single SQL dump for two tables – region and subregion.
Region contains 248 entries, with the following data for each country: ISO code, 3 digit ISO code, fips code, country name, continent, currency code, currency name, phone prefix, postal code regex, languages and geonameid. Subregions contains region ID, name and timezone. The timezone format is “America/Los_Angeles”, “Europe/Madrid”, etc. Unfortunately, some states have multiple timezones and this is not taken into account.
There might still be some issues with some countries not having an accurate state list, but this list is more comprehensive than anything I was able to find online.
Download the list: region.sql
Build 20100609
Posted by visual77 in gaming, programming, sc2build on June 15, 2010
The newest iteration in my StarCraft II Build Order Calculator is a minimalistic approach, in comparison to the previous builds. Unlike the last few ambitious builds that attempted time and resource calculation, this is an attempt at the absolute basics. It is also my first build calculator that is somewhat usable right at the moment, as opposed to merely offering a glimpse at where I want to go with this system.
This calculator contains all units for all 3 races and allows for race changing and resetting the build. It also begins to toy with styles and the UI, although I didn’t spend much time other than getting elements in the rough position that I would like them to be.
I dropped back to a more minimal approach because I felt like the more advanced approaches I was working on were going in the wrong direction. I’d ultimately like a more advanced system, but I want to rewind a bit and go back to basics and consider alternative approaches to the other systems, that relied heavily on large data structures to store data, at times storing it repeatedly for different purposes.
Build 20100524
Posted by visual77 in gaming, programming, sc2build on May 30, 2010
I completed the third JavaScript iteration of the StarCraft II Build Order Calculator this morning and put it online. It took a few days longer than I expected, but I also drastically changed how the data is being stored for the build order. In my previous builds, I stored the data with the time as the lowest level element, whereas this build stores the unit as the lowest level element. This makes it easier to see what the unit is doing (and thus, what it is allowed to do), but makes it harder to display the timeline.
I also stored unit actions (such as build Probe, warp in Pylon, etc.) as functions within each unit. As I wrote the functions, it quickly became apparent that a huge number of functions are identical and should only be written in one place.
This build shows me the viability of storing unit actions within the function and keeping track of unit timelines within the unit, but also shows the weaknesses of displaying the timeline when I have to scan every unit for every second to see what has been done. It still does not take into account that you need a Gateway before you can make a Zealot, but I chose to not pursue that in this build when all of the flaws of this build became apparent. It does, however, take into account queuing and will not let you build more than 1 Probe from a Nexus at any one time.
I will begin my next iteration very soon and hope to have that online within the next few days. Each iteration definitely teaches me a lot about what will and will not work. I am still very far from a final build, but I still think it is possible to get the final build online before the game launches on Jul 27, 2010.
The next iteration of the S2BOC is online
Posted by visual77 in programming, sc2build on May 24, 2010
In my last update on the StarCraft II Build Order Calculator, I said that I was going to have this next version work on building queues, but I decided to work on the URL sharing instead. The newest version of the S2BOC still doesn’t account for queues, but you can now send someone the URL to share build orders.
This URL sharing is one of the most critical requirements of this system. This calculator is designed to aid strategy discussions and a key part of that is showing a friend your strategy. As you update your build order, the URL will be modified, so you can send the build order at any time and anyone going to that URL will see what you see.
This calculator also allows you to switch between Terran, Protoss and Zerg, albeit in a clunky way that will be addressed before the final build. In order to change race, change the URL to start the build order string (from # to the end of the URL) with T, P or Z. In both FireFox and Chrome, I had to refresh the page after changing the URL before the new race properly appeared.
StarCraft II Build Order Calculator
Sample Build (9 Pylon / 12 Gateway Protoss build)
First interactive prototype of sc2build is online
I have finished the first interactive prototype of the StarCraft 2 Build Order Calculator and placed it online with the rest of my iterative development tests. This JavaScript prototype is just a proof of concept and is missing many required features, but it does show the possibilities of the system.
This build is the first JavaScript prototype of the S2BOC. I decided at the very start that I would be building this in a client side language to reduce server strain, and so doing tests in PHP is very impractical. It uses the jQuery library and contains a custom extension to generate the build order. It shows off the abilities of the system to add units and calculate the amount of minerals available at any given time, as well as calculate the earliest moment that a unit can be built.
My next iteration should be online and viewable this weekend. This iteration will contain features not shown in this version, like taking queues into account and building requirements. I estimate there will be another 10-12 iterations before I consider writing the final version.
Iterative Development for Economy Calculator
Posted by visual77 in gaming, programming, sc2build on May 19, 2010
This iterative build was to test the economy calculator at different time intervals. I created an array to store information on 5 basic protoss units – Nexus, Pylon, Gateway, Probe and Zealot. I then wrote some quick calculators to accept a time, in seconds, and return the amount of minerals available at that time. The display is fairly minimal, just showing economy, but various units and builds were constructed at certain times.
The calculation is based on finding out how many probes exist at this time, how long they have existed, and multiplying that by 5/6. 5/6 is the number of minerals gathered per second per harvester (before saturation, at least). Once I have found the total minerals gathered, I get a list of all units that have begun construction at that time and subtract it from the total and return it.
The formula for calculating wealth seems okay, but the initial array contained far more data than I ended up using and the formulas were a bit too hard coded. Things like MULE and Chrono Boost are not being accounted for, and supply count is ignored as well.
I like the idea of a function being passed a time value and returning a snapshot of the build status at that time, and the array storing the build information also containing when each item was started. This system would fairly easily allow new commands to be inserted mid way through the build.
I definitely need to make the calclations more dynamic, though. I’m also still unsure of how to handle the starting Nexus and 5 Probes. This system puts the build time at -100 and -17, respectively, and always adds 700 minerals to the mineral count.
All in all, this iteration did show some interesting ideas, particularly with where to store data on all of the units. I ended up sliding it in as an array inside the build class, but that seems impractical. I should probably set a race as a class, units as a class, buildings as a class and special abilities as a class. My next experimentation will involve testing those methods for viability.
StarCraft II Build Order Calculator
Posted by visual77 in gaming, programming, sc2build on May 18, 2010
I’ve recently begun work on a new project that should see the light of day in time for StarCraft II to launch on July 27. The project, being hosted over at http://sc2build.com, is the StarCraft II Build Order Calculator. The project aims to take the ease of use and share-friendly nature of World of Warcraft talent calculators and apply it to StarCraft II build orders.
The project is just beginning the iterative development phase, with some small scale tests of single aspects of the system. I began writing my notes on the site in plain text, but it quickly became apparent that I will have enough notes to require a full fledged blog.
Expect to see a flood of posts in the coming days as I think aloud on how to build this system and test various methods of implementation. I will be building it through iterative development, and as such there will be many micro tests in the coming weeks of single aspects of the system.
The first test that has already been pondered upon and attempted once is how to store the build order data in a URI without that URI becoming ungainly in length. You can see my notes on that test and see a sample of this one attempt in the iterative development section of that site.