Skip to content

Instantly share code, notes, and snippets.

View kemingy's full-sized avatar
🈚
actions

Keming kemingy

🈚
actions
View GitHub Profile
figure;
hold on;
plot(x1, 'Color', [0.5, 0.5, 0.1], 'Marker', '^', 'LineStyle', 'none', 'LineWidth', 2);
plot(x2, 'Color', [0.5, 0.5, 0.1], 'Marker', '^', 'LineStyle', 'none', 'LineWidth', 2);
plot(x3, 'Color', [0.5, 0.5, 0.1], 'Marker', '^', 'LineStyle', 'none', 'LineWidth', 2);
plot(x4, 'Color', [0.5, 0.5, 0.1], 'Marker', '^', 'LineStyle', 'none', 'LineWidth', 2);
legend('#1', '#2', '#3', '#4');
for i = 1 : 5
line([0, 60], [label(i), label(i)], 'LineStyle', '-.');
end
long long quick_pow(int e, int n)
{
long long ans = 1, tmp = e;
if(!e)
{
return 0;
}
while(n > 0)
{
if (n & 1 == 1)
int maxArea(int* height, int heightSize) {
int start = 0, end = heightSize - 1;
int result = 0, area = 0;
while (start < end) {
area = (end - start) * (height[start] < height[end] ? height[start] : height[end]);
result = (result > area ? result : area);
if (height[start] < height[end]) {
start ++;
} else {
end--;
def fib(n):
"""
n start from 0. (f0, f1, f2 ...)
"""
f1, f2 = 1, 1
for i in xrange(1, n):
f1, f2 = f2, f1 + f2
return f2
def gcd(x, y):
if x < y:
x, y = y, x
two = 0
while y > 0:
if x & 1 == 0 and y & 1 == 0:
two += 1
x = x >> 1
y = y >> 1
#!/usr/bin/env python
# coding=utf-8
import random
import sys
def get_quiz(num=10, inf=0, sup=20):
quiz = []
while len(quiz) < num:
r = random.random()
@kemingy
kemingy / shift_str.c
Created January 1, 2017 14:19
shift strings(use 3 reverse)
void reverse(char* s, int start, int end)
{
char t;
while(start < end)
{
t = s[start];
s[start++] = s[end];
s[end--] = t;
}
// printf("%s\n", s);
@kemingy
kemingy / log.py
Last active July 7, 2017 06:27
python logging config
import logging
import logging.config
config = {
'version': 1,
'formatters': {
'simple': {
'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
},
},
import logging
import os
import sys
import multiprocessing
import jieba
import re
import pickle
from gensim.models import Word2Vec
from gensim.models.word2vec import LineSentence
import signal
from time import sleep
from random import randint
def handler(signum, frame):
print('signal:', signum)
raise Exception('handler over')
def retry(retry_times=3, interval=5):
def decorator(func):