This file contains hidden or 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
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z" |
This file contains hidden or 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
# https://stackoverflow.com/questions/1251999/how-can-i-replace-each-newline-n-with-a-space-using-sed | |
cat test | grep -E $(cat target | sed ':a;N;$!ba;s/\n/|/g') | |
# test | |
# | |
# Hey yoyo | |
# today is a good day | |
# word1 is good | |
# word2 is not good |
This file contains hidden or 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
#!/usr/bin/env bash | |
echo Force delete namespace $1 | |
kubectl get namespace $1 -o json | | |
tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | | |
kubectl replace --raw /api/v1/namespaces/$1/finalize -f - | |
echo Delete namespace $1 finish :) |
This file contains hidden or 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 logging | |
import sys | |
class SecretFilter(logging.Filter): | |
def filter(self, record): | |
if record.msg.find("key") != -1: | |
record.msg = "*** key had been hided ***" | |
return True | |
logger = logging.getLogger("mylogger") |
This file contains hidden or 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 | |
from glob import glob | |
import subprocess as sb | |
def parse_html(filename): | |
print(filename.split("."[0] + ".txt")) | |
with open(os.path.join(".", "txt", filename.split(".")[0] + ".txt")) as f: | |
texts = f.readlines() | |
with open(os.path.join(".", "./html/{}_text.html".format(filename.split(".")[0])), "w") as f: |
This file contains hidden or 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 argparse | |
import os | |
parser = argparse.ArgumentParser() | |
parser.add_argument("html") | |
args = parser.parse_args() | |
This file contains hidden or 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 functools | |
import re | |
accept_language_re = re.compile( | |
r""" | |
([A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*|\*) # "en", "en-au", "x-y-z", "es-419", "*" | |
(?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:\.0{,3})?))? # Optional "q=1.00", "q=0.8" | |
(?:\s*,\s*|$) # Multiple accepts per header. | |
""", | |
re.VERBOSE, |
This file contains hidden or 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 json | |
import re | |
def to_snake(input_str): | |
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', input_str) | |
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | |
def to_camel(input_str): | |
return re.sub(r'_([a-z])', lambda x: x.group(1).upper(), input_str) |
This file contains hidden or 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
setup( | |
name='pip_package_example', | |
version='0.0.1', | |
description="A simple example for writing your own package and setup.py", | |
author="cftang0827", | |
author_email='[email protected]', | |
url='https://github.com/cftang0827/pip_package_example', | |
install_requires=[ | |
"numpy>=1.17.0" | |
], |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder