Category Archives: Python

End Of Iteration 2014w15

Previous Post
Next Post

Code Generation

I wrote new tasks, templates using my AjGenesis code generation tool. I create a simple:

https://github.com/ajlopez/AjGenesisNode-Django

to generate a Django web site, with admin page. The code generation creates the model, and admin feature allows you to edit the data, using Sqlite. It’s simple, but it is working. Next steps: create custom views, and a new project to generate Flask web site.

I added text area input fields to https://github.com/ajlopez/AjGenesisNode-Express the project that generates Express/Node.js web site from a model. Next steps: client-side validation, better server code organization, some initial tests.

I want to integrate these tools in a online app, so I started https://github.com/ajlopez/AjGenesisNodeServer to have a web site that generate codes from a model, defined at client side. You will select technology (Express, PHP, Sinatra, Django, Flask, …), the models (mainly, entities like: customer, supplier, department, employee, invoice… ), the database, the features (multiple pages, single page, angular? backbone? other?, REST API?, phonegap wrapper?), and voila. A zip will be generated with the generated solution. That is, code generation as a service. Maybe I could add an API to be externally consumed.

Python

I added a Flask web site example, work in progress, to my Python Samples:

https://github.com/ajlopez/PythonSamples/tree/master/Flask

I will use as a basis for my AjGenesis code generation version for Flask web sites.

Actor Model in C#

I refactored my project

https://github.com/ajlopez/Aktores

an Akka-like actor model implemented in C#. Now, I have a mailbox per actor, but the actor message process is executed consuming task from a queue, with n thread launched by the initial actor system. It was good to see such refactor working: all is in place, now. It is a proof that you don’t need to design everything before coding. If you follow TDD (Test-Driven Development) new ideas (or old ideas that have not implemented yet) can be added without much effort.

Erlang in C#

I started to add serialization of message to my project

https://github.com/ajlopez/AjErl

As usual, I started simple, using TDD: write input and out channel, using tests, red to green, refactoring. Instead of consuming an external library for serialization, I wrote a simple code, towards my first use case of distributed application. When the use case will be in place, I could start to think about other implementation path.

Google Code Jam

Past Saturday, I participated in Google Code Jam, Qualification Round. My code, usually written following TDD:

https://github.com/ajlopez/TddRocks/tree/master/Gcj2014

The Minesweeper problem is the tricky one. I should add the description of the problems, copying it from the original site.

Others

I added some code kata tests to my JavaScript samples https://github.com/ajlopez/JavaScriptSamples. I added metadata macro readind go my Clojure in C# https://github.com/ajlopez/ClojSharp. I started to add type checking in my node tree for Scala in C# https://github.com/ajlopez/ScalaSharp/commits/master. I added qualified name evaluation to my Rust interpreter in JavaScript https://github.com/ajlopez/RustScript. I worked on two non-public projects, too.

More fun is coming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

End Of Iteration 2014w08

Previous Post
Next Post

More interesting projects and code TDD practices

Annalisa

A new JavaScript project:

https://github.com/ajlopez/Annalisa

to solve some use cases of Preciosa project. Preciosa is written in Django/Python, but I want to explore how to solve:

– Given an string, return associated properties (ie. analyze a product description, then return detected weight (from “10 gr” substring), brand (from “… Axe … “ substring). I create rules to detect some patterns (simple normalized substrings) and return a JavaScript object with detected properties/values.

– Search by word combination (done), and approximated words (WIP)

Now, I’m working on implementing Preciosa use cases, using its data for products, companies, brands, etc.  I’m implementing console programs, and I will to implement a web service with associated test page.

AcquarellaJS

I started:

https://github.com/ajlopez/AcquarellaJS

A new implementation, this time in JavaScript, for my syntax highlighter Acquarella (in C#). I plan to use it to generate colored HTML for my code snippets, and add them to my posts (in blog software that doesn’t allow JS scripts).

Templie

Someone asked on Twitter about a template engine in Java, without dependencies, a lightweight version. Then, I wrote

https://github.com/ajlopez/Templie

Now, it has expansion of variables in ${variable}, and process of @if commands. Next steps: adding @for, adding ${variable.property} using reflection.

ScalaSharp

My Scala interpreter in C#, in progress:

https://github.com/ajlopez/ScalaSharp

I was adding more INode concrete nodes. Instead of having expression tree, I want a node tree, to have type checking BEFORE evaluation, according to a typed compiled language.

Talks

I modified

https://github.com/ajlopez/Talks/tree/master/NodeIntro

It was published to

http://ajlopez.github.io/Talks/NodeIntro/index.html

And created a new one (WIP):

https://github.com/ajlopez/Talks/tree/master/NodeDistributedApps

for upcoming JSConf Uruguay 2014. Yes! I’m an speaker.

SimpleAsync

After attending JavaScript meetup with @getify talk, I wrote, following TDD as usual, a simple async library:

https://github.com/ajlopez/SimpleAsync

I want to add: .do to launch a “parallel” tasks (many consecutive .do returns an array with the collected result), and .map to process an array in “parallel”.

Silabeo

I wrote a new TDD exercises

https://github.com/ajlopez/TddRocks/tree/master/Python/Silabeo

this time in Python: syllable separation in Spanish. Good code kata. It was useful to me to learn and practice more Python.

Others

Minor additions to https://github.com/ajlopez/DylanSharp, https://github.com/ajlopez/MeteorSamples, https://github.com/ajlopez/SimpleReact

I also worked on two non-public projects. More fun is coming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Python: Links, News And Resources (14)

Previous Post

rbarrois/factory_boy
https://github.com/rbarrois/factory_boy
A test fixtures replacement for Python

Introducción a Tryton Application Platform // Speaker Deck
https://speakerdeck.com/smarro/introduccion-a-tryton-application-platform

exception – Try/Catch in Python – Stack Overflow
http://stackoverflow.com/questions/730764/try-catch-in-python

koonsolo/MysticMine
https://github.com/koonsolo/MysticMine
Open Source Game

fisadev/talks
https://github.com/fisadev/talks

Creando un SCADA con Python y HTML5
http://www.slideshare.net/nahueldefosse/creando-un-scada-con-python-y-html5

Virtual machines should be invisible
http://www.cs.iastate.edu/~design/vmil/2011/papers/p02-kell.pdf

PyCon Argentina 2012 – Design Patterns en Python // Speaker Deck
https://speakerdeck.com/dlitvakb/pycon-argentina-2012-design-patterns-en-python

Python 2 debe morir // Speaker Deck
https://speakerdeck.com/ralsina/python-2-debe-morir

PyCon 2012
http://www.infinity77.net/pycon/pycon2012.html

python – How to install pip on windows? – Stack Overflow
http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows

Flask – El microframework que revoluciona el mundo // Speaker Deck
https://speakerdeck.com/hugoruscitti/flask-el-microframework-que-revoluciona-el-mundo

pilas-engine – haciendo juegos en medio de la revolución // Speaker Deck
https://speakerdeck.com/hugoruscitti/pilas-engine-haciendo-juegos-en-medio-de-la-revolucion

slides/ponete-pilas-django at master · machinalis/slides
https://github.com/machinalis/slides/tree/master/ponete-pilas-django

slides/javascript-para-programadores-python at master · machinalis/slides
https://github.com/machinalis/slides/tree/master/javascript-para-programadores-python

¡ Bienvenido a pilas !
http://www.pilas-engine.com.ar/
Game Engine

A Simple Python NodeVisitor Example
http://codemonkeytips.blogspot.com.ar/2010/08/simple-python-nodevisitor-example.html

Eli Bendersky’s website » Blog Archive » Python internals: Working with Python ASTs
http://eli.thegreenplace.net/2009/11/28/python-internals-working-with-python-asts/

Blender – Python
https://sites.google.com/site/blenderpython/

Watch PyDay Rafaela Episodes | Blip
http://blip.tv/pyday-rafaela

Twitter / reingart: Introducción a Sugar en @pyconar …
https://twitter.com/reingart/status/269069285987598338/photo/1

Jython 2.7 and techniques for integrating with Java – Frank Wierzbicki
http://www.slideshare.net/fwierzbicki/jython-update-2012

Java Empowered by Jython
http://www.slideshare.net/fpieraut/jython

My Links
http://delicious.com/ajlopez/python

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Python: Links, News And Resources (13)

Previous Post
Next Post

Singly, OAuth
https://singly.com/features
Get started quickly with examples and libraries in Ruby (Rails, OmniAuth), Javascript (Node, Express), Python (Django), and more.

The Power of Pythonista 1.2
http://www.macdrifter.com/2012/11/the-power-of-pythonista-12.html
Pythonista is a well designed implementation of Python on iOS

7 Python Libraries you should know about
http://doda.co/7-python-libraries-you-should-know-about

Python operator precedence
http://stackoverflow.com/questions/3328355/python-operator-precedence

Strata NYC 2012 and PyData
http://blogger.ghostweather.com/2012/11/strata-nyc-2012-and-pydata.html
A talk at Strata NYC on network visualization

Simple read only attributes with meta-class programming (Python recipe)
http://code.activestate.com/recipes/197965-simple-read-only-attributes-with-meta-class-progra/

Camelot
http://www.python-camelot.com/
Camelot provides components for building business applications on top of Python, SQLAlchemy and Qt.  It is inspired by the Django admin interface.  You can use Camelot to develop both simple and complex business applications at warp speed.

Python @staticmethod vs @classmethod
http://rapd.wordpress.com/2008/07/02/python-staticmethod-vs-classmethod/

What is the difference between @staticmethod and @classmethod in Python?
http://stackoverflow.com/questions/136097/what-is-the-difference-between-staticmethod-and-classmethod-in-python

AMPPS
http://www.ampps.com/
AMPPS is a stack of the Apache Web Server, MySQL, PHP, Perl, Python and SOFTACULOUS.

Associação Python Brasil: Time to call it a day
http://www.erico.com.br/blog/2011/08/30/associacao-python-brasil-time-to-call-it-a-day

What does python print() function actually do?
http://stackoverflow.com/questions/1979234/what-does-python-print-function-actually-do

The new print function in Python 3
http://www.harshj.com/2008/12/09/the-new-print-function-in-python-3/

PyCon 2012 Argentina, Projects
http://ar.pycon.org/2012/projects/index

Tailing in Python
http://lethain.com/tailing-in-python/

Why can’t Python handle true/false values as I expect?
http://stackoverflow.com/questions/2055029/why-cant-python-handle-true-false-values-as-i-expect

#pythonIO webcast sobre Django
http://www.desarrolloweb.com/en-directo/pythonio-django-by-samuel-7619.html

bconstantin / django_polymorphic
https://github.com/bconstantin/django_polymorphic

#pythonIO – segundo round de Web2Py
http://www.youtube.com/watch?feature=player_embedded&v=mWTbJv-hRkc

Frameworks de desarrollo de videojuegos en Python en el #PyConVe
http://www.elchiguireliterario.com/2012/10/24/frameworks-de-desarrollo-de-videojuegos-en-python-en-el-pyconve/

Tv Stalker
http://www.tvstalker.tv/login
diegosarmentero / tvstalker
https://github.com/diegosarmentero/tvstalker
Tv Shows social guide

My Links
http://delicious.com/ajlopez/python

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

New Month’s Resolutions: December 2013

Review of my November’s resolutions:

This new month’s resolution:

– Start compiler reduced Python to C, using JavaScript [complete] repo
– Give a talk about Ruby in C# [complete] slides repo
– Start Ruby to JavaScript compiler [complete] repo
– Complete variable scope in Mass language [pending]
– Give a talk about compiling languages to JavaScript [complete] slides
– Write web framework for AjTalkJs (to be used in Node.js) (plain? MVC?) [pending]
– Improve NPM modules in AjTalkJs and AjTalk [partial] repo
– Improve unit test support in AjTalkjs and AjTalk [partial] repo
– Improve match and data structure in AjErl [pending]

My December’s resolutions:

– Give a one-day Node.js course
– Refactor and improve CobolScript
– Continue writing Ruby to JavaScript compiler
– Variable scope in Mass language
– More modules in AjTalkJs

More fun is coming ;-)

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Python in JavaScript/Node.js

Some weeks ago, I attended an excellent conference, PyCon Argentina 2013. I should write about my personal experience. Now, I want to publish links and comments about the talk I gave.

As other talks, it is related to JavaScrip y Node.js. I explained my work on compiling Python to JavaScript, using JavaScript. My slides at:

https://github.com/ajlopez/Talks/tree/master/PythonJavaScript

You can read them online:

http://ajlopez.github.io/Talks/PythonJavaScript/index.html

I was using Node.js:

http://nodejs.org/

The project I presented is at:

https://github.com/ajlopez/JPyScript

It can compile .py files to JavaScript, on the fly. And it can access to Node.js modules using import notation

Example:

 

Example using Express:

I mentioned other projects:

http://www.brython.info/
http://www.skulpt.org/
http://apppyjs.appspot.com/

Recently, it entered in my radar:

https://github.com/PythonJS/PythonJS

See the benchmarks:

http://pyppet.blogspot.com.ar/2013/11/brython-vs-pythonjs.html

An additional branch. Past year, I gave a talk about Python implementations, and I mentioned PyPy. This year, I assisted to interesting PyPy talks. I started to explore how to compile Python to C, this time using JavaScript. My first attempts:

https://github.com/ajlopez/RedPython

More fun is comming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

End Of Iteration 2013w44

Previous Post
Next Post

The main outcomes were: a talk, about my Smalltalk implementations, new sample code and a new project, inspired by Python and Smalltalk conference.

AjTalk Implementations

I reviewed and improved my implementations:

https://github.com/ajlopez/AjTalkJs
https://github.com/ajlopez/AjTalk

I added a sample using AjTalkJs, Node.js, Express.

My talk for Smalltalks 2013 at

https://github.com/ajlopez/Talks/tree/master/Smalltalks2013

RedPython

I want to implement a compiler/transpiler from reduced (subset of) Python to C, at first using JavaScript.

The project:

I have two samples running: simple hello world, and primes.py

https://github.com/ajlopez/RedPython

More ideas to implement this week. I should improve my Ruby in C# implementation, and maybe, write a Ruby implementation in JavaScript.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

New Month’s Resolutions: November 2013

Time to review my October resolutions:

– Give a talk about PHP and Node.js [complete] see post and PHP/Node repo and PageJs repo at PHP Dev Argentina 2013
– Give a talk about TDD with ASP.NET MVC [complete] see repo
– Give a talk about Scala implementation [complete] see slides and simple samples
– Give a talk about Python in JavaScript [complete] see repo and slides at PyCon 2013 Argentina
– Give a talk about Smalltalk in JavaScript and C# [complete] see repo and slides at Smalltalks 2013

This new month’s resolution:

– Start compiler reduced Python to C, using JavaScript
– Give a talk about Ruby in C#
– Start Ruby to JavaScript compiler
– Complete variable scope in Mass language
– Give a talk about compiling languages to JavaScript (to be confirmed)
– Write web framework for AjTalkJs (to be used in Node.js) (plain? MVC?)
– Improve NPM modules in AjTalkJs and AjTalk
– Improve unit test support in AjTalkjs and AjTalk
– Improve match and data structure in AjErl

More fun is coming 😉

Keep tuned!

Angel “Java” Lopez
@ajlopez

End Of Iteration 2013w43

Previous Post
Next Post

The week was dedicated to prepare and give a talk, and prepare this week next talk.

JPyScript

My Python to JavaScript transpiler, written using JavaScript. It runs on node.js and browser.

https://github.com/ajlopez/JPyScript

It can use Node.js modules using import, and it can run Python scripts in the browser.

I gave a talk at PyCon Argentina 2013. My slides at:

https://github.com/ajlopez/Talks/tree/master/PythonJavaScript

AjTalkJs

My Smalltalk-like VM in bytecodes and JavaScript, written in JavaScript.

https://github.com/ajlopez/AjTalkJs

Now, I can use Node.js modules, run in server and browser. Example:

I was working in minor refactoring of:

https://github.com/ajlopez/RubySharp
https://github.com/ajlopez/PythonSharp

And I was working on two non-public projects: one in C#, in-memory OLAP, and another one in Java, with agile team.

This week I will give a talk about my Smalltalk implementations at Smalltalks 2013 Argentina:

http://www.fast.org.ar/smalltalks2013

More fun is coming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez