Example inputs:
Variable | Value |
---|---|
key | the shared secret key here |
message | the message to hash here |
Reference outputs for example inputs above:
| Type | Hash |
''' | |
1 当指定异常被引发时,使用on_exception装饰器重试。这里有一个例子,当出现任何requests异常时,使用指数退避(backoff.expo即退避时间指数增长): | |
2 当目标函数返回值符合某个特定条件时,on_predicate装饰器会安排重试。当为外部生成内容轮询资源时可能有用。 | |
3 两个backoff装饰器都可以选择使用关键字参数on_success、on_backoff和on_giveup接受事件处理程序函数。这在报告统计或执行其他自定义日志方面可能有用。 | |
''' |
#!/usr/bin/python | |
#coding:utf8 | |
''' | |
Abstract Factory | |
抽象工厂模式也就是不仅生产鼠标,同时生产键盘。 | |
也就是 PC 厂商是个父类,有生产鼠标,生产键盘两个接口。 | |
戴尔工厂,惠普工厂继承它,可以分别生产戴尔鼠标+戴尔键盘,和惠普鼠标+惠普键盘。 | |
创建工厂时,由戴尔工厂创建。 | |
后续工厂.生产鼠标()则生产戴尔鼠标,工厂.生产键盘()则生产戴尔键盘。 | |
''' |
# 求最大公约数 | |
def gcd(pair): | |
a, b = pair | |
low = min(a, b) | |
for i in range(low, 0, -1): | |
if a % i == 0 and b % i == 0: | |
return i | |
numbers = [ | |
(1963309, 2265973), (1879675, 2493670), (2030677, 3814172), |
Example inputs:
Variable | Value |
---|---|
key | the shared secret key here |
message | the message to hash here |
Reference outputs for example inputs above:
| Type | Hash |
class ALG(object): | |
def __init__(self,list): | |
self.list=list | |
#冒泡 | |
def bubble_sort(nums): | |
n =len(nums) | |
for i in range(n - 1): | |
for j in range(n-1 - i): | |
if nums[j+1] < nums[j]: | |
nums[j], nums[j + 1] = nums[j + 1], nums[j] |
import tensorflow as tf | |
import numpy as np | |
################################################################################## | |
# Initialization | |
################################################################################## | |
# Xavier : tf.contrib.layers.xavier_initializer() | |
# He : tf.contrib.layers.variance_scaling_initializer() | |
# Normal : tf.random_normal_initializer(mean=0.0, stddev=0.02) |
const str1 = 'This is an example to test cosine similarity between two strings'; | |
const str2 = 'This example is testing cosine similatiry for given two strings'; | |
// | |
// Preprocess strings and combine words to a unique collection | |
// | |
const str1Words = str1.trim().split(' ').map(omitPunctuations).map(toLowercase); | |
const str2Words = str2.trim().split(' ').map(omitPunctuations).map(toLowercase); | |
const allWordsUnique = Array.from(new Set(str1Words.concat(str2Words))); |
#! /bin/bash | |
in=$1 | |
if [ -z "$in" ] | |
then | |
in=$(cat -) | |
fi | |
if [ -z "$in" ] |
# 邪魔歪道之使用OpenCV精准切割视频 | |
## ffmpeg 切割视频 | |
使用ffmpeg直接切割视频的命令 | |
``` | |
ffmpeg -i test.mp4 -ss 00:00:00 -t 00:00:30 -c:v copy -c:a copy output.mp4 | |
``` | |
或者 | |
``` |
# @Author: xiewenqian <int> | |
# @Date: 2016-11-28T20:35:09+08:00 | |
# @Email: wixb50@gmail.com | |
# @Last modified by: int | |
# @Last modified time: 2016-12-01T19:32:48+08:00 | |
import pandas as pd | |
from pymongo import MongoClient |