Archive for the ‘programmering’ Category

Easy deploy of Rails app with Capistrano, Varnish and Sidekiq

Thursday, August 9th, 2012

Whenever I start a new Rails project, I will like to be testing it extensively on another server, as fast as possible.

So there is a couple of steps that I will go through every time I start my project. I need the following base in all projects:

  • Sidekiq as a background worker; to send emails, process data etc.
  • Capistrano for deploying the app.
  • Unicorn, to run the app after deployment.
  • Foreman, for running the setup locally.

This is my config:

[Gemfile]

[config/sidekiq.yml]

Configs that need variables to be set:

[config/unicorn/production.rb]

[config/deploy.rb]

Remember to bundle, and run ‘capify .‘ in the project to generate the Capfile.

Building a chat with nice tabs in jQuery

Saturday, December 10th, 2011

I am currently trying to find an excuse to work with NowJS which is a very cool NodeJS server that makes it possible to make a server push to connected clients. You are able to group your users into “channels” and only send some groups messages.

I have only been able to build the client, and the javascript that goes with it. It is still very hacky (both css and javascript) but the core concepts is there.

You are able to see a demo here: Demo chat preview

If you were active on the danish chat ‘Jubii Chat’ back in the day, you would be able to recognize one of the users ;)

Node.js and receiving POST-data from HTTP

Saturday, October 22nd, 2011

I have built an application that needed to communicate with another Linux server. It was very simple commands that my nodeserver should receive.

To get the POST-variables in the in-built HTTP-server from NodeJS you can use this method:

function onRequest(request, response) {
  var pathname = url.parse(request.url).pathname;
  console.log("Request for " + pathname + " received.");
  response.writeHead(200, {"Content-Type": "text/plain"});
 
  post_handler(request, function(request_data)
   {
	console.log(sys.inspect(request_data));
	response.end();
   });
}
function post_handler(request, callback)
{
    var _REQUEST = { };
    var _CONTENT = '';
 
    if (request.method == 'POST')
    {
        request.addListener('data', function(chunk)
	{
	    _CONTENT+= chunk;
	});
 
	request.addListener('end', function()
	{
        _REQUEST = querystring.parse(_CONTENT);
	    callback(_REQUEST);
	});
    };
};
 
http.createServer(onRequest).listen(8888);

Enable .bashrc on OSX Snow Leopard (and Lion)

Wednesday, October 19th, 2011

Unfortunately OSX doesn’t use .bashrc per default, but it is easy to enable it. To do it, open up the file /etc/profile with root privileges like this:

sudo nano /etc/profile

And add the following line:

[ -r $HOME/.bashrc ] && source $HOME/.bashrc

[ -r $HOME/.bashrc ] && source $HOME/.bashrc

Save, and now your .bashrc file should work like you expect.

Sommerferie projekter, og et 10-tal!

Wednesday, July 7th, 2010

Jeg har fået afsluttet mit tredje semester på Datamatiker-studiet. Vi har lavet et projekt i samarbejde med de andre grupper på årgangen. Vi stod for backend-delen af systemet, og så var der to andre grupper som stod for front-end delen.

Jeg blev syg til den oprindelige eksamen, så måtte til syge-eksamen, og jeg fik 10! God måde at starte sin sommerferie på :)

Her er en række projekter min sommerferie kommer til at gå med:

Pitch a game concept and win

Vi har i UngeSpiludviklere fået sponsoreret et par Xbox’e og HTC HD2 telefoner af Microsoft. Og vi har sammen med fagforeningen PROSA og spil-foreningen IGDA, fået stablet et arrangement på benene.

Konceptet går på at vi samler en masse danske spiludviklere, og får dem til at pitche idéer for hinanden, dem der har den bedste idé, får en Xbox eller en mobil til at lave deres spil på.

Roskilde-festival

Vi har igen i år et festivals projekt i Ungdommens Naturvidenskabelige Forening (UNF). Jeg har været koordinator og styret hele projektet. Vi laver en energivenlig netcafé, og oplade station på festivallen.

Vemod

Nu kommer vi til softwareprojekterne, det her er skrevet i C#.

Hvor tit sidder man ikke og savner muligheden for at søge efter et billede i et billede?

Jeg er ved at bygge noget software som muliggører at søge efter billeder i billeder. Den er dog ikke helt effektiv endnu, men jeg har et par tricks i ærmet. En test jeg kører lige nu giver følgende resultater:

bigpicTid for at at søge efter billederne i det store billedet:
2xchart 3,809 sekunder
3xcheckbox 2,135 sekunder
1xdownloads 14,997 sekunder

:)