View ring_aes_example.rs
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
# ring = "0.16.20" | |
use ring::*; | |
use ring::aead::{Aad, AES_128_GCM, BoundKey, Nonce, OpeningKey, SealingKey, UnboundKey}; | |
static ALGORITHM: &aead::Algorithm = &AES_128_GCM; | |
struct OneNonceSequence(Option<aead::Nonce>); | |
impl OneNonceSequence { |
View send to flomo.sh
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
fl () { | |
API="" | |
ret_json=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"content\":\"$*\"}" $API) | |
echo $ret_json | sed "s/.*\"message\":\([^,}]*\).*/\1/" | |
} |
View Hypothesis.user.js
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
// ==UserScript== | |
// @name Hypothesis | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author AFuture | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== |
View Inherit_Path.python
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 pathlib import Path | |
class DataSetPath(type(Path())): | |
def __new__(cls, *args, **kwargs): | |
path = cls | |
return super().__new__(cls, *args, **kwargs) | |
def __mod__(self, other): | |
return self.parent / (str(self.name) % other) | |
View show mask on the image.py
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 random_colors(self, N, bright=True): | |
""" | |
Generate random colors. | |
To get visually distinct colors, generate them in HSV space then | |
convert to RGB. | |
""" | |
brightness = 1.0 if bright else 0.7 | |
hsv = [(i / N, 1, brightness) for i in range(N)] | |
colors = list(map(lambda c: colorsys.hsv_to_rgb(*c), hsv)) | |
random.shuffle(colors) |
View pytorch_model_shape_test.py
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
img = np.random.randint(0,256,(4,3,512,512)) # (4,3,512,512) => batch size, channel, height, width | |
img = torch.from_numpy(img).float().div(255) # convert numpy to tensor and scale to 0-1. | |
cbam_tmp = resnet50_cbam() # create a model. | |
cbam_tmp(img) |
View sort within DFgroupby
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
JPEG_INFO.groupby(['plant','classes']).count() | |
path. id | |
plant classes | |
小麦 小麦_叶锈病 94 94 | |
小麦_壳针孢叶斑病 47. 47 | |
小麦_散黑穗病 492. 492 | |
小麦_条锈病 1837. 1837 | |
小麦_白粉病 1071. 1071 | |
小麦_纹枯病 398. 398 |
View Template.cpp
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
#include <iostream> | |
#include <cstdio> | |
#include <algorithm> | |
#include <vector> | |
#include <queue> | |
#include <cmath> | |
#include <cstring> | |
#include <map> | |
#include <set> | |
#include <stack> |
View chang app to zh-CN.sh
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
setAppL(){ | |
APPPATH=$1 | |
APPID=$(mdls -name kMDItemCFBundleIdentifier $APPPATH | cut -d'"' -f2) | |
defaults write $APPID AppleLanguages '(zh-CN)' | |
} |
View convert.py
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
img = transforms.functional.to_pil_image(img) | |
img = cv2.cvtColor(np.asarray(img),cv2.COLOR_RGB2BGR) |
NewerOlder