YARG: Yet Another Racing Game
So I got a little board one night so I wrote a little HTML5/Javascript game. It originally took about 6hours but I’m continuing to improve it.
It’s a tribute to an old TI-83 calculator game I played back in high school.
I’m planning on adding a few things:
- Best lap ghost
- Lap timer
- Track editor/sharer
- Other social stuff
Its also up on github if your interested in contributing https://github.com/garrows/Yarg
Let me know what you all think.
Running Node.js and Apache Together using Mod_Proxy
Intro
Lets say that you want to experiment with Node.js or you want to start to leverage its awesome features but you don’t want to throw away all of your existing Apache compatible website. This tutorial will show you how to configure your existing Apache server to forward requests for a specific folder to Node.js. I’m going to set it up so Node.js handles the /node/ folder and Apache handles everything else.
Assumptions and My Setup
- Apache server running on port 80
- Node.js server already running on port 8080
- Ubuntu Server 10.04.4 LTS
- Your site is example.com.
Configure the Proxy
Enable the mod_proxy and mod_proxy_html Apache modules. They should be available by default so just enable them with the a2enmod command.
sudo a2enmod proxy
sudo a2enmod proxy_http
Now edit your virtual host file (/etc/apache2/sites-available/example.com.conf) to have reverse proxy settings. Within the node, add the following:
ProxyRequests Off
Order deny,allow
Allow from all
ProxyPass /node http://example.com:8080
ProxyPassReverse /node http://example.com:8080
Save that and restart apache with:
sudo service apache2 restart
Success
You should be able to navigate to http://example.com/node and you will magically get your node server’s responses.
Troubles?
If you got a “503 Service Temporarily Unavailable” error, that means your node server isn’t serving on port 8080.
Other Options
Of course you could do things the other way around and run Apache through Node.js which probably has some minor performance benefits. There are a couple of existing packages that do this however I have yet to try them.
- node-http-proxy : https://github.com/nodejitsu/node-http-proxy
- Bouncy : http://substack.net/posts/5bd18d
Thanks ZeKK for the links.
Further Reading
The mod_proxy documentation http://httpd.apache.org/docs/2.0/mod/mod_proxy.html
Node.js Compile & Run Script for Windows
When developing on node.js, I find that I do this routine a lot:
- Make code change
- Kill/restart node.js process
- Reload browser
c:
cd C:\yourworkingdirectory\
taskkill /IM node.exe /F
taskkill /IM firefox.exe /F
rm server.js
type globals.js game.js nodeserver.js > server.js
start "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "http://localhost/"
node server.js
P.S. Yes, sometimes I do develop in windows. Until AAA games are developed for linux I will continue occasionally.
Install and Setup Node.js to Run Forever
Obsoleted!
This article is pretty old and was never very good to start with. A much better solution is Deploying Node.js With Upstart and Monit
Install Node.js
$ sudo apt-get update
$ sudo apt-get install git-core curl build-essential openssl libssl-dev
$ git clone https://github.com/joyent/node.git && cd node
I had trouble using the latest (head) verson of node so I used an older version which is optional.
git checkout origin/v0.4
If you don’t want the older version, skip the previous command.
$ ./configure
$ make
$ sudo make install
$ node -v
Install Node Package Manager (NPM)
$ curl http://npmjs.org/install.sh | sudo sh
$ npm -v
Install Forever
Next, lets make it persistent using Forever, so once we logoff it still runs and will restart even if node throws an error.
sudo npm install forever --global
Make a Test Script
Create a file called test.js and paste this into it.
var util = require('util'),
http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello, i know nodejitsu.')
res.end();
}).listen(8000);
/* server started */
util.puts('> hello world running on port 8000');
Run it Forever (until you kill it)
forever start test.js
You should be able to see it here
ps axl | grep node
And here
forever list
You can kill it using
forever stop 0
Where 0 is the index of your code in the forever list.
Time to start javascripting.
References
Installing Node Wiki https://github.com/joyent/node/wiki/Installation
Installing Node.js and NPM on Ubuntu 11.04 http://www.giantflyingsaucer.com/blog/?p=2775
Keep A Node.js Server Up with Forever http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever
Keyboard Shortcuts For Reddit
Being a fan of Google Reader’s keyboard shortcuts, I decided to implement similar features in Reddit using a bookmarklet.
All you have to do is create a new bookmark, paste the following into it, then when you are in Reddit, click the bookmark.
javascript:var s=document.createElement("script");
s.type="text/javascript";document.body.appendChild(s);
s.src="http://www.garrows.com/reddit.js";
void(0);
The keys are:
- j : next
- k : previous
- v : view selected in foreground tab
- o : open selected in background tab
- u : upvote
- d : downvote
- c : comments
- s : share post
- a : save post
- h : hide post
- + : increase bottom padding
- - : decrease bottom padding
As a bonus feature, once you reach the last item, it will automatically load more at the bottom of the page.
Let me know what you think. Hopefully the wonderful developers at reddit will add this script to their standard page so you wont have to keep clicking the bookmarklet.
How to Migrate a Web Server Running Apache, MySQL, WordPress and Drupal
Well folks its time that my old home hosted server is retired. Which means I have to migrate all of my 5 websites to a new server. Thanks to the way apache, MySQL WordPress and Drupal work, its easy.
1. Copy Apache Config Files
# ssh username@oldserver
# scp /etc/apache2/sites-available/ user@newserver:/etc/apache2/sites-available/
This will copy all the apache config files over to the new server. Now enable all the sites you copied by creating a symbolic link for each .config file you copied in sites-enabled.
# ln -s /etc/apache2/sites-available/yourwebsite.com.conf /etc/apache2/sites-enabled/yourwebsite.com.conf
or use the command a2ensite which does the same thing for you
# a2ensite yourwebsite.com
Restart apache for the changes to take effect.
# /etc/init.d/apache2 restart
2. Copy Your Websites
# scp -r /var/www/ username@newserver:/var/www
Default WordPress and Drupal installs are just files and we have now copied them across. However all the content, comments etc are stored within MySQL so lets migrate that now.
3. Migrate MySQL
Start by being logged into the old server.
# mysqldump --all-databases -u root -p > backup.sql
# scp backup.sql username@newserver:/home/username/
# ssh username@newserver
# mysql -u root -p < backup.sql
What we did here was use mysqldump to script every database and its contents into several sql commands. Then we copied them to the new server and piped them into the new sql server. All our databases, users and table contents have been imported. Magic.
4. DNS Migration
Now all you need to do is reconfigure your DNS servers to point to the new IP address. Chances are your not hosting your own DNS server so you will have to update them using your provider’s web interface. A word of advice though, create a new entry like test.yourdomain.com and point it to the new server first to make sure everything works.
Update Dell Streak To Froyo Officially and Easily (without chewing up your 3G data)
EDIT:
There are some newer versions as of 30th November 2010 for more baseband numbers.
GAUSB1A111800: Streak_318_12821_00.pkg
GAUSB1A120900: Streak_318_12821_00.pkg
GAUSB1A121100: Streak_318_12821_00.pkg
GAUSB1A120621: Streak_319_12792_21.pkg
GAUSB1A120821: Streak_319_12792_21.pkg
GAUSB1A130112: Streak_324_0_12.pkg
GAUSB1A131312: Streak_324_0_12.pkg
Introduction
The long awaited Android 2.2 (Froyo) update from Dell has officially been released. Since I don’t have wifi at work and I don’t want to download 150MB over 3G I decided to do some reverse engineering upgrade pain free. I’m also heading out of town this afternoon so I couldn’t just wait until I got home.
My Specs
OEM Version: GAUSB1A111800
Current OS Version: 1.6
Carrier: Optus (Australia)
Unrooted. Unlocked (by default).
Warning
This update only works if your OEM Version ends in 00.
Procedure
0. BACKUP. Dell provides a nice program called ‘Backup & Restore’ in the Android market. Install and create backup.
1. Download the pkg file from http://mobileupdate.dell.com/PackageProductionLocations/Streak_315_12332_00.pkg on your pc or android. I used my pc and would probably recommend you to also to minimize chances of download corruption. When installing, it reveals itself as being built on 5 Nov 2010 at 1:16:55.
2. Copy it to your sdcard.
3. Rename it to Update.pkg
4. Turn off your phone.
5. Hold down the volume up, volume down and power button together until it turns on.
6. Select option 2 ‘Software upgrade via Update.pkg on SD Card’ by using your volume buttons and select with the shutter button.
7. Think, did you remember to backup?
8. Press the shutter button to begin.
9. Go get a cup of coffee because the install takes about 5mins.
10. Rejoice! If nothing went wrong, you should have booted up into Froyo.
Problems?
There have been a lot of reported problems with the build however I have been pretty lucky with this.
Originally, my standard browser wouldn’t load anything but every other application (opera, maps) would. I fixed this by removing a mystery proxy server that was in my APN settings.
If you have troubles with the newer build, you could try this older one http://mobileupdate.dell.com/PackageProductionLocations/Streak_309_0_00.pkg which worked for me originally.
Also, if you are finding it slow and laggy (which I’m not) you can try following these instructions http://forum.xda-developers.com/showthread.php?t=848487 but I haven’t tested this yet.
Let me know if anyone has any other problems.
How To Setup and Test Node.js, CouchDB and MongoDB
Introduction
A project using a combination of Node.js and CouchDB can solve some pretty difficult problems with ease. Since originally writing this, I decided to use MongoDB instead of CouchDB and have now added in the instructions. I am attempting to solve one that involves consolidating several conflicting data sources into one document orientated database while providing a web interface for reading and writing.
Article Scope
This article will detail how I setup Node.js, CouchDB and MongoDB on Ubuntu Server Edition and preformed a few experiments with the system. The scope of this article does not include how you should do it or go into any detail as to how you could do it. It will only detail how to replicate what I did.
Server Setup
Download and install VMware Player. I installed it on Windows 7.
Download Ubuntu Server Edition iso. I got version 10.10.
Create a new virtual machine on VMware player but do not start the install already. Simply select the “I will install the operation system later” option since we don’t want VMware to configure our install for us. I gave the installation a 10GB hard drive and 128MB of memory.
Start the virtual machine and mount the ubuntu ISO to the cd drive and install it. When asked what software to install I selected LAMP, OpenSSH, PostgreSQL, Samba and Tomcat Java Servers.
Install CouchDB, MongoDB & Node.js
CouchDB is easy to install since ubuntu has added it to their software repositories.
sudo apt-get install couchdb
MongoDB is just as easy
sudo apt-get install mongodb
Node.js is a bit trickier. The easiest way it to get it from the git repository. First install git if you haven’t already got it.
sudo apt-get install git
Then get the node.js source from git.
git clone git://github.com/ry/node.git
cd node
./configure
The configure script told me I was missing g++ and openssl. The openssl one was a bit tricky since I needed openssl, libssl-dev and pkg-config installed.
sudo apt-get install g++
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install pkg-config
When you make ./configure happy, its time to make.
make
Now make a coffee because it takes a little while to compile.
sudo make install
One more thing, felixge has created “a thin node.js idiom based module for CouchDB’s REST API that tries to stay close to the metal”. Lets make life easier and install that.
cd ~/node
git clone git://github.com/felixge/node-couchdb.git
cd /usr/local/lib/node
sudo ln -s ~/node/node-couchdb couchdb
If everything worked correctly, we now have CouchDB and Node.js installed along with the node-couchdb library.
Tests Node.js
Lets check that the installs worked. The command node will take you to its console. Try these commands.
var sys = require('sys');
sys.puts('hello world');
This should simply print ‘hello world’. Pretty easy. Now lets make sure that the node-couchdb library works.
couchdb = require('couchdb');
This should print out some JSON if everything works.
Test CouchDB
CouchDB is a RESTful so to test CouchDB, we need a web browser. Installed lynx which is a command line web browser.
sudo apt-get install lynx
Now navigate to the default CouchDB page.
lynx http://localhost:5984/
It should simply display welcome and the version number in JSON.
Test MongoDB
MongoDB has a nice console so lets use that.
mongo
db.foo.save( { test : 'hello world' } )
db.foo.find()
This should print out something along the lines of { “_id” : ObjectId(“4cb82f963af8744e5572e430″), “test” : “hello world” }
Simple Website
Create a file called example.js and put the following example from node.js into it:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8000, "");
console.log('Server running at publicly on port 8000');
Now start the server
node example.js
You can now navigate to http://locahost:8000 and it will write Hello World. Unless you didn’t install apache, you probably wont be able to bind to port 80.
Coming soon: Testing Node.js and CouchDB to its full potential.
Make Google App Engine Development Server Serve Publicly
Ever wanted to quickly test that Google App Engine site on another computer without deploying but couldn’t because it only accepts localhost connections? Well it’s quite simple actually.
If you are using the command line add this argument to the end.
--address=
If you are using the windows launcher, select the application, click Edit > Application Settings… then in the ‘Extra command line flags’ section, add in
--address=
This works because by default, the address arguement is ‘localhost’ which will restrict the server. However, leaving it blank will allow any host to connect to it.
You could even set up port forwarding on your router to allow anyone to connect if you dare.
Google Opens Phone Gallery
- Detailed technical specifications
- Available operators
- Side-by-side comparisons
- ‘Buy from’ links
- Sort by newest
- Group by country
- Group by manufacturers
- Group by operators
Damn, I was hoping that I got the scoop on something. I was a couple of minutes late ![]()