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
| class KMP: | |
| def partial(self, pattern): | |
| """ Calculate partial match table: String -> [Int]""" | |
| ret = [0] | |
| for i in range(1, len(pattern)): | |
| j = ret[i - 1] | |
| while j > 0 and pattern[j] != pattern[i]: | |
| j = ret[j - 1] | |
| ret.append(j + 1 if pattern[j] == pattern[i] else j) |
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
| const kmp_partial = (pattern = "") => { | |
| const ret = [0] | |
| for (let i = 1; i < pattern.length; i++) { | |
| var j = ret[i - 1]; | |
| while (j > 0 && pattern[j] != pattern[i]) { | |
| j = ret[j - 1] |
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
| def trimSuffix(String original, String suffix) { | |
| if(original.endsWith(suffix)) { | |
| return original.substring(0, original.length() - suffix.length()) | |
| } | |
| return original | |
| } | |
| println(trimSuffix("www.qq.com",".com")) // www.qq | |
| println(trimSuffix("www.qq.com","")) // www.qq.com | |
| println(trimSuffix("www.qq.com","abc")) // www.qq.com |
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
| package corp.sap.hana.datav.controllers.api.v1 | |
| import org.springframework.beans.factory.annotation.Autowired | |
| import org.springframework.web.bind.annotation.GetMapping | |
| import org.springframework.web.bind.annotation.PathVariable | |
| import org.springframework.web.bind.annotation.RequestMapping | |
| import org.springframework.web.bind.annotation.RestController | |
| import corp.sap.hana.datav.repository.rate.ExchangeRateHistoryRepo |
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
| { | |
| "$schema": "http://json-schema.org/draft-06/schema#", | |
| "$ref": "#/definitions/NodeTrainingConfiguration", | |
| "definitions": { | |
| "NodeTrainingConfiguration": { | |
| "type": "object", | |
| "additionalProperties": false, | |
| "properties": { | |
| "author": { | |
| "type": "string" |
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
| SELECT * FROM sys.schemas; -- select schemas | |
| SELECT * FROM sys.tables; -- select tables | |
| SELECT * FROM sys.table_columns; -- select columns of table | |
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
| // run with jjs | |
| print("crypt provider: " + javax.crypto.Cipher.getInstance("AES").getProvider()); | |
| var methods = ["AES","DES","RSA"]; | |
| for (var idx in methods) { | |
| var method = methods[idx] | |
| print(method + " key max length: " + javax.crypto.Cipher.getMaxAllowedKeyLength(method)) | |
| } |
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
| // please run with jjs | |
| var Cipher = javax.crypto.Cipher; | |
| var KeyGenerator = javax.crypto.KeyGenerator; | |
| var String = java.lang.String; | |
| var Arrays = java.util.Arrays; | |
| var SecureRandom = java.security.SecureRandom; | |
| var SecretKeySpec = javax.crypto.spec.SecretKeySpec; | |
| var share_secret_seed = "share_secret_seed"; |
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
| const fetch = require("node-fetch") | |
| const { flatten, range } = require("lodash") | |
| const { URLSearchParams } = require("url") | |
| const weibo_search = async (text, page = 1) => { | |
| const query = new URLSearchParams(); | |
| query.append("containerid", `100103type=61&q=${text}&t=0`) | |
| query.append("page_type", "searchall") | |
| query.append("page", `${page}`) |
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
| MessageLog ml = messageLogFactory.getMessageLog(m) | |
| ml.addAttachmentAsString( | |
| "aiib_acc_content.csv", | |
| content, | |
| "plain/text" | |
| ); |