A new project to learn the Crystal Programming Language

I’ve started a new side project named Crystal Koans, it’s a simple series of exercises organized as a big unit test suite. The “koans” are heavily inspired by similar projects for other languages, but I didn’t found anything similar for Crystal. The project has been included in the awesome collection under the official Learning Resource for the language. I’ll try to maintain and evolve it in the spare time, I hope you’ll find it useful, and any form of contribution is welcome. ...

November 20, 2020 · Andrea Manzini

Hijack C library functions in D

I like playing with the D programming language and I wrote this little post to show how it’s easy to create a dynamic library (shared object, .so) that can be invoked in other programs; to have a little fun we will write a D replacement for the rand() C standard library function call. For your convenience, all the code is also on github Let’s start with the demo implementation, a C program that calls 10 times the stdlib function rand() to get a random number. ...

March 10, 2020 · Andrea Manzini

a very simple NTP client in D

I am quite a fan of the D programming language and I think it deserves more attention, even if since a few months it’s becoming more and more popular, as it gained top20 in the TIOBE Index for February 2020. As an experiment in network programming, I took this simple NTP client written in C and translated to D ; in my opinion while it’s keeping the low-level nature, it’s shorter, clearer and more effective. It’s only a dozen lines of code, but full program is available on my github; stars and contributions are welcome! ...

February 20, 2020 · Andrea Manzini

migrating a repository from mercurial to git

Since bitbucket is sunsetting the support for mercurial repositories, I wrote a quick and dirty script to automate the migration from mercurial to GIT: #!/bin/bash set -e set -u if [ "$#" -ne 3 ]; then echo "Illegal number of parameters" echo "usage: migrate.sh reponame hgrepourl gitrepourl" exit 1 fi REPONAME=$1 HGURL=$2 GITURL=$3 echo "Migrating $REPONAME from $HGURL to $GITURL..." cd /tmp hg clone $HGURL cd $REPONAME hg bookmark -r default master hg bookmarks hg cd .. mv $REPONAME ${REPONAME}_hg mkdir ${REPONAME}_git cd ${REPONAME}_git git init --bare . cd ../${REPONAME}_hg hg push ../${REPONAME}_git cd ../${REPONAME}_git git remote add hgmigrate $GITURL git push hgmigrate master cd /tmp rm -rf /tmp/${REPONAME}_hg /tmp/${REPONAME}_git echo "...done" Before running the script, you only need to install git and create a git repository (remote or local). ...

December 15, 2019 · Andrea Manzini