The MSLUG (Montreal Scheme/Lisp User Group) is rising from the ashes! Next week, Marc Feeley will talk about Gambit REPL, a version of Gambit-C for iOS and Android.
More details can be found here.
(The Scheme Way)
A blog on Scheme, Erlang, and voice application development.
Thursday, November 17, 2011
Wednesday, May 25, 2011
Session handling in NuGram Hosted Server
Some time ago, I wrote a description of how session handling works in NuGram Hosted Server, which is implemented in Erlang. It's also briefly described on slide 15 of my talk at the Erlang Montreal meetup. Over on the Nu Echo blog, I wrote a short post explaining how the session timeout mechanism can be implemented using a plain Erlang/OTP gen_server behaviour. It's not a very profound post, but it's one of those areas where OTP shines (a very simple solution to a very common problem, and no need to reinvent the wheel).
Friday, May 20, 2011
Slides from my talk at the first Erlang Montreal meetup
Over on our corporate blog, I've put the slides from the talk I gave at the first Erlang Montreal meetup. The talk was a summary of some lessons we've learned at Nu Echo building NuGram Hosted Server in Erlang.
Wednesday, May 11, 2011
First Erlang Montreal meeting tomorrow
Tomorrow, May 12th, 2011, the first meeting of the Erlang Montreal user group will take place at the Notman House from 6:30PM to 8PM. I will have the pleasure to give the first talk, in which I will share some of the lessons we learned at Nu Echo on building real applications in Erlang.
Friday, February 11, 2011
Securing a couchdb database
Last week, for a post on our corporate blog, I created and populated a hosted CouchDB database (on CouchOne, now CouchBase). Since I put the code on github and it contains references to my publicly available database, I had to secure it a bit. Here is what I did.
Note: this is not a tutorial on CouchDB security issues, only a list of steps I did to secure my database. For a comprehensive guide on CouchDB security, there are excellent online sources.
1. Creating the user/password
The first thing to do is to create a new user with an associated password on the instance.
% curl -X PUT 'https://dboucher.couchone.com/_config/admins/username' -d '"password"'
2. Configuring the user
The next step is to configure the user account by setting its type and roles. In my case, I wanted to add the editor role to my account so I could restrict the creation of new documents to this role (the validator below is kept in a document on the database itself, so it is readable by everyone and I don't want other people to know which user account to hack).
The user account configuration is done using another simple HTTP request:
% curl -X PUT 'https://username:password@dboucher.couchone.com/_users/org.couchdb.user:username' -d@userdata.json
where the file userdata.json contains the following text:
{
"name": "newuser",
"type": "user",
"roles": ["editor"]
}3. Validator
Finally, to prevent creation of new documents (and modifications or deletion as well) from unauthorized users, I created a design document for my database that only contains a validate_doc_update function. The validation function checks that the user that tries to create/modify/delete a document has the role
editor. The code goes as follows:{
"_id": "_design/address",
"validate_doc_update": "function (newdoc, olddoc, userCtx) { if (userCtx.roles.indexOf(\"editor\") == -1) throw({unauthorized: \"illegal access\"});}"
}To create the design document, I simply entered the following at the shell prompt:
% curl -X PUT 'https://username:password@dboucher.couchone.com/streets/_design/address' -d@designdoc.jsonThat's it. I could certainly have done something fancier, but that worked and that was really easy to setup.
Thursday, January 06, 2011
My resolutions for 2011
First of all, I wish all of you a very happy new year 2011!
My regular readers may have noticed that I did not publish a lot of posts in the last months. I've been quite busy at work and wrote a number of articles on Nu Echo's blog instead. And most of all, I have not done as much Scheme or Erlang programming as I would have liked to do.
But I played a bit with a number of different technologies in the past months (Ruby, Groovy, CouchDB, NodeJS, websockets, etc.) and it be would worthwhile to write down my observations on these technologies. So my resolution for this new year (as far as this blog is concerned) is to write on a more regular basis about them. For example, I will try to explain:
My regular readers may have noticed that I did not publish a lot of posts in the last months. I've been quite busy at work and wrote a number of articles on Nu Echo's blog instead. And most of all, I have not done as much Scheme or Erlang programming as I would have liked to do.
But I played a bit with a number of different technologies in the past months (Ruby, Groovy, CouchDB, NodeJS, websockets, etc.) and it be would worthwhile to write down my observations on these technologies. So my resolution for this new year (as far as this blog is concerned) is to write on a more regular basis about them. For example, I will try to explain:
- what I think of Ruby and Groovy for writing DSLs from a Scheme perspective (you know I'm a big fan of macros and DSLs);
- what makes Erlang a great language for writing voice applications;
- my (very) personal take on NodeJS
and many other things.
Also, there seems to be a growing interest for SchemeScript in the last 6 months. The number of downloads on SourceForge has surged. For this reason, I will take some time to write tutorials and make some screencasts on how to use SchemeScript effectively.
Happy New Year!
Tuesday, August 24, 2010
ECMAScript - turning a binary function into a variadic one
In my previous post, I mentioned that it's easy to take a binary JavaScript function and turn it into a variadic one. Here's the helper function to do that:It is now possible to call
function variadic(fun, val0f, val1f) {return function() {var len = arguments.length;if (len == 0) {return val0f();} else if (len == 1) {if (val1f != undefined) {return val1f(arguments[0]);}else {return arguments[0];}} else {var tmp = fun(arguments[0], arguments[1]);for (index = 2; index < len; index++) {tmp = fun(tmp, arguments[index]);}return tmp;}};}
The 'variadic' function takes three parameters:
- the binary function;
- a function that returns the value for the variadic version when called with zero arguments
- a function that returns the value for the variadic version when called on a single. If not specified, the first argument to the variadic function is returned as is when called on a single argument.
For example, the summation operator is defined as
var sum = variadic(function(x,y) {return x+y;},function() { return 0;},function(x) { return x;});
while the equivalent of Scheme's / function is defined as
var div = variadic(function(x,y) {return x/y; },function() { throw "not enough arguments to div"; },function(x) { return 1/x;});
div.apply(this, [1,2,3,4,5])
to get 0.008333333333333333.
Subscribe to:
Posts (Atom)