Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Put your views on different design documents in couchDB in order to bypass whole DB lock for indexing. Be cautious that if your database has huge amount of data there will be an hourly lock on couchiDB on all operations!!!

So for example if you have couchDB view on:
http://YOUR_IP:5984/_utils/#/database/YOUR_DATABASE/_design/query/_view/THIS_IS_YOUR_VIEW

Put your view that is on a different category like below:
http://YOUR_IP:5984/_utils/#/database/YOUR_DATABASE/_design/NEW_DESIGN_DOCUMENT/_view/THIS_IS_YOUR_VIEW

This simple trick will prevent database lock on whole operations, the change wiill at least does not affect other views operations.

#couchdb #database #performance #lock #indexing
Get query result from MySQL for last month:

SELECT * FROM users WHERE registration_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH)

#mysql #query #interval #now #date_sub
اسنپ یکی از قابلیت‌های مهم «اوبر» به نام «uberPOOL» را به سیستم خود اضافه می‌کند. بر اساس این طرح، می‌توان تعداد سفرهای تکراری را کاهش داد، هزینه کمتری از مسافر دریافت نمود و البته سهم بیشتری نیز به راننده پرداخت.

در این راهکار که تا دو ماه دیگر عملیاتی می‌شود، مسافرانی که به شکل پیاده کمتر از ۵ دقیقه با هم فاصله داشته باشند می‌توانند از یک خودرو استفاده کنند. در واقع یک اسنپ، با این راهکار دو مسافر را جا‌به‌جا می‌کند و هزینه آن نیز ۳۰ درصد ارزان‌تر است.

#snapp #startup
Projects written in ReactJS:
- uber.com
- ubereats.com
- metbase.com
- trello.com
- instagram
- discordapp.com
Indent in vim:
1- press V and select multiple lines
2- press > (you can press > as many times as you want to indent more)

Unindent in vim:
1- press V and select multiple lines
2- press < (you can press < as many times as you want to unindent more)

#vim #commands #indent #unindent
.format() (new method) is far better than string formatters like %s,%r,%d (old method) from readability, flexibility and other point of views.
In the following pictures this is demonstrated:
Unlike string formatter, formatter() method is consistent with no change in method call.
In old style you cannot give positional index, but in format() you can.
Padding and aligning strings
These operations are not even available in old style, to choose a character for padding! :)
There are tons of these examples for format(), like thousand separator and so. Go for it and explore more.
Having local git repository server is easy enough by using docker and open source git lab project:

docker pull gitlab/gitlab-ce

#gitlab #open_source #docker
Tech C**P
Having local git repository server is easy enough by using docker and open source git lab project: docker pull gitlab/gitlab-ce #gitlab #open_source #docker
After pulling image into docker repository run the image using the command below:

sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest

Reference:
https://docs.gitlab.com/omnibus/docker/README.html

#gitlab #docker #image #docker_run
You may have used JSFiddle to interactively write JS code and get instant result. It is good to note that there is one for Database (MySQL, PostgreSQL, SQLite)!
If you want to query, create table, create partition and all the different operations on a database you can do now by using the below site without ever making a big mistake on your system:

https://www.db-fiddle.com/

#mysql #postgresql #database #fiddle #dbfiddle
When you commit to git, then you push and get rejected:

$ git push
To my_repo:~/my_project.git
! [rejected] dev -> dev (fetch first)
error: failed to push some refs to 'my_repo:~/my_project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

To prevent merging with your local and making your git history filthy, reset head to the latest commit (head~1):

$ git reset HEAD~1
Unstaged changes after reset:
M another_file_here.py
M some_file_here.py

Now git pull and the commit again and push. The world is cleaner now.

#git #reset_head #merge #repository
If you are working with #Cement, #Flask or other python frameworks that do not give ODM (Object Document Mapper) out of the box, you can use MongoEngine for MongoDB.
It has all the capabilities that you can almost imagine for an ODM to define schema and apply restrictions to it. You'll hear more about it later.

https://github.com/MongoEngine/mongoengine

#mongodb #mongoengine #ODM #python #ORM
Merging 2 wave files using scipy, audiolab:

import audiolab, scipy
a, fs, enc = audiolab.wavread('file1.wav')
b, fs, enc = audiolab.wavread('file2.wav')
c = scipy.vstack((a,b))
audiolab.wavwrite(c, 'file3.wav', fs, enc)