This document has now been incorporated into the uWSGI documentation:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Steps with explanations to set up a server using:
| # simple snippet data to grouping and counting a django models | |
| # for example in this data | |
| # I have fields with attribute DateTimeField | |
| # so I use `Model.objects.datetimes` | |
| # Because I just want get day,month,year | |
| # If you just use fields `DateTime` Prefer you can use `Model.objects.date` | |
| users = Model.objects.all() # Models to be grouping | |
| count_user = [{'val': users.filter(date_joined__day=x.day,date_joined__month=x.month,date_joined__year=x.year).count(), 'date':x.strftime('%Y-%m-%d')} for x in Model.objects.datetimes('date_joined','day')] |
| import ctypes, sys | |
| from ctypes import windll, wintypes | |
| from uuid import UUID | |
| class GUID(ctypes.Structure): # [1] | |
| _fields_ = [ | |
| ("Data1", wintypes.DWORD), | |
| ("Data2", wintypes.WORD), | |
| ("Data3", wintypes.WORD), | |
| ("Data4", wintypes.BYTE * 8) |
| ## lets say we have erro page err.html in we css folder, | |
| ## we want nginx can serve the css... blah talk is cheap, lets see the conf \ :v / | |
| error_page 500 502 503 504 = @errorz; | |
| location @errorz { | |
| root /var/www/html/e; | |
| try_files $uri /index.html = 500 502 503 504; | |
| } |
| #!/usr/bin/env python | |
| # Install fake factory at first. Helps us create 50k customers in odoo | |
| # pip install fake-factory | |
| # Documentation for odoo is listed here | |
| # https://www.odoo.com/documentation/9.0/api_integration.html#calling-methods | |
| # MIT License | |
| # Copyright (c) 2016 Jasim Muhammed |
| #!/usr/bin/python | |
| import argparse | |
| import odoorpc | |
| import csv | |
| # set arguments parser | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("-f", "--file", help="csv file to import") | |
| parser.add_argument("-d", "--delimiter", help="delimiter for csv file", default="^") |
| server { | |
| listen 80 default_server; | |
| #rewrite ^/.*$ https://$host$request_uri? permanent; #Uncomment this line in case you want to use https only | |
| #server_name {{ODOO_DOMAIN}}; | |
| include odoo_params; | |
| location /longpolling { | |
| proxy_pass http://127.0.0.1:8072; | |
| } | |
| location / { |
| cr = self.env.cr | |
| sql = 'select product_id, location_id, sum(qty) from stock_quant where location_id != 9 group by location_id, product_id order by product_id asc limit 10' | |
| cr.execute(sql) | |
| cr.dictfetchall() | |
| """ | |
| Example Output: | |
| [{'sum': 4.0, 'location_id': 19, 'product_id': 13}, {'sum': 1.0, 'location_id': 12, 'product_id': 13}, {'sum': 20.0, 'location_id': 19, 'product_id': 14}, {'sum': 2.0, 'location_id': 12, 'product_id': 14}, {'sum': 3.0, 'location_id': 19, 'product_id': 15}, {'sum': 3.0, 'location_id': 12, 'product_id': 16}, {'sum': 6.0, 'location_id': 19, 'product_id': 16}, {'sum': 28.0, 'location_id': 19, 'product_id': 17}, {'sum': 3.0, 'location_id': 19, 'product_id': 18}, {'sum': 6.0, 'location_id': 12, 'product_id': 18}] |
| const electron = require('electron'); | |
| const rq = require('request-promise'); | |
| const notifier = require('node-notifier'); | |
| const app = electron.app; | |
| const BrowserWindow = electron.BrowserWindow; | |
| let mainWindow | |
| app.on('window-all-closed', function() { | |
| app.quit(); |