Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
In case you want to run Selenium tests you need to run xvfb to have X virtual framebuffer (in-memory display server) you need to install it and then have script like below to run your Selenium test:

#!/bin/bash
Xvfb :10 -ac &
xvfb_pid=$!
export DISPLAY=:10
python -u test_login.py & >> /var/log/test_login.log
kill ${xvfb_pid}

In case you need to run browser in headless mode you need to install xvfb

#selenium #xvfb
Backup mysql database and gzip 9 it:

mysqldump -u $user -h $host --port=$port --password=$password $db_name | gzip -9 > "$backup_file_name"
#mysql #backup #gzip9
CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.


- https://codemirror.net/

We ourselves have used it for json prettifier in our internal tools.

#js #javascript
Heading to Zoodroom, wish me luck 😍
#job #python
Mastering #Ansible Video #Course
Media is too big
VIEW IN TELEGRAM
#ansible part2 - Ansible requirements
In Django unittests you can use fixtures in order to create dummy data. To create fixtures you can use django dumpdata command to dump a specific data:

python3 manage.py dumpdata --indent 4 YOUR_APP.YOUR_TABLE > output_data.json


This is how you can dump data and use it as your data backend for unittests.

#django #python3 #dumpdata #unittest
Working Effectively with Legacy Code - Michael C. Feathers.epub
3.8 MB
Working effectively with legacy code
#ebook #pdf #epub
Is there a way to create ObjectID from an INT in MongoDB?

import bson

def object_id_from_int(n):
s = str(n)
s = '0' * (24 - len(s)) + s
return bson.ObjectId(s)

def int_from_object_id(obj):
return int(str(obj))

n = 12345
obj = object_id_from_int(n)
n = int_from_object_id(obj)
print(repr(obj)) # ObjectId('000000000000000000012345')
print(n) # 12345


#mongodb #objectid #pymongo #python #bson #int