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
#include <iostream> | |
#include <string> | |
using namespace std; | |
enum gender : bool { | |
male = true, | |
female = false | |
}; |
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
Portrait rights license agreement | |
Party A: (model or subject) | |
Party B: (Shanghai Jingshi Culture Communication Co., Ltd.) | |
Both parties have reached an agreement on the use of images with portraits of Party A as follows: | |
1. Party A agrees to take portrait photos by Party B (Shanghai Jingshi Culture Communication Co., Ltd.) and agrees that the photographs taken can be used in the Hopecolor brand's Tmall e-commerce webpage/apps as well as Hopecolor's other promotions. Party B's promotion and packaging including but not limited to brochures, leaflets, posters, and new media legal commercial use such as Douyin (Tiktok), Weibo, etc. This authorization to use is limtid to a one-year period. During the above said period, Party A shall not shoot portraits with other similar brands like Hopecolor . | |
2. After entering into this agreement, Party A shall not submit any other claims or litigations to Party B and the other third-party brand agents of Hopecolor, with regard to matters on portrait rights, privacy right |
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
from Crypto.PublicKey import RSA | |
from Crypto import Random | |
from Crypto.Signature import PKCS1_v1_5 | |
random_generator = Random.new().read | |
key = RSA.generate(1024, random_generator) # private key | |
public_key = key.publickey() | |
enc_data = public_key.encrypt('abcdefgh', 32) | |
key.decrypt(enc_data) # 'abcdefgh' |
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 heapq | |
class MyHeap(object): | |
def __init__(self, initial=None, key=lambda x:x): | |
self.key = key | |
if initial: | |
self._data = [(key(item), item) for item in initial] | |
heapq.heapify(self._data) | |
else: | |
self._data = [] |
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
# you can write to stdout for debugging purposes, e.g. | |
# print("this is a debug message") | |
def checkPass(lst, length, d): | |
maxD = 0 | |
lst = sorted(lst, key=lambda x: x[0]) | |
print(lst) | |
for i in xrange(1, len(lst)): | |
if abs(lst[i][0] - lst[i-1][0]) > maxD: | |
maxD = abs(lst[i][0] - lst[i-1][0]) |
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
static int cf_tolua(lua_State *L) { | |
lua_pushliteral(L, "hello"); | |
return 1; | |
} | |
static int cf_fromlua(lua_State *L) { | |
const char *str = lua_tostring(L, 1); // first argument passed in; second would be at index 2 | |
printf("%s\n", str); | |
return 0; | |
} |
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
# gcc -Wall -o match match.c && ./match | |
# | |
#include <stdio.h> | |
#include <string.h> | |
#include <regex.h> | |
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
func makeConnectionType(str: String) throws -> ConnectionType { | |
switch str { | |
case "clear": | |
return .clear | |
case "startTLS": | |
return .startTLS | |
case "tls": | |
return .tls | |
default: | |
throw "unkown connection 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
console.log(1); | |
(_ => console.log(2))(); | |
eval('console.log(3);'); | |
console.log.call(null, 4); | |
console.log.apply(null, [5]); | |
new Function('console.log(6)')(); | |
Reflect.apply(console.log, null, [7]) | |
Reflect.construct(function(){console.log(8)}, []); | |
Function.prototype.apply.call(console.log, null, [9]); | |
Function.prototype.call.call(console.log, null, 10); |
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
# hackerrank playground | |
import pdb | |
import sys | |
# def solve(*args): | |
# result = [0, 0] | |
# a_ = [args[i] for i in range(int(len(args)/2))] | |
# b_ = [args[i] for i in range(int(len(args)/2), len(args))] | |
# pairs = zip(a_, b_) |