Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
In order to remove a specific document in couchDB, you just need to give delete function the document itself:
couch = couchdb.Server('http://SERVER_IP:PORT/')
your_db = couch['your_db_name']

# we assume you have fetched your_couch_db_doc document
your_db.delete(your_couch_db_doc)

Use this method in preference over __del__ to ensure you're deleting the revision that you had previously retrieved. In the case the document has been updated since it was retrieved, this method will raise a ResourceConflict exception:
>>> db.delete(doc) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ResourceConflict: (u'conflict', u'Document update conflict.')

#couchdb #couch #delete #remove #document #python
One the most useful commands in vim is to delete or change inside of a block like {} or inside of a charater like "SOME THING".

In case you want to just delete inside of something and you don't want to go into INSERT mode just press di keyboard buttons in order, otherwise press ci keyboard buttons to go in INSERT mode and change something.

Let's give an example. Suppose we have lines like below and we have opened it in vim:
user_id = "43dd94e5d79ffeb2ffffabd112d5e945"
name = "Alireza"
dob = "SECRET :)"

Place the cursor between double quotes somewhere in the SECRET :) and press d then press c keys and finally press double quote ("). The vim will search for the surrounding double quotes and will remove everything inside of it. Our output is:
user_id = "43dd94e5d79ffeb2ffffabd112d5e945"
name = "Alireza"
dob = ""

Now let's assume we have a block of code like below:
users_data = {
}

Go inside of the block of curly braces (`{}`) and put your cursor inside of the block. Now press c on your keyboard then press i afterward, and at the end press { on your keyboard. It will delete everything inside of {} for you and put your vim mode in INSERT mode. So you would have the following output:
users_data = {
}

You can do the same with every block of code and every character like (), [], '', etc.

ci stands for Change Inside
di stands for Delete Inside

#vim #tricks #commands #change #delete #ci #di
Delete elasticsearch indexes older than 1 month:

#!/bin/bash

last_month=`date +%Y%m%d --date '1 month ago'`
old_es_index="faxplus_*-$last_month"
echo "Deleting ES indexes $old_es_index..."
curl -X DELETE 'http://localhost:9200/myindex_*-20180520'
echo ''

NOTE: asterisk in curl command will be anything in between of myindex_ and -20180520. For example myindex_module1-20180520.

#linux #sysadmin #bash #script #es #elasticsearch #DELETE #purge
How do you delete all text above a certain line?

dgg

Will delete everything from your current line to the top of the file.

#vim #delete #dgg