Monday, July 21, 2014

Getting Started with Edge.js

Quote from site :

Edge.js is a node.js module that let’s you run C# code from Javascript or vice-versa. It even works on
OSX and Linux through Mono. This essentially lets you write native addons in C# instead of C.



http://mcluck90.tumblr.com/post/89814519378/getting-started-with-edge-js

Saturday, July 12, 2014

Running multiplie Python apps with uwsgi and nginx

Quote from site :

This is a recipe on how to easily run multiple Python web applications using uwsgi server (in emperor mode) and behind nginx. Most existing docs and blogs would show how to manually start uwsgi to run a single app. In this post, I'll show how to configure uwsgi as a system service (with upstart) capable of serving multiple python WSGI compliant web applications by simply placing them in a standard location and adding an standard xml file.

http://jawher.me/2012/03/16/multiple-python-apps-with-nginx-uwsgi-emperor-upstart/ 


Wednesday, July 2, 2014

Sunday, June 22, 2014

Install Web2py + Nginx + uwsgi on Ubuntu Server

#!/bin/bash
echo 'setup-web2py-nginx-uwsgi-ubuntu-precise.sh'
echo 'Requires Ubuntu > 12.04 and installs Nginx + uWSGI + Web2py'
# Check if user has root privileges
if [[ $EUID -ne 0 ]]; then
   echo "You must run the script as root or using sudo"
   exit 1
fi
# Get Web2py Admin Password
echo -e "Web2py Admin Password: \c "
read  PW
# Upgrade and install needed software
apt-get update
apt-get -y upgrade
apt-get autoremove
apt-get autoclean
apt-get -y install nginx-full
apt-get -y install build-essential python-dev libxml2-dev python-pip unzip
pip install setuptools --no-use-wheel --upgrade
PIPPATH=`which pip`
$PIPPATH install --upgrade uwsgi
# Create common nginx sections
mkdir /etc/nginx/conf.d/web2py
echo '
gzip_static on;
gzip_http_version   1.1;
gzip_proxied        expired no-cache no-store private auth;
gzip_disable        "MSIE [1-6]\.";
gzip_vary           on;
' > /etc/nginx/conf.d/web2py/gzip_static.conf
echo '
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
' > /etc/nginx/conf.d/web2py/gzip.conf
# Create configuration file /etc/nginx/sites-available/web2py
echo 'server {
        listen          80;
        server_name     $hostname;
        ###to enable correct use of response.static_version
        location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
            alias /home/www-data/web2py/applications/$1/static/$2;
            expires max;
            ### if you want to use pre-gzipped static files (recommended)
            ### check scripts/zip_static_files.py and remove the comments
            # include /etc/nginx/conf.d/web2py/gzip_static.conf;
        }
        ###

        ###if you use something like myapp = dict(languages=['en', 'it', 'jp'], default_language='en') in your routes.py
        #location ~* ^/(\w+)/(en|it|jp)/static/(.*)$ {
        #    alias /home/www-data/web2py/applications/$1/;
        #    try_files static/$2/$3 static/$3 =404;
        #}
        ###
       
        location / {
            #uwsgi_pass      127.0.0.1:9001;
            uwsgi_pass      unix:///tmp/web2py.socket;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;

            ###remove the comments to turn on if you want gzip compression of your pages
            # include /etc/nginx/conf.d/web2py/gzip.conf;
            ### end gzip section

            ### remove the comments if you use uploads (max 10 MB)
            #client_max_body_size 10m;
            ###
        }
}
server {
        listen 443 default_server ssl;
        server_name     $hostname;
        ssl_certificate         /etc/nginx/ssl/web2py.crt;
        ssl_certificate_key     /etc/nginx/ssl/web2py.key;
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;
        ssl_ciphers ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA;
        ssl_protocols SSLv3 TLSv1;
        keepalive_timeout    70;
        location / {
            #uwsgi_pass      127.0.0.1:9001;
            uwsgi_pass      unix:///tmp/web2py.socket;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
            ###remove the comments to turn on if you want gzip compression of your pages
            # include /etc/nginx/conf.d/web2py/gzip.conf;
            ### end gzip section
            ### remove the comments if you want to enable uploads (max 10 MB)
            #client_max_body_size 10m;
            ###
        }
        ###to enable correct use of response.static_version
        location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
            alias /home/www-data/web2py/applications/$1/static/$2;
            expires max;
            ### if you want to use pre-gzipped static files (recommended)
            ### check scripts/zip_static_files.py and remove the comments
            # include /etc/nginx/conf.d/web2py/gzip_static.conf;
        }
        ###

}' >/etc/nginx/sites-available/web2py

ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2py
rm /etc/nginx/sites-enabled/default
mkdir /etc/nginx/ssl
cd /etc/nginx/ssl

openssl genrsa 1024 > web2py.key
chmod 400 web2py.key
openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt
openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info


# Prepare folders for uwsgi
sudo mkdir /etc/uwsgi
sudo mkdir /var/log/uwsgi

# Create configuration file /etc/uwsgi/web2py.ini
echo '[uwsgi]

socket = /tmp/web2py.socket
pythonpath = /home/www-data/web2py/
mount = /=wsgihandler:application
processes = 4
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
stats = /tmp/stats.socket
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
uid = www-data
gid = www-data
cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o
no-orphans = true
' >/etc/uwsgi/web2py.ini

#Create a configuration file for uwsgi in emperor-mode
#for Upstart in /etc/init/uwsgi-emperor.conf
echo '# Emperor uWSGI script

description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [06]
##
#remove the comments in the next section to enable static file compression for the welcome app
#in that case, turn on gzip_static on; on /etc/nginx/nginx.conf
##
#pre-start script
#    python /home/www-data/web2py/web2py.py -S welcome -R scripts/zip_static_files.py
#    chown -R www-data:www-data /home/www-data/web2py/*
#end script
respawn
exec uwsgi --master --die-on-term --emperor /etc/uwsgi --logto /var/log/uwsgi/uwsgi.log
' > /etc/init/uwsgi-emperor.conf
# Install Web2py
mkdir /home/www-data
cd /home/www-data
wget http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
mv web2py/handlers/wsgihandler.py web2py/wsgihandler.py
rm web2py_src.zip
chown -R www-data:www-data web2py
cd /home/www-data/web2py
sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)"
start uwsgi-emperor
/etc/init.d/nginx restart

## you can reload uwsgi with
# restart uwsgi-emperor
## and stop it with
# stop uwsgi-emperor
## to reload web2py only (without restarting uwsgi)
# touch /etc/uwsgi/web2py.ini

Monday, June 16, 2014

Beginners Guide to Writing Flask Apps on OpenShift

Nice tutorial,

https://www.openshift.com/blogs/beginners-guide-to-writing-flask-apps-on-openshift

Easy WebSockets with Flask and Gevent

Quote from site

I'm happy to introduce Flask-SocketIO, a very easy to use extension that enables WebSocket communications in Flask applications.

http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent

Flask-SocketIO

Quote from site:

Flask-SocketIO gives Flask applications access to low latency bi-direccional communications between the clients and the server. The client-side application can use the SocketIO Javascript library or any compatible client to establish a permanent connection to the server.

http://flask-socketio.readthedocs.org/en/latest/

Wednesday, June 11, 2014

Playfull - Game Article

Nice articles on different canvas techniques :

http://www.playfuljs.com/

CrunchMe - Javascript tool compression

Quote from site


CrunchMe is a tool for compressing JavaScript source code into a self-extracting JavaScript program


http://crunchme.bitsnbites.eu/

Visto JavaScript Framework (VistoJS)

Quote from site:
The Visto JavaScript Framework (VistoJS) integrates KnockoutJS, JQuery and RequireJS (and TypeScript) to provide the programming model known from .NET XAML and MVVM: It is possible to implement views with "code-behind" and bindings to view models, declaratively load subviews in HTML and navigate between pages - all in a single-page application.

The main advantages of this library is that it allows to develop component-based and implement reusable views which are composed of predefined programming blocks (view, view model and HTML). These views can be reused as sub views, in dialogs or as page instances. The programming API and paradigm is very similar to the one found in Windows Phone XAML or Windows 8 Store Apps programming (MVVM pattern, view "code-behind", paging/navigation).

http://visto.codeplex.com/

Tuesday, June 10, 2014

Learn Python Through Public Data Hacking

Quote from site :

David Beazley
What's more fun than learning Python? Learning Python by hacking on public data! In this tutorial, you'll learn Python basics by reading files, scraping the web, building data structures, and analyzing real world data



Python Data Hacking

Converts a Meteor app into a "standard" Node.js application

Quote from site:

Demeteorizer

CLI tool to convert a Meteor app into a "standard" Node.js application. The resulting app contains a package.json file with all required dependencies and can be easily ported to your own servers or Node.js PAAS providers.
Demeteorizer's output is similar to meteor bundle except that it generates a package.json containing all required dependencies. This allows you to easily run npm install on the destination server, which is especially important for compiled modules.

 https://github.com/onmodulus/demeteorizer

Friday, June 6, 2014

Getting chatty with Meteor.js

Quote from site

Meteor is a full-stack application platform which lets you write everything with JavaScript, because y’know…yay JavaScript.
For more of the actual features, please visit Meteor.com.
My aim, by the end of this article, is for you to be able to build, not a Hello World app, not a Todo app, but drumroll …a Realtime Chat App. Cool, huh!?

Fast Track to Intel® XDK NEW

Wonderful tutorial for developing mobile apps with XDK

Quote from site : 

Fast Track to Intel® XDK NEW is designed to teach experienced web developers and designers how to design, implement, and package web applications for mobile devices. The course is task-based, with you learning by performing a series of hands-on tasks. Over the next four hours you will create a web application named “Friends with Beer” that enables users to create a themed contact manager that uses many mobile-specific features such as calculating geoposition, video playback, push notifications, phone dialing, sending emails, and more!

 https://software.intel.com/en-us/html5/articles/fast-track-to-intel-xdk-new


Thursday, June 5, 2014

XDK Intel - Ajax calls

Sample from  StackOverflow

http://stackoverflow.com/questions/21890565/intel-xdk-doesnt-let-me-make-ajax-calls
<html>
<head>
    <title>AJAX and XDK</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0;" />
    <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>  
    <script src="intelxdk.js"></script>
    <script src="xhr.js"></script>
    <script>
        function doAJAX() {
            $.ajax({
                type:'GET',
                url:'http://time.jsontest.com/',
                success: function (data) {
                    alert(JSON.stringify(data))
                }
            });
        }
</script>
<style>
    body {font-family:arial;background-color:white}
</style>    
</head>
<body>         
    <h3>AJAX Call</h3>
    <button onclick="doAJAX()">AJAX Call</button>
</body>
</html>

Async Javascript

Quote from site :

Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js, it can also be used directly in the browser. Also supports component.
Async provides around 20 functions that include the usual 'functional' suspects (map, reduce, filter, each…) as well as some common patterns for asynchronous control flow (parallel, series, waterfall…). All these functions assume you follow the Node.js convention of providing a single callback as the last argument of your async function.

https://github.com/caolan/async

Quick Examples :
async.map(['file1','file2','file3'], fs.stat, function(err, results){
    // results is now an array of stats for each file
});

async.filter(['file1','file2','file3'], fs.exists, function(results){
    // results now equals an array of the existing files
});

async.parallel([
    function(){ ... },
    function(){ ... }
], callback);

async.series([
    function(){ ... },
    function(){ ... }
]);

Monday, June 2, 2014

Python WSGI with Node-Webkit

Quote from site :

Let us combine the greatness of HTML/CSS/Javascript for user interface with Python the best way to build backend to create a desktop app.
The basic idea is to use create a python webserver process, wait for it to start and display your app. After your app closes it will close the webserver process.

http://blog.infireal.com/wsgi-node-webkit-2014-03.html


Wednesday, May 28, 2014

Single-File Stand-alone Python 2.7.5 for Windows

If you don't want to install Python on your client.
Here is a solution :

Quote from site :

I frequently write programs in python as it is a handy, powerful language. However, sometimes I don't want to install it. There are some other projects to give a portable python implementation. That still seems too heavy for some tasks.
Here is a Windows executable form of Python 2.7.5 that contains most of the standard libraries, plus pywin32. It has the following features:
  • Single file with no dependencies besides Windows (XP or later)
  • Can run python programs (e.g., py.exe sample_program.py)
  • Can be used as an interactive shell (e.g., py.exe, then start typing)
  • Can be used to execute string commands (e.g., py.exe -c "print 'hello world'")

I've included the very simple source code, which is nothing more than a setup.py script using py2exe. I compressed the executable using upx, which reduces its size by 12% or so and doesn't substantially slow down starting the program.

http://www.orbitals.com/programs/pyexe.html

Javascript CorMVC

This library is one which influenced the most my way to write Javascript applications.
Quote from site :

CorMVC stands for, "Client-Only-Required Model-View-Controller," and is designed to be an extract-and-run learning tool for those who want to start building more complex applications. It does not presuppose any server-side technology and requires no more than a web browser to experiment with
http://www.bennadel.com/blog/1790-cormvc-my-jquery-powered-model-view-controller-mvc-framework.htm

Book Review: Programming Collective Intelligence in Python

A nice review for a great book

Une application desktop en Node.js avec node-webkit

Citation d'après le site:

By | 29 octobre 2013
Le concept de base de Node.js est de pouvoir écrire des application en JavaScript indépendamment de tout navigateur web. Cela inclut notamment la création de serveur, mais le programme node-webkit donne une possibilité supplémentaire : la possibilité de créer des applications desktop multi-plateformes.

http://www.decouvrir-nodejs.fr/2013/10/29/une-application-desktop-en-node-js-avec-node-webkit/

Microsoft Updates Python Tools for Visual Studio

Quote from site

"PTVS," as it's called, includes "integrated IPython REPL support for smart history, shell commands and inline images." It also contains Python-specific tools like mixed mode debugging of Python with C++ and remote debugging of Linux servers in Azure.

http://visualstudiomagazine.com/articles/2014/04/10/python-tools-for-visual-studio.aspx 

Using Knockout Custom Binding Handlers

Quote from site:

Knockout custom binding handlers can help simplify integration with third-party JavaScript libraries. Here's how.

 http://visualstudiomagazine.com/articles/2014/04/01/using-knockout-custom-binding-handlers.aspx

StreamlineJS Asynchronous programming made easy

Take a look at the sample page

http://sage.github.io/streamlinejs/examples/streamlineMe/streamlineMe.html

Build Desktop Apps with JavaScript and Node WebKit

Quote from site

What if we could approach the problem from a different angle? What if we took an existing, non-visual platform that already allows developers to do whatever they want and put a visual layer on top of it? That platform is Node.js and that visual layer is WebKit. Put them together, with Javascript as the underlying engine and WebKit as the visual layer, and you have Node-WebKit!

http://flippinawesome.org/2014/02/10/build-desktop-apps-with-javascript-and-node-webkit/

Monday, May 26, 2014

A Curious Course on Coroutines and Concurrency

Quote from site:

This tutorial is a practical exploration of using Python coroutines (extended generators) for solving problems in data processing, event handling, and concurrent programming. The material starts off with generators and builds to writing a complete multitasking environment that can run thousands of concurrent tasks without using threads or using code based on event-driven callbacks (i.e., the "reactor" model). 

http://www.dabeaz.com/coroutines/


Saturday, May 3, 2014

Monday, April 28, 2014

Cheetah 3D

Cheetah 3D is a very nice and cheap 3D modeler and rendering system when compared with 'monsters' like Maya, LightWave, Houdini..
Here is one of my first 'visible' image rendered.