Older blog entries for eMBee (starting at number 21)

Building an API with Zinc-REST in Pharo Smalltalk

In this session we are going to build a simple RESTful API using the Zinc-REST package.

The base image is again Moose, now the latest build of Moose 5.1

You may watch part one, part two and part three of this series if you are interested to find out what lead to this point. They are however not needed to be able to follow this session.

Syndicated 2015-02-28 17:23:13 from DevLog

13 Feb 2015 (updated 28 Feb 2015 at 18:11 UTC) »

A static webapplication hosted on Pharo Smalltalk

For part three of our workshop series we start from scratch, and build a small website that hosts nothing but static files from a memory FileSystem.

We are also going to explore the new development tools that are built in the Moose project

You may watch the first and second parts of this series, or you may jump right in here.

In the next session we are going to build the RESTful API to make this application functional

Syndicated 2015-02-13 08:37:26 (Updated 2015-02-28 18:11:55) from DevLog

3 Feb 2015 (updated 13 Feb 2015 at 09:11 UTC) »

Serving files through FileSystem in Pharo Smalltalk

In the second part of this series we transform our website to serve all content as files from a FileSystem object.

If you haven't yet, take a look at part 1

In the next session we will serve an actual web-application

Syndicated 2015-02-03 05:37:58 (Updated 2015-02-13 09:11:23) from DevLog

the community calendar project at google code in

For the community-calendar project in total, 11 tasks were proposed, of which 7 got completed:

Not so much work got done on the code itself, but we now have some documentation of the API as well as the start of a testing framework to help keep the API stable.

As a sideproject, these tasks were designed to explore the ember.js framework. the calendar-widget, going to be embedded into different websites was a good target because we now can offer both versions for embedding.

For ember.js the student, samarjeet wrote about the work in his weblog. An initial comparison: Comparing the community-calendar
Creating Ember Components turned out to be more dificult, and we had to enlist outside help to solve it.
Finally, a deeper comparison of Angular.js vs. Ember.js

This leaves us with 4 tasks that were not worked on

Syndicated 2015-01-31 09:19:07 from DevLog

csdn interview

I have been interviewed by CSDN. The interview has been published today in chinese.

The original english answers as i sent them are below:

1. Could you introduce yourself to us first?

I am using and developing Free Software and Open Source for more than 20 years. I am a contributor to the Pike programming language, the Foresight Linux distribution and several other Free Software Projects. I co-edited a book on Pike and organized developer conferences. I am also a mentor at FOSSASIA. Throughout my career I focused on developing and advocating Free Software. I have lived and worked in several countries around our planet Earth. I came to china in 2008. I am currently the CTO at eKita, a startup in Bangkok, and the General Manager at Realsoftservice, a Linux service firm in Beijing where i offer software development, training and internships. I live in Beijing with my family.

2. Compared with your own country, what attracts you most in China or Beijing?

China (and Asia in general) has a different culture from western countries. Learning chinese culture allows me to look at situations from a different perspective.

I believe that all the world should be united into one country. And in order to do that we need to understand the different parts of the world, what everyone can contribute to this world, and what unifies us.

China is a large part of this world, and also not much is known about china outside of it. The only way to learn about china is to be here.

China is also huge. I like to travel, and china allows me to travel long distances to places that are very different from each other without having to cross any borders.

3. What is your role in BLUG? Could you describe the important development milestones of BLUG?

I am acting as the secretary. That means i help to arrange meetings and events for the group.

I joined the BLUG in 2008 and i am not familiar with the history before. One important event before i joined was the 2007 Software Freedom Day which was chosen as the best SFD event for that year.

At the time, when i joined, the BLUG had monthly meetings, frequent quan'r dinners and BLUG Tuesday events. We also had a group aiming to build a quadcopter and a library. Active members were both foreigners and chinese.

In summer 2008 an intern at Exoweb where i worked at the time, together with me initiated a hackaton event called "Coding For Fun". I then continued hosting the event by myself as part of the BLUG. When i left Beijing other BLUG members continued hosting the event.

When I came back to Beijing some active members had left. I took over the management of the group in 2013, when most active members had left. At that time active participation was very low. I continued running the monthly meetings and Coding For Fun events. In Autumn we re-started BLUG Tuesday and used it to test new meeting locations. That way we found our current meeting place.

We slowly regained new active members, most of them chinese.

4. What kind of difficulties have BLUG encountered in the process of development, and how to solve them?

The main difficulty we have is finding good locations for the meeting and Coding For Fun events. It is still an unsolved problem. We don't have sponsors to pay for using locations, so we rely on offers for places we can use for free.

5. What are the daily activities in BLUG? Do you (or BLUG) have any interactions with other communities?

I am trying to visit and keep relations with every group that i can find in Beijing. I am regularly participating at events from the Beijing Open Party, Ruby, Python, Angular.js meetups. Barcamp and more.

Most of these groups have Linux users, but as i am a programmer, many groups are interesting to me personally too.

We also work with other groups to organize events, for example the Software Freedom Day. or we support conferences like GNOME.asia and FUDcon or the OpenSUSE summit, all of which had volunteers who are BLUG members.

We also participated at Google Code-In with FOSSASIA.

6. Have you ever attended open source activities in other countries or regions?

What are the differences between other countries and China in Open-source activities?

Every place and every country i have lived in, i participate in the local activities. These vary in size and regularity. In some cases my visit was the motivation for a group to have more meetings. In most groups the meeting involved some form of topic presentation and discussion. But sometimes it was just going out for dinner. Really not much different from china.

7. From your personal point of view, could you share with us some tips on how to manage one open source community successfully?

Well, there are different kinds of communities, for example those that revolve around a particular software project where all members in some form contribute to that software project. The contributions to such projects are often motivated by the contributors own needs. The main goal for community managers is to get active contributors to the project.

Other communities are more loose where people just share a common ideal, but actually may contribute to different projects.

The BLUG is of the latter kind. People contribute to the BLUG more out of a desire to serve the community than out of a personal need. And many do not contribute to the BLUG directly.

The goal of the BLUG is to provide a venue for Free Software contributors and users to share and meet like-minded people. Most Free Software Communities are spread all over the world, whereas groups like the BLUG are very local.

To manage a local group, i believe persistence would be the most important aspect. If the group has meetings, they should be regular, so that new people can easily find out when and where the meetings happen. Then it takes a while for the word to spread, and attendance to grow. Keep holding the meetings, even if only two or three people join. Then keep advertising the group and invite new people. Eventually more will join and come back regularly.

8. Could you introduce us some active and outstanding members in BLUG?

It is difficult to praise the contributions of some people without unjustly leaving out others. Moreover i don't even know all the contributions of every member. Some members don't come to the meeting often but they are very active elsewhere in the Free Software and Open Source Community. This is one of the things that tends to be miss-understood about the Free Software community.

Some people worry if they release their work with a Free Software license, then others can take advantage of it without giving anything back. But we don't know if those users are not active somewhere else making contributions to our society in other ways.

This is after all what i believe is the purpose of our life. All Men have been created to carry forward an ever-advancing civilization. (人人生来是为了推动文明不断进步的)

9. GNU project founder Richard Stallman came to China in May, 2014, did you have a meet with him?

And what do you think about the Free Software campaign leaded by Richard Stallman since 1980th?

I have met richard stallman a few times before, but never had much direct interaction with him. This year he joined us for a BLUG Dinner. As for his campaign, i fully support the idea of Free Software. I believe that all knowledge should be shared, and everyone should have the opportunity to use all of the worlds knowledge in their work. To fulfill the purpose of life we should all use our work to contribute to society. And allowing others to use and modify our software is a great and very easy way of doing that.

10. The last one, could you reveal to us the BLUG's future development plan, and what kind of activity will be organized in the future days?

Future plans of the BLUG depend on its members. For now my goal is to get more active members, people who help to host events, give talks, or help contribute to our website. The BLUG website is very old and in dire need of an upgrade. but it is difficult to do if we want to keep all the data.

I am also trying to work on a community calendar where we can share all events

Syndicated 2015-01-29 08:13:08 from DevLog

29 Jan 2015 (updated 30 Jan 2015 at 18:11 UTC) »

Using the FileSystem class in Pharo Smalltalk

I am learning how to build a website with a RESTful API in Pharo Smalltalk. This project started during Google Code-In as a set of tasks for students to work on. A handful of students were interested and picked up tasks to learn Pharo.

Now that Google Code-In is over, the students are interested to continue learning and so i am running workshops with them, where we explore the tools needed to build this server.

The first workshop was held last week on sunday the 25th, and the next one will be on saturday the 31st of Jnauary. from 2pm to 6pm chinese time, that is 7am to 11am CET or 6am to 10am UTC. We will meet on freenode irc in the channels #fossasia and #pharo.

A part of website consists of static files. To simplify development and deployment, we want to serve those files from the smalltalk image. One way to hold several documents inside an image is using a memory FileSystem. The FileSystem class is described in the book "Deep into Pharo" in chapter 3.

In the first workshop we try to use the FileSystem class in a sample application. We use the tutorial "Building and deploying your first web app with Pharo" as a starting point, and adapt the code to store images in a FileSystem object.

If you want to follow along, please first complete the tutorial and then watch the screencast below to continue:

Syndicated 2015-01-29 04:48:02 (Updated 2015-01-30 18:11:44) from DevLog

31 Dec 2014 (updated 31 Dec 2014 at 18:10 UTC) »

learning smalltalk with Google Code In

For years i have been meaning to learn smalltalk. my first exploration started about 10 years ago while teaching two children to make a game with squeak. Then i worked through a tutorial about making a simple game. Unfortunately it didn't capture my interest. So the my attempts to learn smalltalk were stalled as i searched for a project that i could do with it.

Why do i want to learn smalltalk? Because it is the first object-oriented language. Many of the OO concepts were invented in smalltalk. There is also the concept of working in an image that not only contains my code but also a full IDE which is used to update my code at runtime. Updating code at runtime is a concept that has been with me for more than 20 years now, ever since i started programming MUDs in LPC and writing modules for the Spinner/Roxen webserver in Pike. Pike allows recompiling classes at runtime. Any new instances will be made from the new class, while old instances remain as is. If the compilation fails, the class is not replaced and the old class continues to work. This way it is possible to make changes on a live server without restarting and disrupting ongoing requests. A decade later i discovered sTeam, the platform that also drives this very website. It takes this process even further: sTeam persists code and objects in a database. While in Roxen objects live as long as it takes to process a request, in sTeam objects are permanent, much like in a smalltalk image. sTeam then adds the capability to update live objects with new class implementations. The image concept of smalltalk is therefore already very familiar, and the major difference is smalltalk's GUI.

Recently a friend asked me what it would take to build a text search application for the Baha'i writings in chinese. There is one for english and other western languages, but not for chinese, and it does not run on mobile devices. It is also not Free Software, so i can't use it as a base to improve. But i didn't really want to take on a new project either so i just filed the idea for the time being.

One of my customers is managing access to several internal resources through htaccess and htpasswd. Because they have many interns who need to have access to some of these, and because they are now spread over multiple servers, it is becoming more and more cumbersome to manage them manually via these files. It also does not help that a salt module which we could use to help depends on apache helpers, which we can not install because apache conflicts with nginx which we are using. So i started exploring alternatives. One such alternative is a different way for nginx to verify access. It can make a request to an external service which then grants or rejects access depending on the resource and credentials. This could be implemented as a webservice with a webinterface to manage the users. I looked for some existing applications that would get me part of the way but i found nothing suitable.

Enter Google Code-In: FOSSASIA invited the BLUG to join them as mentors.

At first i put up tasks for the community-calendar project, but then i realized that this was an opportunity to explore new ideas. Figuring that teaching is the best way to learn i put up those project ideas as tasks for the students. I could ask students to learn and explore, and finally work on those projects. I would pick the technology and guide the students through a sequence of tasks to acquire the skills needed to implement the actual applications. This was my chance to get back into smalltalk. Since code-In targets middle and highschool students, it is quite unlikely that any of them already know smalltalk, or have even heared about it. so in a way this will introduce a few students to smalltalk. I picked pharo because i feel it is going in the right direction trying to improve itself and also adding things like commandline support.

The desktop application was straight-forward: find out how to embed text-documents in the image and make them searchable.

The web application took more exploration. I wanted to do it with a RESTful api and a javascript frontend. Again, the frontend was easy to define: create a user management interface. For the backend, the question was which webframework to use? AIDA/web has builtin user management and REST style url support by default. Seaside includes a REST module, but both are strong on generating html which i am not interested in. Then there is iliad, which appears more lightweight. Eventually i figured i could just let the students explore each, and i created a task for each tutorial that i could find:

(some of these i repeated because the student who did the them first time didn't pick up the follow-up tasks.)

Finally i discovered that Zinc, the HTTP server used by most frameworks is powerful enough to build a RESTful API without all the templating extras that the above frameworks provide. I also discovered teapot, a microframework that might be useful.

Once the students are familiar with the smalltalk environment, they can move on to the next steps:

Of course there are also tasks for the front-end

Related is also this task about a file editor, which i believe should make it easier to edit static assets like html and css pages from within the image:

Syndicated 2014-12-31 06:24:17 (Updated 2014-12-31 18:10:38) from DevLog

leaning smalltalk through Google Code In

For years i have been meaning to learn smalltalk. my first exploration started about 10 years ago while teaching two children to make a game with squeak. Then i worked through a tutorial about making a simple game. Unfortunately it didn't capture my interest. So the my attempts to learn smalltalk were stalled as i searched for a project that i could do with it.

Why do i want to learn smalltalk? Because it is the first object-oriented language. Many of the OO concepts were invented in smalltalk. There is also the concept of working in an image that not only contains my code but also a full IDE which is used to update my code at runtime. Updating code at runtime is a concept that has been with me for more than 20 years now, ever since i started programming MUDs in LPC and writing modules for the Spinner/Roxen webserver.

Recently a friend asked me what it would take to build a text search application for the Baha'i writings in chinese. There is one for english and other western languages, but not for chinese, and it does not run on mobile devices. It is also not Free Software, so i can't use it as a base to improve. But i didn't really want to take on a new project either so i just filed the idea for the time being.

One of my customers is managing access to several internal resources through htaccess and htpasswd. Because they have many interns who need to have access to some of these, and because they are now spread over multiple servers, it is becoming more and more cumbersome to manage them manually via these files. It also does not help that a salt module which we could use to help depends on apache helpers, which we can not install because apache conflicts with nginx which we are using. So i started exploring alternatives. One such alternative is a different way for nginx to verify access. It can make a request to an external service which then grants or rejects access depending on the resource and credentials. This could be implemented as a webservice with a webinterface to manage the users. I looked for some existing applications that would get me part of the way but i found nothing suitable.

Enter Google Code-In: FOSSASIA invited the BLUG to join them as mentors.

At first i put up tasks for the community-calendar project, but then i realized that this was an opportunity to explore new ideas. Figuring that teaching is the best way to learn i put up those project ideas as tasks for the students. I could ask students to learn and explore, and finally work on those projects. I would pick the technology and guide the students through a sequence of tasks to acquire the skills needed to implement the actual applications. This was my chance to get back into smalltalk. Since code-In targets middle and highschool students, it is quite unlikely that any of them already know smalltalk, or have even heared about it. so in a way this will introduce a few students to smalltalk. I picked pharo because i feel it is going in the right direction trying to improve itself and also adding things like commandline support.

The desktop application was straight-forward: find out how to embed text-documents in the image and make them searchable.

The web application took more exploration. I wanted to do it with a RESTful api and a javascript frontend. Again, the frontend was easy to define: create a user management interface. For the backend, the question was which webframework to use? AIDA/web has builtin user management and REST style url support by default. Seaside includes a REST module, but both are strong on generating html which i am not interested in. Then there is iliad, which appears more lightweight. Eventually i figured i could just let the students explore each, and i created a task for each tutorial that i could find:

(some of these i repeated because the student who did the them first time didn't pick up the follow-up tasks.)

Finally i discovered that Zinc, the HTTP server used by most frameworks is powerful enough to build a RESTful API without all the templating extras that the above frameworks provide. I also discovered teapot, a microframework that might be useful.

Once the students are familiar with the smalltalk environment, they can move on to the next steps:

Of course there are also tasks for the front-end

Related is also this task about a file editor, which i believe should make it easier to edit static assets like html and css pages from within the image:

Syndicated 2014-12-31 06:11:01 from DevLog

Google Code In with FOSSASIA

FOSSASIA is a mentor organization at Google Code-In, and the Beijing GNU/Linux User Group has been invited to join them as mentors.

Two of us joined and created tasks for our projects.

At first i created tasks for our community-calendar project, but then i took the opportunity to get students to work on new projects that i had been hoping to do. For a long time i wanted to learn smalltalk, but i lacked good project ideas. This changed recently, as a friend asked me about a text search application, and one of my customers needed a better solution than htpasswd to manage users for nginx. I decided that both could be done in smalltalk.

So i created tasks for three new projects: A text search application to run on the desktop, and one on mobile, and a user-management web-application. For the desktop and the web-application i stipulated pharo smalltalk as the implementation platform. For good measure i also threw in my idealist for sup, a reimplementation of the frontend for this weblog in angular.js, a t-shirt design for the BLUG, packaging pike, and exploration of the meetup.com api. I also proposed a new structure of the files for the fossasia api, and helped mentor a few tasks relating to getting chinese communities added to the api.

  • community-calendar (7 tasks)
  • desktop text search application (2 tasks)
  • mobile text search application (2 tasks)
  • user-management web-application (12 tasks)
  • sup ideas (more than 50 ideas, create tasks as needed)
  • fossasia (1 task)
  • sTeam weblog ui (1 task)
  • blug t-shirt (1 task)
  • amber (2 tasks)
  • file-editor (1 task)
  • packaging pike (1 task)
  • meetup.com api (3 tasks)
new tasks will be added as needed, when i get another idea for improvements on one of the projects, or if i feel a task needs to be redone.

Syndicated 2014-12-31 03:53:36 from DevLog

19 Sep 2013 (updated 19 Sep 2013 at 07:11 UTC) »

watch for the fish shell

The following command is used to watch the progress of files being updated in a directory.

watch 'du -h *| tail -20 | cut -c -$(($COLUMNS-5))'

cut is used so we don't get linewraps in the output. And we need to subtract 5 from the width because there is a tabstop in there which cut counts as 1 instead of the width of the tabstop (which is 8 minus the width of the size column)

This command works fine as long as files are updated in alphabetical order, but when this is not the case we need to sort files by time.

We need to do something like this instead:

watch 'du -h $(ls -tr)| tail -20 | cut -c -$(($COLUMNS-5))'

Unfortunately this only works if the filenames don't contain spaces.

fish handles spaces in filenames just fine:

du -h (ls -tr)| tail -20 | cut -c -(math $COLUMNS - 5)

So instead of trying to find a solution for dealing with spaces in bash, lets just use a better shell, shall we?

However, watch insists on executing the command with sh -c, so we need to devise our own watch loop for fish instead. That's not really hard:

while true
  clear
  du -h (ls -tr) | tail -20 | cut -c -(math $COLUMNS - 5)
  sleep 2
end

Unfortunately using clear causes an annoying flicker, especially if the du command takes a bit longer.

ANSI escape-sequences help:


clear
while true
  echo \e\[H
  du -h (ls -tr) | tail -20 | cut -c -(math $COLUMNS - 5)
  sleep 2
end

This causes the cursor to be moved into the top-left corner without clearing the screen. Now we are almost there. Two problems still:
The tab character used to align the columns does not overwrite anything in its space. Likewise at the end of the line, if the newly written line is shorter then the remaining part of the old line is not cleared.

We can fix this with some sed trickery to clear the path:


clear
while true
    echo \e\[H
    du -h (ls -tr) | tail -20 | sed -e 's/^/'\e'\[K/' | cut -c -(math $COLUMNS - 2)
    sleep 2
end

The ANSI escape sequence ESC[K clears the line just before it is rewritten. This has almost the same effect as clearing the screen, but without the flicker because we only start clearing after du has done its work.
And because the escape sequence adds 3 characters to the output we need to adjust the width accordingly.

At the end we can also add a command to clear the rest of the screen.

Leaves one last issue: $COLUMNS doesn't get updated if the terminal is resized. Granted, it's a nit-pick really, because how often does one resize the terminal. But to make this command generally usable, let's fix this too:


clear
while true
    echo \e\[H
    du -h (ls -tr) | tail -20 | sed -e 's/^/'\e'\[K/' | cut -c -(math (tput cols) - 2)
    echo \e\[0J
    sleep 2
end

This is now pretty usable, so we'll leave it at that. There is still some room for improvement though. For example currently we are estimating that the size column is at least 2 characters wide so the tabstop adds at most 5 characters worth of space which cut does not count. Should it be less then we would get a linewrap again and if it is more then we get empty space at the end of the line. cut likely also has problems with multibyte unicode characters. This can probably be solved by switching the terminal in a no-wrap mode while the command is running, or finding a replacement for cut that handles these issues.

Syndicated 2013-09-19 05:44:43 (Updated 2013-09-19 07:11:05) from DevLog

12 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!