This file contains 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
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 |
This file contains 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
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) |
This file contains 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
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--; |
This file contains 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 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 |
This file contains 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 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 |
This file contains 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
#!/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() |
This file contains 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
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); |
This file contains 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 logging | |
import logging.config | |
config = { | |
'version': 1, | |
'formatters': { | |
'simple': { | |
'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
}, | |
}, |
This file contains 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 logging | |
import os | |
import sys | |
import multiprocessing | |
import jieba | |
import re | |
import pickle | |
from gensim.models import Word2Vec | |
from gensim.models.word2vec import LineSentence |
This file contains 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 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): |
OlderNewer