Posts

Showing posts from July, 2016

How to fix the Unbound module Graphics in an ocaml project

Image
From ~/pr/gitl/ocaml-gol In a constant effort to learn new programming languages, I'm currently trying to use ocaml , a free and open-source general-purpose, multi-paradigm programming language maintained at the Inria . It's basically an extension of Caml with object-oriented features. I'm mostly interested by its functionnal and pattern matching features but the module part of the language can be a bit difficult to understand for someone with little to none ML (Meta Language) background.   The error When trying to use the graphics module to create a graphical window and go just a little further than the simplest helloworld program, here is the result : If the project uses dune : (executable (name ocaml_project) (libraries lwt.unix graphics) ) with this code : let () = Printf.printf "Hello, world!\n";; Lwt_io.printf "Hello, world!\n";; Graphics.open_graph " 800x600";; The first times I built this project running the du...

How to remove the first character of a ruby string

Image
Recently, I had to remove the first character of string in a private nanoc -powered project.    I easily found a quick and elegant way to achieve this and according to this stackoverflow answer  it seems the fastest. path="_theString" path[1..-1] # => "theString" And to complete this post, if you plan to use this often and you want to remove one or more leading letters, you may want to override the String class to remove the first n characters : class String def removeFirstChars!(how_many = 1) self.replace self[how_many..-1] end end And you can use it on every String variable : str="Aze" str.removeFirstChars! # => ze # or str.removeFirstChars! 2 # => e The stackoverflow answer also gives the code and benchmark results to achieve this with an Array In this initial post, the function is called eat and it shows several other useful utility functions.

RainbruRPG's client is now in src/

Image
Like in this previous post , today's commit  #826  is also on source code reorganization. This time, the client source code was moved from the client/ subdirectory to the new  src/ development tree. Original news This change includes C++ source code and   Ogre3D configuration files templates (. cfg.in files) , used  by cmake  to generate plugins.cfg and resources.cfg . The m4-based  autotools   files were deleted while the remaining files, including TODO and ChangeLog, were moved to the  OLD/client  directory. To make the whole project consistent, the last to-be-moved directory is services/ . 2022 update Article's links are now dead since RainbruRPG 's now hosted at bitbucket . To be complete, the current directories from src are : client : the game client source code; examples : some code example for the main project libraries; logger : the logger library used both by client and server; serve...