Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

JG tlkahn

🥫
View GitHub Profile
#include <iostream>
#include <string>
using namespace std;
enum gender : bool {
male = true,
female = false
};
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
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'
@tlkahn
tlkahn / test.py
Created October 26, 2017 05:44
min waiting time problem
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 = []
@tlkahn
tlkahn / monkey.py
Created October 24, 2017 15:40
monkey_pass_puzzle.py
# 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])
@tlkahn
tlkahn / main.c
Created October 10, 2017 06:47 — forked from fur-q/main.c
C/Lua interop basic example
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;
}
@tlkahn
tlkahn / match.c
Created September 25, 2017 13:39 — forked from ianmackinnon/match.c
C Regex multiple matches and groups example
# gcc -Wall -o match match.c && ./match
#
#include <stdio.h>
#include <string.h>
#include <regex.h>
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"
@tlkahn
tlkahn / function_invocation.js
Created June 18, 2017 20:44 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
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);
@tlkahn
tlkahn / test.py
Created June 14, 2017 05:56
hackerrank playground
# 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_)