minikube stop; minikube delete
docker stop $(docker ps -aq)
rm -r ~/.kube ~/.minikube
sudo rm /usr/local/bin/localkube /usr/local/bin/minikube
systemctl stop '*kubelet*.mount'
sudo rm -rf /etc/kubernetes/
docker system prune -af --volumes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int call(int rnum){ | |
// rnum is parameter | |
printf("the num is %d", rnum); | |
} | |
int num = 20; | |
call(num); | |
// num is argument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def infinite_sequence(): | |
"""Makes the infinite sequence with Python generator. | |
""" | |
num = 0 | |
while True: | |
yield num | |
num += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_return_type(func): | |
# Define wrapper(), the decorated function | |
def wrapper(*args, **kwargs): | |
# Call the function being decorated | |
result = func(*args, **kwargs) | |
print('{}() returned type {}'.format( | |
func.__name__, type(result) | |
)) | |
return result | |
# Return the decorated function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def counter(func): | |
def wrapper(*args, **kwargs): | |
wrapper.count += 1 | |
# Call the function being decorated and return the result | |
return func(*args, **kwargs) | |
wrapper.count = 0 | |
# Return the new decorated function | |
return wrapper | |
# Decorate foo() with the counter() decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Docstring - Google style | |
def function(arg_1, arg_2=42, some_function): | |
"""Descriptioin of what this function does. | |
Args: | |
arg_1 (str): Description of arg_1. | |
(The string to search). | |
arg_2 (int, optional): Write optional when | |
argument has default value. | |
some_function (callable): The function we want a tooltip for. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from functools import wraps | |
def timer(func): | |
"""A decorator that prints how long a function took to run.""" | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
# When wrapper() is called, get the current time. | |
t_start = time.time() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
def memorize(func): | |
"""Store the results of the decorated function for fast lookup """ | |
# Store results in a dict that maps arguments to results | |
cache = {} | |
@wraps(func) | |
def wrapper(*args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Project: HTML Generator | |
With the new html() decorator you can focus on | |
writing simple functions that return the | |
information you want to display on the webpage | |
and let the decorator take care of wrapping them | |
in the appropriate HTML tag. | |
""" | |
def html(open_tag, close_tag): | |
def decorator(func): | |
@wraps(func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
print(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
OlderNewer