Skip to content

Instantly share code, notes, and snippets.

View repodevs's full-sized avatar

Edi Santoso repodevs

View GitHub Profile
@repodevs
repodevs / gist:f1683ff26cef7f2cacf5
Created December 9, 2015 03:11 — forked from evildmp/gist:3094281
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@repodevs
repodevs / views.py
Created January 27, 2016 20:55
models grouping by date and count data
# 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')]
@repodevs
repodevs / knownpaths.py
Created April 19, 2016 10:21 — forked from mkropat/knownpaths.py
Python wrapper around the SHGetKnownFolderPath Windows Shell function
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)
@repodevs
repodevs / my-nginx.conf
Created December 22, 2016 03:02
nginx error page with custom css
## 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;
}
@repodevs
repodevs / insert_50k_odoo_customer.py
Last active January 12, 2017 15:58 — forked from jasimmk/insert_50k_odoo_customer.py
Helps us create 50k customers in odoo; Install fake factory at first. pip install fake-factory
#!/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
@repodevs
repodevs / py_create_odoo_contacts.py
Created January 15, 2017 08:21
odoo create data contact from csv file
#!/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="^")
@repodevs
repodevs / nginx_odoo.conf
Created January 18, 2017 06:52
odoo nginx config
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}]
@repodevs
repodevs / main.js
Created February 26, 2017 05:42
electron example with odoo
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();
@repodevs
repodevs / speed_typing_reference.md
Created March 8, 2017 00:44
speed typing improvement reference