Are crypto-currencies the new tulips ?
2017-05-26 00:04:42
The last days were tough ! Ether price has been 20x within 3 months time.
This unexpected market boom hadn't bring the joy it should have to me because my mind is still unconfortable with what I do not understand.

Let's remind how good of an oracle I was : I've written the wrongful prediction that Ether price would fall to 1.5usd during 2017.
I saw the year 2017 as a year of Ether accumulation where I would quietly mine and hold until a take-off occured.
Following my prediction, I've traded all the Ether I've mined from Oct 2016 to Feb 2017 for Bitcoin in the hope to be able to acquire Ether at a very low price during the year.
Unfortunately Ether has since then taken-off leaving me in the dust. Well...thanks god Bitcoin price has also more doubled to ease my pain.

What will be my next move ?

As of currently I own both Ether and Bitcoin for about the same amount. I've increased my mining capability since with the price rise, profitability is high no matter the current difficulty.
I'm still caped by my electricity provider at 6000kw so I won't go way higher that 4 rigs if I want to eat and shower.
Plus I've realize that mining is interesting when difficulty is low and price low because then when price rise with difficulty, the accumulated coins because so much worth.
Therefore I'm mining with good profit but then difficulty will rapidly catch the current price and will have to question my commitment to mining or try mining another coin.

What is driving the price currently ?

One can only guess, it appears that Korean are massively buying Bitcoin, maybe this mechanicaly drives all other crypto-prices as other cryptos can only be traded for Bitcoin (except Ethereum) ?
On korean market places, Bitcoin is trading for more than 4000USD while only 2400USD on other market.
Bitcoin may really well reach korean prices if demand stay steady.
Hashcode 2017 qualifications
2017-02-24 09:13:34
Didn't do very well in Python, so here is my good old C version.

 
 
#include <stdio.h>
#include <stdlib.h>
 
typedef struct {
int v;
int e;
int r;
int c;
int x;
} T_PARAMS;
 
T_PARAMS g_params;
 
typedef struct {
int cid;
int latency;
} T_CONNECTION;
 
typedef struct {
int latency;
int cache_srv;
T_CONNECTION * conlist;
} T_ENDPOINT;
 
 
typedef struct {
int vid;
int endid;
int nreq;
int vsize;
} T_REQUEST;
 
 
typedef struct {
int vcount;
int * vlist;
int free;
} T_CACHE;
 
int * vsize;
 
 
T_CACHE * init_cache(T_PARAMS params) {
    T_CACHE * cachelist = (T_CACHE*)malloc(sizeof(T_CACHE)*params.c);
 
    for (int i = 0;i < params.c;i++) {
        cachelist[i].vcount = 0;
        cachelist[i].vlist = (int *)malloc(sizeof(int)*params.v);
        cachelist[i].free = params.x;
    }
 
    return cachelist;
}
 
int add_video(T_CACHE * cachelist,int i, int vid,int w) {
    if (cachelist[i].free < w) return -1;
    cachelist[i].vlist[cachelist[i].vcount] = vid;
    cachelist[i].vcount++;
    cachelist[i].free -= w;
    return 0;
}
 
 
int read_int(FILE * f) {
    char str[10];
    int c = fgetc(f);
    int count = 0;
    while (c != EOF && c != ' ' && c!= '\n') {
        str[count] = c;
        count++;
        c = fgetc(f);
    }
    str[count] = 0;
    return atoi(str);
}
 
int compare2(void const *a, void const *b) {
    T_REQUEST * req1 = (T_REQUEST*)a;
    T_REQUEST * req2 = (T_REQUEST*)b;
    return (req2->nreq * req1->vsize) - (req1->nreq * req2->vsize);
}
 
int compare(void const *a, void const *b) {
    T_REQUEST * req1 = (T_REQUEST*)a;
    T_REQUEST * req2 = (T_REQUEST*)b;
    return req2->nreq - req1->nreq;
}
 
void solver(T_PARAMS g_params,T_REQUEST * reqlist, T_ENDPOINT * endpointlist, T_CACHE * cachelist, int * vsize, int (*compare) (void const *a, void const *b)) {
    qsort(reqlist,g_params.r,sizeof(T_REQUEST),compare);
    for (int i=0;i<g_params.r;i++) {
        T_REQUEST req = reqlist[i];
        int l = endpointlist[req.endid].latency;
        int cid = -1;
        for (int j = 0;j < endpointlist[req.endid].cache_srv;j++) {
            T_CONNECTION con = endpointlist[req.endid].conlist[j];
            if (l > con.latency) {
                l = con.latency;
                cid = con.cid;
            }
        }
 
        if (cid != -1) add_video(cachelist,cid,req.vid,vsize[req.vid]);
    }
}
 
unsigned int score_simple(T_PARAMS g_params,T_REQUEST * reqlist, T_ENDPOINT * endpointlist, T_CACHE * cachelist) {
    double sc = 0;
    double totnr = 0;
    for (int i = 0;i < g_params.r;i++) {
        unsigned int l = endpointlist[reqlist[i].endid].latency;
 
 
        for (int j = 0;j < endpointlist[reqlist[i].endid].cache_srv;j++) {
 
            T_CONNECTION con = endpointlist[reqlist[i].endid].conlist[j];
 
            for (int k = 0;k < cachelist[con.cid].vcount;k++) {
 
                if (cachelist[con.cid].vlist[k] == reqlist[i].vid) {
                    if (l > con.latency) {
                        l = con.latency;
                    }
                }
            }
 
        }
 
        sc += (endpointlist[reqlist[i].endid].latency - l) * reqlist[i].nreq;
        totnr += reqlist[i].nreq;
 
    }
 
    return (sc * 1000.) / totnr ;
}
 
void output_solution(T_PARAMS g_params,T_CACHE * cachelist) {
    FILE * f = fopen("result.txt","w");
 
    int count = 0;
    for (int i = 0;i < g_params.c;i++) {
        if (cachelist[i].vcount > 0) count++;
    }
 
    fprintf(f,"%d\n",count);
 
    for (int i = 0;i < g_params.c;i++) {
        if (cachelist[i].vcount > 0) {
            fprintf(f,"%d",i);
            for (int j = 0;j < cachelist[i].vcount;j++) {
                fprintf(f," %d",cachelist[i].vlist[j]);
            }
            fprintf(f,"\n");
        }
    }
 
    fclose(f);
}
 
 
int main(int argc, char **argv) {
    FILE * f = fopen(argv[1],"r");
 
    fscanf(f,"%d %d %d %d %d\n",&g_params.v,&g_params.e,&g_params.r,&g_params.c,&g_params.x);
 
    vsize = (int*)malloc(sizeof(int)*g_params.v);
 
    for (int i = 0;i < g_params.v;i++) {
        vsize[i] = read_int(f);    
    }
 
    T_ENDPOINT * endpointlist = (T_ENDPOINT*)malloc(sizeof(T_ENDPOINT)*g_params.e);
 
    for (int i = 0;i < g_params.e;i++) {
        fscanf(f,"%d %d\n",&endpointlist[i].latency,&endpointlist[i].cache_srv);
        endpointlist[i].conlist = (T_CONNECTION*)malloc(sizeof(T_CONNECTION)*endpointlist[i].cache_srv);
        for (int j = 0;j < endpointlist[i].cache_srv;j++) {
            fscanf(f,"%d %d\n",&endpointlist[i].conlist[j].cid,&endpointlist[i].conlist[j].latency);
        }
    }
 
    T_REQUEST * reqlist = (T_REQUEST*)malloc(sizeof(T_REQUEST)*g_params.r);
 
    for (int i = 0;i < g_params.r;i++) {
        fscanf(f,"%d %d %d\n",&reqlist[i].vid,&reqlist[i].endid,&reqlist[i].nreq);
        reqlist[i].vsize = vsize[reqlist[i].vid];
    }
    fclose(f);
 
    for (int i = 0;i < g_params.v;i++) {
        printf("video %d : %d\n",i,vsize[i]);
    }
 
    for (int i = 0;i < g_params.e;i++) {
        printf("endpoint %d : latency : %d\n",i, endpointlist[i].latency);
    }
 
    T_CACHE * cachelist = init_cache(g_params);
 
    solver(g_params,reqlist,endpointlist,cachelist,vsize,&compare);
 
    printf("SOLVED\n");
 
    printf("Score: %d\n",score_simple(g_params,reqlist,endpointlist,cachelist));
    output_solution(g_params,cachelist);
    return 0;
}
 
 
Google Hashcode 2016 qualification : input parsing
2017-02-21 23:01:14
It took me 1h30 to write the proper input parsing of the exercise in C.

 
#include <stdio.h>
#include <stdlib.h>
 
typedef struct {
    int x;
    int y;
    int * alist;
} T_WAREHOUSE;
 
typedef struct {
    int x;
    int y;
    int n;
    int * plist;
} T_ORDER;
 
 
int main(int argc, char **argv) {
    int h;
    int w;
    int d;
    int l;
    int t;
    int * wheight;
    int wc;
    int oc;
    FILE * f = fopen(argv[1],"r");
    fscanf(f, "%d %d %d %d %d\n",&h,&w,&d, &t,&l);
    printf("Area : %d x %d\n",h,w);
    printf("Number of drones: %d\n",d);
    printf("Number of turns : %d\n",t);
    printf("Maximum load : %d\n",l);
    int np;
    fscanf(f,"%d\n", &np);
 
    printf("Number of product : %d\n",np);
 
    int c;
    char arg[10];
    c = fgetc(f);
    int i = 0;
    int counter = 0;
 
    wheight = (int*)malloc(sizeof(int) * np);
    while(c != '\n' && c != EOF) {
        arg[i] = c;
        i++;
        c = fgetc(f);
        if (c == ' ' || c == '\n' || c == EOF) {
            arg[i] = 0;
            wheight[counter] = atoi(arg);
 
            printf("Counter = %d\n",wheight[counter] );
            counter++;
         i = 0;
        }
    }
 
 
    for (int i = 0; i < np; i++) {
        printf("Wheight of product %d : %d\n",i, wheight[i]);
    }
 
    fscanf(f,"%d\n", &wc);
 
    T_WAREHOUSE * wlist = (T_WAREHOUSE*)malloc(sizeof(T_WAREHOUSE)*wc);
 
    for (int j = 0;j < wc;j++) {
        fscanf(f,"%d %d\n",&wlist[j].x, &wlist[j].y);
 
 
        wlist[j].alist = (int*)malloc(sizeof(int) * np);
        counter = 0;
        c = fgetc(f);
        i = 0;
        while(c != '\n' && c != EOF) {
            arg[i] = c;
            i++;
            c = fgetc(f);
            if (c == ' ' || c == '\n' || c == EOF) {
                arg[i] = 0;
                wlist[j].alist[counter] = atoi(arg);
                counter++;
                i = 0;
            }
        }
 
    }
 
    for (int i = 0;i < wc;i++) {
        printf("wc %d : %d - %d\n",i,wlist[i].x,wlist[i].y);
        for (int j = 0; j < np; j++) {
            printf("p: %d availability : %d\n",j,wlist[i].alist[j]);
        }
    }
 
    fscanf(f,"%d\n", &oc);
    printf("Order count : %d\n",oc);
 
    T_ORDER * olist = (T_ORDER*)malloc(sizeof(T_ORDER)*oc);
 
    for (int j = 0;j < oc;j++) {
        fscanf(f,"%d %d\n",&olist[j].x, &olist[j].y);
 
        fscanf(f,"%d\n",&olist[j].n);
 
        olist[j].plist = (int*)malloc(sizeof(int) * olist[j].n);
        i = 0;
        counter = 0;
        c = fgetc(f);
        while(c != '\n' && c != EOF) {
            arg[i] = c;
            i++;
            c = fgetc(f);
            if (c == ' ' || c == '\n' || c == EOF) {
                arg[i] = 0;
                olist[j].plist[counter] = atoi(arg);
                counter++;
                i = 0;
            }
        }
 
    }
 
    for (int i = 0;i < oc;i++) {
        printf("oc %d : %d - %d\n",i,olist[i].x,olist[i].y);
        for (int j = 0; j < olist[i].n; j++) {
            printf("p: %d type : %d\n",j,olist[i].plist[j]);
        }
    }
 
    fclose(f);
    return 0;
}
 
On Ether price crash
2016-12-05 22:32:10
I've been mining Ether for 1.5 month already which made me own 80 ether. That would be worth 1000 usd 2 months ago but today it's only worth a measly 500 usd, thanks to current Ether value of $7. I don't really care about day to day Ether value as I'm mining to hold. I knew It was kind of gambling when I bought two rigs worth 1600€ a piece and started mining in October.

Nevertheless this bubble burst (yes I think we can call it like that) made me think more deeply about was crypto-currency mining.
In the Bitcoin paper, Satoshi Nakamoto desribed mining as an incencitive that would people to commit processing power to the Bitcoin in order to secure the network by validatiing transaction.
Cryto-currency mining is not supposed to make people rich, it's supposed the reward miners for the processing power they give to the network. To that regard, mining profitability should converge towards electricity cost. The fact that sometimes, mining profitability greatly exceed electricity cost to become an extremely rewarding business I more due to high level of speculation or that supply in coin greatly is insufficient compare to demand. Mining is steadily profitable during shorts lapse of time when demand exceed coin production but as more miners come into action profitability decrease thanks to difficulty increase. The Bitcoin boom made mining profitable but it would have been equally profitable to just buy coin rather than going with the hassle of mining.
Business based on Ethereum are in their infancy so one can argue that the short boom in Ether profitability is more likely due to speculation.

What is the real price of Ether ? Off course, it's very difficult to give a faire price to an asset such as Ethereum.
One interesting fact is that 70 milllions Ether out the 80 millions Ether currently available had been premined, which means that 70 millions Ether were sold or given to organization like DAO to support Ethereum eco-system. Creators of the Ethereum themselves do not see Ethereum as a currency but more as some kind of asset.
Hence my thought that Ether market cap should converge towards Ethereum eco-system value. A market cap of 1 billion as seen in july was just ridiculous considering how in its early stage is Ethereum. None of the most notrious Ethereum projects like "Slock.it" or "Augur" made it past that startup scale, and valuating Ethereum like a successful tech company seems ambitious.
Today I'd say that Ethereum core value is about 100 Millions USD. Which price it in line with "startup with potential". I do hope that I'm wrong, but in absence of ground-breaking news, I can very well forsee Ether reach 1.2 USD in the near future.
Code is law
2016-12-01 23:48:17
It all started with the novel "Code and Other Laws of Cyberspace" from Lawrence Lessig
I used to work in developing accounting software. Sometimes, regulations and business rules that comes with it are so complex that the users of the application themselves would go and ask developers the behavior of the software. The code written become the base on which people in the company will base their decision. it become more and more evident that technology and regulations are now tightly bonded.
Then I came to face the "Code is law" concept : what if the code did not comply to regulation but the code itself was the regulation. In the cybernetic era we are living in, computer software is everywhere. What if software ruled our lives.

Ethereum

In France, there's a law that only "government approved" cashier software are allowed, to prevent any falsification. Still nothing can guarantee that the some would run unmodified. Therefore i dont think that closed source program can be used as a base of trustable software because it is impossible to know whether the program contains any illegal backdoor.
How to produce that kind of software and how do ensure that is still meets its requirement ? State or established company could deliver such service, just think at Verisign which, for instance, issue encryption certificates. But that how can we make sure that the state or the company does not break the law, and isn't putting the power of law enforcement to private company a risk?
Open-source software is a good alternative as the source code can be read and verified statically but it is impossible to ensure that the code will not be modified at run time. So in order for the code to be the law, we need a platform where the code is publicly available and also an unmodifiable unstoppable platform where the code will run. These these approved software are law in a way that there business rules enforce the law. One can say that they are the law.
Blockchain technology comes into play because of its ability to for a decentralized trust mechanism that can support this concept that code can be a sort of unmodifiable contract that can be trusted as truthfully as the legal code itself, comes Ethereum. Ethereum is a blockchain platform that can run publicly non stoppable, non alterable software. Ethereum, hence, fill the need for trustable execution of the law code.
It's an innovative idea : one can imagine escrow service that will act as a man in middle without any human action, or billing software that will run on the platform to absolutely non modifiable.

It's only the begining

The cyber law era hasn't even started yet but with the ever growing role of technology on our lives, we've come to realize that software code rules our lives. With great power comes great responsiblity. So is the need for software that we can trust.
Single board computer in 2016
2016-11-09 23:32:10


When I've first heard about the Raspberry Pi in 2012, I honestly didn't saw any use for it outside the "Small is beautiful" effect.

It's small, it's cheap but it's badly underpowered and with as little as 256 Mb RAM it cannot be decently used to launch any desktop class application.
The only proper use that I could see for it was as NAS server for all your pirated movies (yay I don't download movies :( )

Well...time has passed and now IoT is the new hype. IoT(Internet of Things) meant to change our consumer life by making everyday objects connected to the Internet.

A few month ago, I'd bought myself an Arduino (Yes I know I am once again late to the party). I played with it a little bit and it made me realize that it was the doorstep of the IoT and also what IoT meant actually.

Then I finally got it : the Raspberry Pi is by no means a pocket computer or a cheap computer for stingy people. It is a platform to prototype smart and connected object.

The selling point of the Raspberry Pi is it's integrated GPIO pins that allows to send or receive electric signals from any connected component. It also features a camera interface that is directly connected to the onboard GPU for direct compression and streaming.
NameComment
Raspberry Pi ZeroThe board that started the race to the bottom
Orange Pi ZeroThe chinese copycat, is it ?
C.H.I.Pthe new comer

Networking in C/C++
2016-10-24 22:25:33
In a funny way, I spent most of my working days writing network software.
Client/server, blocking/non blocking, TCP/HTTP/UDP and I'm suprised to feel all but embarrassed coming back at home :
What library should I use to write networking software ?

A stackoverflow topic sum it up :
http://stackoverflow.com/questions/118945/best-c-c-network-library

Given the choice, I'd rather go for SDL_net as I used SDL already a lot in my home projects.

Biggest game ever
2016-01-27 22:33:15
https://www.youtube.com/watch?v=HhyyUiYQolA

What is the video game that offers the largest open world to explore ? Not Oblivion, not World of Warcraft, I was stunned to learn that it's a rather anonymous game called "Fuel" by the french developers of Asobo Studio.

The game offer 118km by 118km of fully detailed explorable world and all fitting in a single DVD.

That is a seriously impressive fact but why would you accomplish such glorious software engineering for a racing game !?
Returning implementing class from an abstract class method
2016-01-19 16:34:15
This is a common problem :

A is an abstract class that implement a method

B implements A
C implements A

A's method returns "this" so that you can use the chain calls like this a.method.method.method

Problem : a.method retursn an instance of A, so that you can not use a method of B after calling b.method.

I didn't know that this kind of pattern has a name : F-bounded quantification

The solution is pretty weak :
 
abstract class A<T extends A<T>> {
public T clone(T original);
}
 
class B extends A<B> {
@Override
public B clone(B original) {
//...
}
}
 


Downloading Java JDK on a headless server
2015-12-10 13:36:09
Because every server deserve a JDK :

 
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" <a href ="http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.tar.gz">http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.tar.gz</a>
 
See 10 older news | Back to the top