Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
In order to remove docker images, first see your images and their corresponding id:
sudo docker images
Now to remove an image just use rmi as below:
sudo docker rmi b0c8cfb8fdb3

b0c8cfb8fdb3 is IMAGE ID to be removed.

#docker #image #rmi #remove
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
How do I remove the passphrase for the SSH key without having to create a new key?

I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite painful when you are trying to commit (Git and SVN) to a remote location over SSH many times in an hour.
$ ssh-keygen -p
Enter file in which the key is (/Users/my_username/.ssh/id_rsa):
Enter old passphrase:
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.

This will then prompt you to enter the keyfile location, the old passphrase, and the new passphrase (`which can be left blank to have no passphrase`).

If you would like to do it all on one line without prompts do:
$ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]

NOTE: Beware that when executing commands they will typically be logged in your ~/.bash_history file (or similar) in plain text including all arguments provided (i.e. the passphrases in this case). It is therefore is recommended that you use the first option unless you have a specific reason to do otherwise.

You might want to consider using ssh-agent, which can cache the passphrase for a time. The latest versions of gpg-agent also support the protocol that is used by ssh-agent.

#id_rsa #ssh #passphrase #keygen #linux #osx #remove_passphrase
How to find documents with a specific field type?

It may happen to have different field types in a specific field like credit, and some of them are numeric and some of them string. In order to find NumberLong() field types you can use $type:

db.users.find({credit: {$type: "long" }})


If you want to remove those fields, if applicable, use remove instead of find to remove those documents that has wrong types. It is not sensible to do that for users document though, it just gives you the idea.

#mongodb #mongo #type #field_type #remove #find
Did you push a very large file into git? Does everyone yell at you about your commit and your uselessness? Are you a junky punky like me that just ruin things? Oh I'm kidding...

Because of that big file cloning the repo again would take a long long time. Removing the file locally and pushing again would not solve the problem as that big file is in Git's history.

If you want to remove the large file from your git history, so that when everyone clone the repo should not wait for that large file, just do as follow:

git filter-branch --tree-filter 'rm path/to/your/bigfile' HEAD

git push origin master --force

I should note that you should be in the root of git repo.

If you need to do this, be sure to keep a copy of your repo around in case something goes wrong.

#git #clone #rm #remove #large_file #blob #rebase #filter_branch
Delete files older than X days. You can use find command in order to find files with specific patterns in a specific directory and then remove those files:

BACKUP_DIR=/var/backup

# Number of days to keep backups
KEEP_BACKUPS_FOR=30 #days

find $BACKUP_DIR -type f -name "*.sql.gz" -mtime +$KEEP_BACKUPS_FOR -exec rm {} \;

-mtime n[smhdw]:
If no units are specified, this primary evaluates to true if the difference between the file last modification time and the time find was started, rounded up to the next full 24-hour period, is n 24-hour periods.

-exec utility [argument ...] ;
True if the program named utility returns a zero value as its exit status. Optional arguments may be passed to the utility. The expression must be terminated by a semicolon (``;''). If you invoke find from a shell you may need to quote the semicolon if the shell would otherwise treat it as a control operator. If the string ``{}'' appears anywhere in the utility name or the arguments it is replaced by the pathname of the current file. Utility will be executed from the directory from which find was executed. Utility and arguments are not subject to the further expansion of shell patterns and constructs. SO BECAREFUL SEMICOLON IS NEEDED!

#find #rm #exec #mtime #remove_old_files #remove