LRU是在一個有限大小的快取空間,保持最近使用過的資料的一種快取機制,可以透過getter、setter方法搭配一個有序字典物件來實現
import collections
class LRUCache(object):
""" Simple LRU Cache
sudo curl -sSL https://get.docker.com/ | sh | |
sudo usermod -aG docker $(whoami) | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.16.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
sudo apt-get install -y bash-completion |
import os | |
from base64 import b64encode | |
random_bytes = os.urandom(24) | |
print(b64encode(random_bytes).decode('utf-8')) |
sudo lsof -i -n -P | grep LISTEN |
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.
To use the script, follow the instructions given in the script's docstring.
For further details, read this blogpost.
The procedure outlined here is inspired by this answer on Stack Overflow.
<!DOCTYPE html> | |
<html> | |
<body> | |
<div id="container"></div> | |
<script> | |
var node1 = document.createElement("p"); | |
var txt1 = document.createTextNode("This is 1 "); | |
node1.appendChild(txt1); |
find $(pwd) -name "*.sql" -type f -mtime +30 -exec rm -f {} \; |
#!/usr/bin/env python | |
import SimpleHTTPServer | |
import BaseHTTPServer | |
import sys | |
""" | |
Usage: | |
python httpd.py [port] [additional headers ...] |