I had a quick session showing of what CoffeeScript can do, including a simple task list manager (non GUI). The task list manager is made up by two classes. Task, which is the regular task instance containing a name and function for setting it to done or not done. TaskList which is the manager of tasks which can create and read all the tasks. Both files can be compiled into a js file using:
coffee -cj todo.js task.coffee tasklist.coffee
This is what the task.coffee file looks like this:
Sounds pretty sweet, but what does it all mean? Ryan Dahl does a pretty good job explaining it, check out the video below.
So what can I do with node.js? Well for one thing, one big thing, that I will use it for is as a game server. Currently I’m doing a HTML5 game with network support for more player. It will be more of a tech demo then a released game. To do it even faster I will use the awesome node plugin called nowjs, check out some examples of nowjs here. More info as it advances :^)
The box that contains the artifact to unlock your mind.
Behold! Every item in the box fits perfectly, easy to unpack an pack down.
The USB dongle for connecting to the EPOC headset.
16 Felt sensors in their hydrator pack. All these sensors need to be soaked and attached to the headset before each use. After use, they should be removed from the headset and put back into the hydrator pack.
Contact lens liquid, used for soaking the felt sensors. Had to use a lot the first time I used the headset. This is way better then using some sort of gel, doesn’t get sticky, messy and no smell.
USB cable, for charging the headset. You can’t use this as an alternative connection as far as I know.
And here is the headset itself! Had a bit of a hassle the first time putting it on, but just after some uses I can put it on with ease. It doesn’t feel weird wearing it, and my glasses is not in the way. But it’s really tedious installing and removing the felt sensors each time I want to use it.
Another post will come soon where I will show it in action. It will also feature me wearing this dorky thing :^)
I recently ordered a dev kit from Emotiv and just found out that it will be here this Friday!
So what is this Emotiv stuff?
Emotiv is the company behind the EPOC neuroheadset, a wireless headset that reads neuro-signals basically. I won’t get into what a neuron is but if you want to read more about that sort of stuff check out the wikipedia article. It can read two types of major neuroscience branches (as they are called on the wiki) Cognitive and Affective. To make this easy we could say that the cognitive part is your conscious thoughts and intent while the affective part is your emotions. It can also read your face expression and has a gyro.
So what can you do with it?
A lot! Imagine using this headset in games, where you use your thoughts as input. Some people has connected it to their homes to switch on and off lights by just thinking about it. Another guy built it to control his wheelchair by using facial expressions. I can’t wait to get started, I noticed this project 2 years ago but I don’t think they shipped internationally by that time.
it currently only supports Windows but both OSX and Linux support (yay!) is in beta stage. So right now the dev kit contains a few dll files that you can access with C\C++, C#, Java (with jni), mathlab (I think) and other languages where you can communicate with win dlls. I’ve that there is a Unity plugin for this as well. The dev kit also contains a few applications such as a control panel for the EPOC headset.
Is this the future for gaming and human to device interaction? I don’t know, but I will blog about my experience of it when it gets here. Currently my only concern is that it has some latency, making action based games hard to create. Check out the videos below to see more of this awesome product!
I’ve hear rumors that this little baby will be released November\December this year! I will most definitively get me one of those for experimenting, especially for gaming, see the sprite and graphics tech demo below.
So if you never head of Raspberry Pi (not many have) here is a quick summary.
It’s a single board computer, unlike it’s ”competitor” Pico-itx which is only a motherboard. So this means that all the ports, memory, cpu, gpu etc. is already mounted on the board. It will be bundled with Debian but any other OS compatible with an ARM processor should work (Android?). So what’s so awesome about it? In my opinion these three aspects are more then enough to buy one:
- It’s cheap, they got two models, one budget\lite version for $25 and one more featured version for $35. The later one has more RAM, Ethernet and one more USB port.
- Power,the low-end model only consumes around 1W on full load and has external PSU like laptops. This makes it smaller and more portable. The high-end requires more power, but still unconfirmed of how much more. And you can also run it on 4 AA batteries!
- The GPU and HDMI. Yeah, you heard me. On board HDMI. And it’s powerful too. It can render a full HD 1080p movie directly to a television or monitor and demos has been shown where it runs Quake 3 at 1080p(!). Check the sprite demo below, and make sure to visit http://www.raspberrypi.org/
Setting up the environment variables JAVA_HOME and JDK_HOME is easy, just type this into the terminal:
Note: No trailing slash and point to the root of the platform, not /bin. And no ”quot” chars.
This works great until you reboot or re-login. You may know that you can add these two lines to .bash_properties located in your home folder. But you won’t find that file in Ubuntu, instead add these two lines in the bottom of .bashrc.
Now log out and in again and try to type this in the terminal:
If you see: /usr/lib/jvm/java-6-sun for example, then your done! Recheck the .bashrc file in your home folder if you only see blank space.
You can do this for all the custom environment variables you want to add to your Ubuntu account.
Easy as pie with a GUI (like tortoise or rapidSVN), but sometimes you don’t want a GUI (for numerous reasons). I struggled with this for a while and found a solution. My biggest issue was to find the actual revision --limit was my savior. It may not be the best but worked great for my purpose.
To locate the revision where the file was deleted, use svn log --verbose --limit 15
I add --verbose to see the files and not just the comments and revision numbers and --limit 15 to only get the 15 latest revisions (our HEAD is at 9780). Now locate the revision where the file was deleted, marked with a big D.
Then run svn up -r revision_number filename_or_folder
When I’m coding, or actually whatever I’m doing at work, I tend to forget common things. By things, I mean commands, code library names, processes, code snippets, environments, softwares etc. I used to have a notepad with this common stuff in case I forgot them. But now I’ve lost that notepad… Can’t find it… But I learn on my mistakes! I’m going to use a digital notepad from now on for safe keeping. I was planning to use google docs, but then I realized, why keep this common stuff to my self? Why not share it for other people having the same problem?
So, that’s why I created this category called Stickies on my blog, for post that I might need later on, for safe keeping or just a memo. Feel free to comment on my ”Stickies” if you have a better way of solving the problem.
A common thing I’ve noticed is that people that begin to code java (or any other language supporting ArrayLists) can not see the differences and uses ArrayLists before traditional Arrays. So here is a quick description of both and when to use them.
An array has fixed length which is set when it is created (using the new keyword), it cannot grow dynamically. It can be 2-dimensional, 3-dimensional or more. Don’t really know if there is a max matrix, guess not, but only as long as your computer has ram for it. Arrays are quick and always start with index 0, a common beginner mistake is to set the array length counting 0 as a value, see below.
byte myArray =newbyte;byte=1;byte=2;//Won't work as the length of the array is only set to 1!
Arrays are good to use when you know the maximum length after code compilation. An example related to game development is Tile Maps, when loading the map data you should already know how big your level is. This is true for most tile maps. Another example could be if you want to enter player High-Score data into an array before converting it to JSON or XML to a webservice such as: score, name, email, time and ip; total length of 5.
ArrayLists are very similar to regular Arrays, you store stuff in them. But instead of having a fixed length ArrayLists grow each time you add another element. Unlike Arrays, ArrayLists are filled with data through the method add() and you get the data by using the method get(int index). But under the hood of an ArrayList lies an Array. So each time you call the add() method you clone your current Array in the ArrayList into a new Array with the new fixed length of n+1, where n is the current length, and then the new data is added. This can slow down performance of course, but it’s a cool feature if you need dynamic arrays. I use a custom built version of ArrayLists in my game for handling all the objects.
Here is a performance tip: when creating your ArrayList you can set the built-in Arrays fixed length using ensureCapacity(int minCapacity). This way the ArrayList does not clone the current Array when you call the add() method until it reaches the minCapacity.