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 filecmp | |
import os | |
import pathlib | |
import shutil | |
def no_change(src_file, dest_file): | |
equal = filecmp.cmp(src_file.resolve(), dest_file.resolve(), False) | |
return equal |
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 zipfile | |
def recursive_unzip(zip_file, target_dir): | |
print("export: ", zip_file) | |
if not os.path.exists(target_dir): | |
os.makedirs(target_dir) |
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 random | |
import time | |
from concurrent.futures import ThreadPoolExecutor, wait, FIRST_COMPLETED | |
from memory_profiler import profile | |
random.seed(10) | |
total_iterations = 1000 | |
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 importlib | |
# 自动注册当前文件夹下所有模块 | |
module_dir = os.path.dirname(__file__) | |
for i in os.listdir(module_dir): | |
module_name = os.path.basename(i).split('.')[0] | |
importlib.import_module('.' + module_name, __package__) | |
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
pattern="*.log" #change to your file pattern | |
# need to install jq | |
function filter_function(){ | |
file=$1 | |
cat $file |jq -r 'select(.userid==100) |[.userid, .name, .age, .type] |@csv' | |
} | |
files=$(ls $pattern) | |
for file in $files ; do | |
echo "current_file:$file" |
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
<IfModule mod_rewrite.c> | |
<IfModule mod_negotiation.c> | |
Options -MultiViews | |
</IfModule> | |
RewriteEngine On | |
# Redirect Trailing Slashes... | |
RewriteRule ^(.*)/$ /$1 [L,R=301] |
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 tensorflow as tf | |
def gradient_panalty(real, fake, discriminator, alpha, gp_lambda=10): | |
# alpha = tf.placeholder(shape=[None, 1, 1, 1], dtype=tf.float32) | |
# alpha = tf.random_uniform(shape=[batch_size, 1, 1, 1], minval=0., maxval=1.) | |
interpolated = real + alpha * (fake - real) | |
logit = discriminator(interpolated) | |
grad = tf.gradients(logit, interpolated)[0] # gradient of D(interpolated) | |
grad_norm = tf.norm(tf.layers.flatten(grad), axis=1) # l2 norm | |
gp = gp_lambda * tf.reduce_mean(tf.square(grad_norm - 1.)) | |
return gp |
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 tensorflow as tf | |
def export_submodel(sess, inputs, outputs, output_dir): | |
output_nodes = list(inputs.values()) + list(outputs.values()) | |
output_node_names = [node.name.replace(":0", "") for node in output_nodes] | |
graph = tf.get_default_graph() | |
graph_def = graph.as_graph_def() | |
# sess = tf.get_default_session() | |
output_graph_def = tf.graph_util.convert_variables_to_constants( | |
sess, |
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 queue import Queue | |
from threading import Thread | |
class AsyncQueue: | |
def __init__(self, generator, cache_size=10): | |
self._q = Queue(maxsize=cache_size) | |
self._generator = generator | |
self._input_thread = Thread(target=self.append_to_queue) | |
self._input_thread.setDaemon(True) |
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
enable-rpc=true | |
rpc-allow-origin-all=true | |
rpc-listen-all=true | |
#rpc-secret=xiaocong | |
dir=/home/suo/下载/aria2 | |
#是否启用https加密,启用之后要设置公钥,私钥的文件路径 | |
#rpc-secure=true | |
#启用加密设置公钥 |
NewerOlder