Skip to content

Instantly share code, notes, and snippets.

@LotusChing
LotusChing / code.md
Created December 25, 2019 07:37 — forked from gopalindians/code.md
Jetbrains IntelliJ IDEA 2019.2.4 Activation code

Please make fork of this, as this can be removed by Github.com sooner or later.

CATF44LT7C-eyJsaWNlbnNlSWQiOiJDQVRGNDRMVDdDIiwibGljZW5zZWVOYW1lIjoiVmxhZGlzbGF2IEtvdmFsZW5rbyIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJGb3IgZWR1Y2F0aW9uYWwgdXNlIG9ubHkiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiQUMiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJEUE4iLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJQUyIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IkdPIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiRE0iLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJDTCIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJTMCIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiUkQiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJQQyIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJNIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiV1MiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJEQiIsI

@LotusChing
LotusChing / default.conf
Created March 5, 2019 12:50 — forked from flox1an/default.conf
nginx config that uses the oauth2-proxy (via auth_request) to authenticate against gitlab and then proxies all requests to a backend service while setting the auth headers X-User and X-Email
server {
listen 80;
server_name localhost;
location /oauth2/ {
proxy_pass http://oauth-proxy:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
@LotusChing
LotusChing / receive_curl_upload_file.py
Created November 23, 2016 06:48
receive curl upload file to flask
# coding:utf-8
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/upload', methods=['PUT'])
def upload():
# coding:utf-8
def singleton(cls):
instances = {}
def wrapper(*args, **kwargs):
if cls not in instances:
instances[cls] = cls(*args, **kwargs)
return instances[cls]
return wrapper
@LotusChing
LotusChing / case.py
Created November 2, 2016 07:15
Case in Python
matrix = {
'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'*': lambda x, y: x * y,
'/': lambda x, y: x / y
}
def compute(x, oper, y):
return matrix[oper](x, y)
@LotusChing
LotusChing / words_finder.py
Created August 2, 2016 00:12
words search match
collection = ['django_migrations.py',
'django_admin_log.py',
'main_generator.py',
'migrations.py',
'api_user.doc',
'accounts.txt'
]
import re
def LotusFinder(user_input, collection):
@LotusChing
LotusChing / roman_to_int.py
Created July 30, 2016 02:43
roman number to integer
def roman_to_int(src):
convert_map = {
'I' : 1,
'V' : 5,
'X' : 10,
'L' : 50,
'C' : 100,
'D' : 500,
'M' : 1000
}
@LotusChing
LotusChing / integer_to_roman.py
Last active July 29, 2016 06:32
change integer number to roman numeral
dict = {
'1' : 'I',
'5' : 'V',
'10' : 'X',
'50' : 'L',
'100' : 'C',
'500' : 'D',
'1000' : 'M',
}
def g(n):
@LotusChing
LotusChing / str_to_int.py
Last active July 14, 2016 02:53
Convert String to int , Such as '123' -> 123
def do(in_str):
out_num = 0
multiplier = 1
for x in range(0, len(in_str)):
out_num = out_num * 10 + ord(in_str[x]) - ord('0')
return out_num * multiplier
def str_to_int(in_str):
if '.' in in_str:
big_num, small_num = in_str.split('.')
@LotusChing
LotusChing / list_merge_keep_ordert.py
Created July 13, 2016 03:12
merge list and keep order
l1 = [2, 4, 6, 8, 9, 10]
l2 = [0, 1, 2, 6, 7, 9, 100, 134]
'''
思路
1. 因为是两个list都是有序列表,所以对比两个列表末尾的元素取出最大值
2. 根据最大值创建一个最大值+1的dict叫做bucket(桶)
3. 合并两个list然后进行循环,根据列表中的元素找到bucket中的key,然后对value+1
4. 最后遍历bucket,取出value不等于0的,然后根据key对应的value循环输出key
'''