Skip to main content

Posts

Rails and ActiveScaffold problems

It appears that form_tag :action => 'show_results' is not the same as form_tag 'show_results' . Always use form_tag :action => 'show_results' . Also, when you get strange errors from RJS that ActiveScaffold hide method does not exists, you may need to download the latest version of ActiveScaffold and make sure that the Public folder (where the javascript files are stored) and the Vendor folder (where the plugin is stored) gets updated with that new version.

My first work with Gosu + Chipmunk

I modified the tutorial game to make the ship point to the mouse cursor. Kept the physics, resulting in an interesting game. Here is the source code: require 'rubygems' require 'gosu' require 'chipmunk' SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 # The number of steps to process every Gosu update # The Player ship can get going so fast as to "move through" a # star without triggering a collision; an increased number of # Chipmunk step calls per update will effectively avoid this issue SUBSTEPS = 6 # Convenience methods for converting between Gosu degrees, radians, and Vec2 vectors class Numeric def gosu_to_radians (self - 90) * Math::PI / 180.0 end def radians_to_gosu self * 180.0 / Math::PI + 90 end def radians_to_vec2 CP::Vec2.new(Math::cos(self), Math::sin(self)) end end # Layering of sprites module ZOrder Background, Stars, Player, UI, Cursor = *0..4 end class Cursor attr_reader :img, :visible, :imgObj, :p...

Gosu, Chipmunk in Ubuntu linux

To use the excellent ruby game framework Gosu and the 2D physics engine Chipmunk in Ubuntu, you need to copy the two .so files (chipmunk.so and gosu.so) in the /lib/ruby/1.8/i686-linux folder. You can download those files from  https://sites.google.com/site/jptarqu/downloads  (look for  gosu_and_chipmunk.tar.bz2) . I will explore the possibility of cross-platform, easy Game development using Gosu.

Session problems with Mongrel and Jruby on rails

If you get a "wrong number of arguments(2 for 1)" in the stale_session_check method when running your jruby ruby on rails application, the problem may be your sessions. Clear the sessions and delete all rows from the sessions database table if you are using one. Then add to environment.rb: config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" } The code has to be inside the Rails::Initializer.run do |config| block.

Rubyscript2Exe is not deleting the temp files once it is done: SOLVED!

Is your Ruby on rails application packed in a exe created by Rubyscript2Exe? Is Ruby2Exe not deleting the temp files once it is done? I came out with the solution of deleting the files of previous run: 1. Replace the contents of init.rb with this: require "rubyscript2exe" require "fileutils" at_exit do require "irb" require "drb/acl" require "dbi" require "dbd/ODBC/ODBC" #Add the libraries you need end if RUBYSCRIPT2EXE.is_compiled? ee_base_folder = File.expand_path(RUBYSCRIPT2EXE.appdir + "/../..") ee_folder = File.expand_path(RUBYSCRIPT2EXE.appdir + "/..") name_parts = ee_folder.split(".") curr_ee_folder_number = name_parts[3].to_i last_ee_folder_number = curr_ee_folder_number - 1 Dir.entries(ee_base_folder).each do |folder| if (folder != ".") and (folder != "..") and (folder.split(".")[3].to_i != curr_ee_folder_number) ...

Database configuration sample for accessing MS SQL in Jruby's rails

Use NetBeans to create the rails project using Jruby. Make sure you select "use JDBC". The database yml for connecting to MS SQL through ODBC: development: adapter: jdbc username: MYUSERNAME password: "14 if your password starts with a number enclose the password in double quotes" driver: sun.jdbc.odbc.JdbcOdbcDriver url: jdbc:odbc:MYDNSNAME

The easiest way to install Samba 3 with ldap as a domain controller

Acting like a wizard, the Samba/Ldap Installer found in http://www.majen.net/smbldap/ can install and configure Samba as a PDC with openLDAP backend. After finding useless most of the tutorials out there (including the official samba PDC howto) I found this little piece of magic that installed the Samba PDC in the edubuntu server at work. After running the script you need to install BIND9 (a dns server) and webmin (a linux administration web console) to set up a dns to point to your domain server. I still can only log in from windows as root tho; but I will work on solving that problem next week. Another thing I will take a look at is the NTX-grp out-of-the-box solution for open-exchange, which also includes Samba as a PDC with ldap and the dns server.
Want to migrate your rails database to a specific version? Use: rake db:migrate VERSION=# where # is 1 or 2 or 3 .... Want to migrate your production database? Use export RAILS_ENV=production Change production to any other environment you want.

Finish the new Tarpri.com

I decided to help some people by re-designing the Tarpri.com website because the joomla's ez-store component stopped working. Thanks to the ruby-powered, website generator Webgen and websites with open web designs, the process of creating the website went somewhat smooth. If you want to use Webgen to generate your website, you should download the example personal website to learn how to use Webgen. I had a small problem with generating php files; when following the example in the website for outputNameStyle which is the custom page name output format, I got an "invalid URI" message when running webgen. I solved it by using: outputNameStyle: [:name, [”.”, :lang], .php] in the meta info section of the .page file for the English version of the page. outputNameStyle: [:name, ., :lang, .php] in the meta info section of the .page file for the spanish version of the page.

Semi-Automated Mail Merge in OpenOffice

I released a new version of my MailMerger application ( http://rubyforge.org/projects/mailmergehelper/ ) . The application now uses java and ruby to automate the collection and processing of csv data to be merged. It uses a java class that can transform csv to ods (OpenOffice Calc document) and viceversa and html to ods. The Writer mail merge template must use a datasource that links to an ods spreadsheet. It works with OpenOffice 2.3. The program has helped me alot at work, where we use it to automatically take the html data produced by RenWeb's create-a-report and convert it to ods so that OO Writer can use it for mail merge. The program also allows for custom ruby scripts to process the data before is sent to Writer. I also found that the best way of doing labels in OpenOffice is to download the Microsoft Word templates from the Avery website and then convert them into odt.

Content files not available in Typing Master

I got an error when trying to open Typing Master's User Manager. The error said that the content files were not available. To fix the error, I search for any changes made to the shared Typing Master folder and noticed that the lessons folder was missing. I reinstalled Typing Master to add the folder again. Surprisingly, the re-installation did not delete any of my user data files, all of the student's information was there intact.

How to connect to CSV files using Ruby DBI ODBC and no DSN

I had a hard time finding a way of connecting to csv files using ruby's dbi through the odbc driver without using a DSN. The odbc turned not to work with Microsoft Text driver for odbc because the name of the driver has a semicolon in it. Thus, the ruby code fro the driver was splitting the name of driver, resulting in a keyword syntax error. The following is the (working) code that shows how to connect to csv files using dbi and odbc, note that I had to override require to add the fix to the odbc driver because dbi loads the driver using require : require "dbi" alias :old_require :require def require(library) old_require(library) if library.downcase.include?("odbc") define_odbc_fix() end end def define_odbc_fix DBI.class_eval 1 # DNS-less connection drv = ::ODBC::Driver.new drv.name = 'Driver1' driver_attrs.each do |param| param.gsub!(colon_stuffing_string, ";"...

Multiline and regular expressions troubles

I had some problems with Ruby on rails while working in the Bullet on rails framework. Regexp.new("(class [^$]+)$", Regexp::MULTILINE) will basically match your whole file until the end. Regexp.new("(class [^\n]+)", Regexp::MULTILINE) will match only the line that starts with "class". Also, if you have problems with JavaScript, try doing rake rails:update:javascript.

Don't drop, remove!

When you want to completely erase an scene node from your irrlicht scene, use renmoveALL and remove instead of drop. It happened to me that I was just dropping and then deleting the object C style, however the scene manager still had a grab on the node because the node was loaded from an irr file and therefore was giving me a runtime exception.

Directional player-controlled character movement

I finally was able to replicate in CalvaryGDK directional player-controlled character movement that you find in 3rd person games and platform games. The trick is to set the linear velocity to zero on all axis. Recommended for human movement behavior. The changes are in the SVN trunk at sourceforge. I will try to make a classic spaceship game with Calvary and released soon (maybe this weekend?). //move the object using forces but stop forcing after a speed is reached // only ONE of the components should be filled. RubyMethod move_forced(VALUE self, VALUE x, VALUE y, VALUE z, VALUE max_speed) { guard(GameObject.move_forced); CWorldObject *obj = internal(self); //std::cout move_forced " GetLinearVelocity().X; if (abs(obj->GetLinearVelocity().X) ApplyForce(RubyFloat::internal(x), 0.0f, 0.0f); } else { float cy = RubyFloat::internal(y); if (cy != 0.0f) { //std::cout GetLinearVelocity().Y; if (abs(obj->GetLinearVelocity()...

No bones

Don't use custom moving bones for animations. Just Take a apart every part of the mesh and export it on its own. Because they all have a 0,0,0 origin, the end result should be the same character being displayed.

Back to rails! (only for a while tho)

Got so excited with focus sis and rails at work that I decided to work on a new personal project. The new project will help new and advance users to use a simple GUI to create web applications based in rails. The project's aim is to have the same easiness to use that MS Access has. However, thanks to the power of ruby on rails, the end result could be a MS Access killer :). Tonight, I worked on the code to generate forms from a GUI wizard.