Sep 2, 2018

create manual tabs on odoo 11 without snippet

just put this code to your view



<div>
                    <!-- Thumbnail -->
                    <div class="oe_snippet_thumbnail">
                        <img class="oe_snippet_thumbnail_img" src="/website_tabs/static/src/img/thumbnail.png" />
                        <span class="oe_snippet_thumbnail_title">Tabs</span>
                    </div>

                    <!-- Snippet Body -->
                    <section class="oe_snippet_body cst mt16 mb16">
                        <div class="container">
                            <div class="row">
                                <div role="tabpanel">
                                    <!-- Nav tabs -->
                                    <ul class="nav nav-tabs" role="tablist">
                                        <li role="presentation" class="active"><a href="#tab1" aria-controls="tab1" role="tab" data-toggle="tab">Text Block</a></li>
                                        <li role="presentation"><a href="#tab2" aria-controls="tab2" role="tab" data-toggle="tab">Text-Image</a></li>
                                        <li role="presentation"><a href="#tab3" aria-controls="tab3" role="tab" data-toggle="tab">Image-Text</a></li>
                                    </ul>
                                    <!-- Tab panes -->
                                    <div class="tab-content">
                                        <div role="tabpanel" class="oe_structure oe_empty tab-pane active" id="tab1">
                                            <section class="mb16">
                                                <!-- Text Block snippet -->
                                                <div class="container">
                                                    <div class="row">
                                                        <div class="col-md-12 text-center mt16 mb32">
                                                            <h2>A Great Headline</h2>

                                                            <h3 class="text-muted">A good subtitle</h3>
                                                        </div>

                                                        <div class="col-md-12 mb16 mt16">
                                                            <p>A great way to catch your reader's attention is to tell a
                                                            story. Everything you consider writing can be told as a
                                                            story.</p>

                                                            <p><b>Great stories have personality.</b> Consider telling a
                                                            great story that provides personality. Writing a story with
                                                            personality for potential clients will asist with making a
                                                            relationship connection. This shows up in small quirks like
                                                            word choices or phrases. Write from your point of view, not
                                                            from someone else's experience.</p>

                                                            <p><b>Great stories are for everyone even when only written for
                                                            just one person.</b> If you try to write with a wide general
                                                            audience in mind, your story will ring false and be bland. No
                                                            one will be interested. Write for one person. If it’s genuine
                                                            for the one, it’s genuine for the rest.</p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </section>
                                        </div>
                                        <div role="tabpanel" class="oe_structure oe_empty tab-pane" id="tab2">
                                            <section class="mt16 mb16">
                                                <!-- Text-Image snippet -->
                                                <div class="container">
                                                    <div class="row">
                                                        <div class="col-md-6 mt16">
                                                            <h3>A Section Subtitle</h3>

                                                            <p>Write one or two paragraphs describing your product or
                                                            services. To be successful your content needs to be useful to
                                                            your readers.</p>

                                                            <p>Start with the customer – find out what they want and give
                                                            it to them.</p>
                                                        </div>

                                                        <div class="col-md-6 mt16"><img alt="Odoo text and image block"
                                                        class="img img-responsive shadow mb16" src=
                                                        "/website/static/src/img/text_image.png"/></div>
                                                    </div>
                                                </div>
                                            </section>
                                        </div>
                                        <div role="tabpanel" class="oe_structure oe_empty tab-pane" id="tab3">
                                            <!-- Image-Text snippet -->
                                            <section class="mt16 mb16">
                                                <div class="container">
                                                    <div class="row">
                                                        <div class="col-md-6 mt16"><img alt="Odoo image and text block"
                                                        class="img img-responsive shadow mb16" src=
                                                        "/website/static/src/img/image_text.jpg"/></div>

                                                        <div class="col-md-6 mt16">
                                                            <h3>A Section Subtitle</h3>

                                                            <p>Write one or two paragraphs describing your product,
                                                            services or a specific feature. To be successful your content
                                                            needs to be useful to your readers.</p>

                                                            <p>Start with the customer – find out what they want and give
                                                            it to them.</p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </section>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
Read more ...

Aug 7, 2018

spynner vs pyppeteer vs requests vs firefox headless

memory usage : spynner vs pyppeteer vs requests vs firefox headless

febru@ubuntu:~$ ps_mem -p 41293
 Private  +   Shared  =  RAM used Program

  5.9 MiB + 394.5 KiB =   6.3 MiB python2.7
---------------------------------
                          6.3 MiB
=================================
febru@ubuntu:~$ ps_mem -p 41603
 Private  +   Shared  =  RAM used Program

 16.2 MiB +   2.3 MiB =  18.5 MiB python3.5
---------------------------------
                         18.5 MiB
=================================
febru@ubuntu:~$ ps_mem -p 41699
 Private  +   Shared  =  RAM used Program

 11.9 MiB + 538.5 KiB =  12.5 MiB python2.7
---------------------------------
                         12.5 MiB

=================================
febru@ubuntu:~$ ps_mem -p 22208
 Private  +   Shared  =  RAM used Program

  9.0 MiB +   1.6 MiB =  10.6 MiB python2.7
---------------------------------
                         10.6 MiB
=================================


the winner is SPYNNER ... yeeaaaaa  
Read more ...

Jul 18, 2018

SOLVED InsecurePlatformWarning: A true SSLContext object is not available.

in my case, its solved by :

sudo su :

pip install -U pip
pip install -U pyopenssl ndg-httpsclient pyasn1


Read more ...

Jul 17, 2018

just simple ocr

$ sudo apt-get update
$ sudo apt-get install autoconf automake libtool
$ sudo apt-get install libpng12-dev
$ sudo apt-get install libjpeg62-dev
$ sudo apt-get install g++
$ sudo apt-get install libtiff4-dev
$ sudo apt-get install libopencv-dev libtesseract-dev
$ sudo apt-get install git
$ sudo apt-get install cmake
$ sudo apt-get install build-essential
$ sudo apt-get install libleptonica-dev
$ sudo apt-get install liblog4cplus-dev
$ sudo apt-get install libcurl3-dev
$ sudo apt-get install python2.7-dev
$ sudo apt-get install tk8.5 tcl8.5 tk8.5-dev tcl8.5-dev
$ sudo apt-get build-dep python-imaging --fix-missing
$ sudo apt-get install imagemagick

sudo apt-get build-dep python-imaging --fix-missing



$ wget http://www.leptonica.com/source/leptonica-1.76.0.tar.gz
tar -zxvf leptonica-1.76.0.tar.gz
$ cd leptonica-1.76.0/
$ ./autobuild
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig


wget https://github.com/tesseract-ocr/tesseract/archive/3.05.02.tar.gz
$ tar -zxvf 3.05.02.tar.gz
$ cd tesseract-3.05.02/
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

export TESSDATA_PREFIX=/usr/local/share/
sudo cp -r tessdata $TESSDATA_PREFIX

wget http://tessdata.projectnaptha.com/3.02/eng.traineddata.gz
gunzip eng.traineddata.gz
sudo cp -r eng.traineddata $TESSDATA_PREFIX


wget https://github.com/rhgraysonii/ocr_tutorial/archive/v0.tar.gz
$ tar -xf v0.tar.gz
cd python_ocr_tutorial-0/
sudo apt-get install python-virtualenv
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt


ocr.py
===================
import pytesseract
import requests
from PIL import Image
from PIL import ImageFilter
from StringIO import StringIO


def process_image(url):
    image = _get_image(url)
    image.filter(ImageFilter.SHARPEN)
    return pytesseract.image_to_string(image)


def _get_image(url):
    return Image.open(StringIO(requests.get(url, verify=False).content))




curl -X POST http://localhost:5000/v1/ocr -d '{"image_url": "https://ecs7.tokopedia.net/img/product-1/2015/5/6/329033/329033_ea3477c4-f38e-11e4-ba78-9dda64efb121.jpg" }' -H "Content-Type: application/json"


cli.py
====================



import sys
import requests
import pytesseract
from PIL import Image
from StringIO import StringIO


def get_image(url):
    return Image.open(StringIO(requests.get(url).content))


if __name__ == '__main__':
    """Tool to test the raw output of pytesseract with a given input URL"""
    sys.stdout.write("""
===OOOO=====CCCCC===RRRRRR=====\n
==OO==OO===CC=======RR===RR====\n
==OO==OO===CC=======RR===RR====\n
==OO==OO===CC=======RRRRRR=====\n
==OO==OO===CC=======RR==RR=====\n
==OO==OO===CC=======RR== RR====\n
===OOOO=====CCCCC===RR====RR===\n\n
""")
    sys.stdout.write("A simple OCR utility\n")
    url = raw_input("What is the url of the image you would like to analyze?\n")
    image = get_image(url)
    sys.stdout.write("The raw output from tesseract with no processing is:\n\n")
    sys.stdout.write("-----------------BEGIN-----------------\n")
    sys.stdout.write(pytesseract.image_to_string(image) + "\n")
    sys.stdout.write("------------------END------------------\n")



source : https://realpython.com/setting-up-a-simple-ocr-server/


Read more ...

Jul 15, 2018

playing with socat

liat komunikasi header (request + response)
    sudo socat -v TCP-LISTEN:8001,fork  TCP:192.168.100.100:8069  

lihat komunikasi data  (request + response)
    socat -u tcp4-listen:1934,fork SYSTEM:'tee in.txt |socat - "TCP:192.168.100.100:8069" |tee out.txt'

check header request
    socat -u tcp4-listen:1934 -

forward to 2 destination, just first
    socat -u tcp4-listen:1934 - | tee >(socat - tcp4:127.0.0.1:1935) >(socat - tcp4:127.0.0.1:1936) > /dev/null

Read more ...