I wrote this four years ago, so instead use this command:
$ docker rmi $(docker images -q -f dangling=true)
Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
by Sander Marechal
I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.
| import json | |
| import urlparse | |
| from itertools import chain | |
| flatten = chain.from_iterable | |
| from nltk import word_tokenize | |
| from gensim.corpora import Dictionary | |
| from gensim.models.ldamodel import LdaModel | |
| from gensim.models.tfidfmodel import TfidfModel |
| ############################################################################### | |
| # Helpful Docker commands and code snippets | |
| ############################################################################### | |
| ### CONTAINERS ### | |
| docker stop $(docker ps -a -q) #stop ALL containers | |
| docker rm -f $(docker ps -a -q) # remove ALL containers | |
| docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter | |
| # exec into container |
| [ | |
| { | |
| "city": "New York", | |
| "growth_from_2000_to_2013": "4.8%", | |
| "latitude": 40.7127837, | |
| "longitude": -74.0059413, | |
| "population": "8405837", | |
| "rank": "1", | |
| "state": "New York" | |
| }, |
| ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key | |
| # Don't add passphrase | |
| openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub | |
| cat jwtRS256.key | |
| cat jwtRS256.key.pub |
| """Genetic Algorithmn Implementation | |
| """ | |
| #引入随机函数 | |
| import random | |
| #定义基因遗传算法顶层接口 | |
| class GeneticAlgorithm(object): | |
| # 定义算法初始化 | |
| def __init__(self, genetics): |
| #/usr/bin/env python | |
| # coding=utf-8 | |
| import random | |
| import re | |
| def color(messages): | |
| color = '\x1B[%d;%dm' % (1,random.randint(30,37)) | |
| return '%s %s\x1B[0m' % (color,messages) |
| Port: 1080 | |
| 1. Create a file /YOUR PATH/gitproxy.sh with content: | |
| #!/bin/sh | |
| nc -X 5 -x 127.0.0.1:1080 "$@" | |
| 2. Edit your ~/.gitconfig | |
| # For git:// |