News
Home Home Contact us Contact
home News Projects Tests Files Follow manatlan on Twitter Sign in
2 weeks ago

Happy birthday iBraining

10 years since iBraining is Online !

No special events today ! No new games, no new version, although I remade it in an angular version, and got a riotjs version too. But I don't have the courage to change anything. Last year, I've made the responsive version for smart devices.

I'm not able to decide if it should go with angular or riotjs. I like riotjs, but theses last weeks I came back to angular, because I'm more productive with angular material.

Comments (View)
2 weeks ago

CavePilot, finally !

Here is a playable CavePilot. It's based on my old test. It should work (with chrome or firefox) on desktop (with keys) or smart devices (with gyroscope and with chrome only)

It's Single Page Application, made with riotjs2. It's a Progressive Web App, so it can be added to home screen, and should be playable offline.

Everything was made with my online editor, in a browser, on the Paas (Platform as a Service) : Google App Engine.

I've made an android app for CavePilot. But it's just a shelf, for fun ;-). But it's a webapp, so no need to update it to get the latest release, coz I can update it whenever, with a simple browser ;-)

Regarding the game ; you should drive into caves, to reach the sun as fast as possible. It's just amazing ;-)

Levels are too simples ... so it will be harder in the future, perhaps ;-)

Comments (View)
last month

Kiss a rest api

I see a lot of things about python libs to help to make restful api, nowadays. Sure, hug is beautiful.

Last year, I've made my own lib for that. But since some months, I use this KISS way, and I'm really happy with it :

Server side, I create a HTTP POST endpoint (here with bottle):

@post("/server")
def serverEndpoint():
    try:
        datas=json.loads(request.body.read())
        c=lambda d: globals()["API_"+ d.keys()[0] ]( **d[ d.keys()[0] ] )
        return {"result":[c(i) for i in datas] if type(datas)==list else c(datas)}
    except Exception as e:
        import traceback
        return {"error":traceback.format_exc()}

Now, I can create a lot of serverside API (method which starts with 'API_'), example:

def API_add(a,b=1):
    return a+b

And client side, I call them easily, like this (here with angularjs, but likely the same with JS's fetch) :

$http.post("/server", {add: {a:12, b:42} } ).then( ... )

And better, within 1 http request, I can call multiple api too, like this :

$http.post("/server", [ {add:{a:36,b:29}} , {add:{a:27}} ] ).then( ... )

If I call one method, the result is in the "result" attribut of the response. If I call multiple, results are in a list in the "result" attribut of the response. If server side error, the traceback is in the "error" attribut of the response.

It's very useful in a lot of cases, and it's hard to make simpler !?

Comments (View)
5 months ago

My first PWA

Here is a scratch app. Progressive Web Apps are the way to go, like I said 3 years ago, it's a different fashion. It's a lot lot better to manage the cache with a service worker than with the appcache manifest ;-).

This one doesn't use angular, neither riotjs; it's just pure javascript ;-) In an near future, "web app" won't need Cordova/phonegap to access to peripherals. All will be added as api/event thru the service worker.

Comments (View)
9 months ago

Websocket on app engine : soon !

Big news ;-)

https://code.google.com/p/googleappengine/issues/detail?id=2535

"Thanks to everyone for your feedback. We recognize the importance of App Engine support for WebSockets[1][2] and are actively working on implementing this feature."

7 years later ;-)

Comments (View) Tags: gae
last year

FreeboxV6 Api V3 avec Python

Un peu de python, et ça vient annuler ça ;-)

Voilà une api python simple de registration et de connexion avec les API v3 de la freebox :

import urllib2,hmac,json,hashlib,time

class FbxCnx:
    def __init__(self,host="mafreebox.free.fr"):
        self.host=host

    def register(self,appid,appname,devname):
        data={"app_id": appid,"app_name": appname,"device_name": devname}
        r=self._com("login/authorize/",data)["result"]
        trackid,token=r["track_id"],r["app_token"]
        s="pending"
        while s=="pending":
            s=self._com("login/authorize/%s"%trackid)["result"]["status"]
            time.sleep(1)
        return s=="granted" and token

    def _com(self,method,data=None,headers={}):
        url = "http://"+self.host+"/api/v3/"+method
        if data: data = json.dumps(data)
        return json.loads(urllib2.urlopen(urllib2.Request(url,data,headers)).read())

    def _mksession(self):
        challenge=self._com("login/")["result"]["challenge"]
        data={
          "app_id": self.appid,
          "password": hmac.new(self.token,challenge,hashlib.sha1).hexdigest()
        }
        return self._com("login/session/",data)["result"]["session_token"]

class FbxApp(FbxCnx):
    def __init__(self,appid,token,session=None,host="mafreebox.free.fr"):
        FbxCnx.__init__(self,host)
        self.appid,self.token=appid,token
        self.session=session if session else self._mksession()

    def com(self,method,data=None):
        return self._com(method,data,{"X-Fbx-App-Auth": self.session})

    def dir(self,path='/Disque dur/'):
        return self.com( "fs/ls/" + path.encode("base64") )

Pour commencer, il suffit de registrer son appli dans la freebox, en lançant, dans son reseau local uniquement, chez soi, la commande suivante :

print "token='%s'" % FbxCnx().register("test.id","le nom de l'app","la device")

Il faut valider la registration sur l'afficheur LCD de la freebox, et garder le token !

Une fois que c'est fait; on peut attaquer les API depuis n'importe où sur le web. Si on est ailleurs que dans son sous réseau freebox, il faudra préciser l'ip public de la freebox, ainsi que sont port, dans un paramètre 'host' (faut évidemment que ça soit activé dans la config freebox).

f=FbxApp("test.id",token,host="11.22.33.44:4444")
print f.dir()

L'instance FbxApp négocie, en douce, un 'token de session'. Si on veut garder la même session, il est possible de l'obtenir (f.session), de la faire persister, et de la donner à l'instanciation, comme ceci :

session="WV+O0z1XgE4QB728uINupbQdBiKKAhKYjAX+UylmGwL2ejo6ViQkcx1tK4onQIzt"
f=FbxApp("test.id",token,session,host="11.22.33.44:4444")
print f.dir()

Il n'y a que la commande "fs/ls" d'implementer (via dir()), mais le reste est tout aussi simple ;-)

Mais on peut aussi appeler directement les API, ainsi (et voir passer des params, via un dict comme second argument):

print f.com("airmedia/receivers")

Comments (View)
last year

In the SPA style

I've built a super tool : it's a "web editor" online, so I can quickly code for the web (static or dynamic (python/bottle) files). It use the marvelous ace editor, it's hosted on GAE, it's built with RiotJS. It's a little bit like koding, but without the linux prompt. It's just for me, but I could release it. The frontend is here, but it's just for me, like I said before ;-( ... (it's already the second version, and this one was coded using the first version ... it's like the chicken & the egg ;-) ... now, I can code with the chromebook or whatever internet devices ;-)

It could be done with angular, but not. RiotJS is more fun (but not widely used ?!?) ;-)

Here are 2 (ugly) demos of a classic (simple) app (a kind of todo's app). The first one : an Angular2 version (with classic ES5 javascript (not typescript!)), the second one : a RiotJS version.

Twos are using :

  • a service (to deal with datas) : 'MyService'
  • a master component : 'app'
  • a child component : 'item' (itered from the master)
  • a mecanism of events to communicate between the twos
  • a pipe (aka filter), to transform data : 'mypipe'

I let you choose which is the most readable, the simplest ;-)

It's not really comparable, A2 comes with a full stack. With Riot, you'll need to import yours polyfills and others libs : but you've got the choice !

Comments (View)
2 years ago

iBraining goes mobile

It's a big day, It's nearly Christmas ! iBraining is now (nearly) fully playable on smartdevices (phones, tablets, small screens, ...).

It's not a big rewrite from scratch (like I planned), not a SPA app, not riotjs/angular* powered! I've just hacked the html/css to be a responsive app, to adapt itself to smallest screens. It should do the job.

Desktop version continues to work ;-), just small changes in the front.

Hope everything will continue to work for everybody.

PS: I will continue to work on it in the future days (mainly : better rendering).

Comments (View) Tags: ibraining
2 years ago

RiotJs : I

It makes 5 days since I've discovered RiotJS :-)

It's perfect (there are some glitchs, but nothing annoying). You can clearly concentrate on your code/app, and not fight with the framework. It's pretty convention over configuration (it's sadly not the case of angular2). It fits my brain, and I am clearly more efficient with it ;-). And it's pretty easy to use others js libs, without a wrapper.

I've started to recode ibraining.com with riotjs. So the angularJS version will never reach the online state ;-). I've redone all my game components in less than 8hours. Pretty nice :-)

And my chromebook, with caret, is perfect tool to develop with RiotJS (angular2 dev is more complex on chromebook).

Here is my first riot online app (it's nothing, coded in 20min). It's a scratchpad to code python things. It works offline, uses 4 buffers (saved locally), and CTRL+RETURN is a shortcut to run the code. Thanks to skulpt.

Comments (View) Tags: angular, ibraining
2 years ago

RiotJs : I'm fan

It makes 5 deys since I've discovered RiotJS :-)

It's perfect (there are some glitchs, but nothing annoying). You can clearly concentrate on your code/app, and not fight with the framework. It's pretty convention over configuration (it's sadly not the case of angular2). It fits my brain, and I am clearly more efficient with it ;-). And it's pretty easy to use others js libs, without a wrapper.

I've started to recode ibraining.com with riotjs. So the angularJS version will never reach the online state ;-). I've redone all my game components in less than 8hours. Pretty nice :-)

And my chromebook, with caret, is perfect tool to develop with RiotJS (angular2 dev is more complex on chromebook).

Here is my first riot online app (it's nothing, coded in 20min). It's a scratchpad to code python things. It works offline, uses 4 buffers (saved locally), and CTRL+RETURN is a shortcut to run the code. Thanks to skulpt.

Comments (View) Tags: angular, ibraining
<< oldest

Tags

RSS aex aex
RSS d2 d2
RSS gae gae
RSS go go
RSS ppa ppa
RSS Python Powered Get Ubuntu
©opyleft 2008 - manatlan cmd snippets