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 / 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
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 / speed_typing_reference.md
Created March 8, 2017 00:44
speed typing improvement reference
@repodevs
repodevs / django.py
Last active March 24, 2017 09:06
Django Bypas CSRF and simple requests login
# app/views.py
from django.contrib.auth import authenticate, login
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def login_user(request):
user = authenticate(username=request.POST['username'], password=request.POST['password'])
login(request, user)
return HttpResponse("Logged In")
@repodevs
repodevs / coa.csv
Created April 28, 2017 16:29
Example Chart of Accounts
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
External ID;Code;Name;Allow Reconciliation;Type/ID
__export__.account_account_176;1.01.01.01;Kas Belum Disetor Cabang Bandung;True;3
__export__.account_account_177;1.01.01.02;Kas Kecil Cabang Bandung;True;3
__export__.account_account_174;1.01.04.01;Piutang Usaha Cabang Bandung;True;1
__export__.account_account_175;2.01.01.01;Hutang Usaha Cabang Bandung;True;2
;1.01.01.02;Kas Belum Disetor Cabang Bali;True;3
;1.01.01.03;Kas Kecil Cabang Bali;True;3
;1.01.04.02;Piutang Usaha Cabang Bali;True;1
;2.01.01.02;Hutang Usaha Cabang Bali;True;2
;1.01.01.03;Kas Belum Disetor Cabang Bekasi;True;3
@repodevs
repodevs / odoo_uninstall_addons.py
Created June 13, 2017 08:13
python script to uninstall odoo addons via xmlrpc
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""Uninstall a module"""
import xmlrpclib
import argparse
import getpass
parser = argparse.ArgumentParser()
# Connection args
@repodevs
repodevs / cancel_reason.py
Created July 17, 2017 10:45
add field in existing odoo models
from odoo import models, fields, api, _
class SiteSurvey(models.Model):
_inherit = "site.survey"
cancel_reason = fields.Char("cancel reason")
class SiteSurveyWizard(models.TransientModel):
_name = "site.survey.wizard"

Keybase proof

I hereby claim:

  • I am repodevs on github.
  • I am repodevs (https://keybase.io/repodevs) on keybase.
  • I have a public key whose fingerprint is 32C0 64EA 1713 F990 2ACF 6B2B 96A3 FF2F 38AF 394C

To claim this, I am signing this object: