Skip to content

Instantly share code, notes, and snippets.

View ilyasProgrammer's full-sized avatar

Ilyas ilyasProgrammer

  • Sindelfingen
View GitHub Profile
select schemaname as table_schema,
relname as table_name,
pg_size_pretty(pg_total_relation_size(relid)) as total_size,
pg_size_pretty(pg_relation_size(relid)) as data_size,
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid))
as external_size
from pg_catalog.pg_statio_user_tables
order by pg_total_relation_size(relid) desc,
pg_relation_size(relid) desc
limit 10;
@ilyasProgrammer
ilyasProgrammer / cal.lua
Created November 27, 2023 10:30 — forked from meskarune/cal.lua
conky calendar and weather
#!/usr/bin/env lua
conky_color = "${color1}%2d${color}"
t = os.date('*t', os.time())
year, month, currentday = t.year, t.month, t.day
daystart = os.date("*t",os.time{year=year,month=month,day=01}).wday
month_name = os.date("%B")
@ilyasProgrammer
ilyasProgrammer / psql-with-gzip-cheatsheet.sh
Created June 10, 2022 10:27 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@ilyasProgrammer
ilyasProgrammer / action.xml
Last active October 19, 2021 06:22
To call a wizard from Action menu and apply it to a record set just need to set binding_view_types
<record id="action_view_link_mo_to_task" model="ir.actions.act_window">
<field name="name">Link MO to Task</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">link.mo.to.task</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="mrp.model_mrp_production"/>
<field name="binding_view_types">list</field>
</record>
@ilyasProgrammer
ilyasProgrammer / rotate.py
Created April 29, 2021 11:28
Rotate CSV from attachment
atts = self.env['ir.attachment'].search([('res_model', '=', 'syscoon.financeinterface'),
('type', '=', 'binary'),
('res_id', '=', export_id)])
for at in atts:
# order lines by date asc. just revert CSV file data rows.
data = base64.decodebytes(at.datas).decode("latin")
stream = StringIO(data)
dialect = csv.Sniffer().sniff(data[:5000])
data_list = list(csv.reader(stream, dialect=dialect))
file_path = "/var/tmp/" + at.name
@ilyasProgrammer
ilyasProgrammer / pdf.py
Created April 20, 2021 11:40
Rotate PDF
import PyPDF2
to_rotate_path = '/var/tmp/to_rotate.pdf'
fh = open(to_rotate_path, "wb")
fh.write(base64.decodebytes(att.datas))
fh.close()
rotated_path = self.rotate_pdf(to_rotate_path)
def rotate_pdf(self, path):
pdf_in = open(path, 'rb')
@ilyasProgrammer
ilyasProgrammer / img.py
Last active April 20, 2021 11:41
PDF to Image and rotate
from pdf2image import convert_from_path, convert_from_bytes
from io import BytesIO
image = convert_from_bytes(base64.decodebytes(att.datas))[0].rotate(90, expand=True)
buffered = BytesIO()
image.save(buffered, format="JPEG")
img_str = base64.b64encode(buffered.getvalue())
@ilyasProgrammer
ilyasProgrammer / sql.sh
Last active March 29, 2021 16:02
MS SQL Connect Linux
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod bionic main" | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt update
sudo apt install msodbcsql17
import pyodbc
import pandas as pd
cnxn = pyodbc.connect("Driver={/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.7.so.2.1};"
@ilyasProgrammer
ilyasProgrammer / popup.py
Created March 27, 2021 15:05
Odoo pop up
notification = {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': ('Your Custom Title'),
'message': 'Your Custom Message',
'type':'success', #types: success,warning,danger,info
'sticky': True, #True/False will display for few seconds if false
},
}
@ilyasProgrammer
ilyasProgrammer / template.xml
Last active March 17, 2021 10:28
Inherit Qweb template defined as t t-name
<templates id="template" xml:space="preserve">
<!-- main_menu is a template in module stock_barcode -->
<t t-extend="main_menu">
<t t-jquery=".message_demo_barcodes" t-operation="append">
And barcode <a href="/mrp_workorder/static/src/pdf/barcodes_actions_Manufacturing.pdf" target="_blank" aria-label="Download" title="Download">commands for Manufacturing</a>.
</t>
</t>
</templates>