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
| #define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */ | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <limits.h> | |
| #include <string.h> | |
| struct entry_s { | |
| char *key; | |
| char *value; |
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 math import log10, factorial | |
| # O(nlog(n)) implementation | |
| def count7(n, acc=0): | |
| if n <= 0: | |
| return acc | |
| while n > 0: | |
| v = n | |
| while v > 0: | |
| v, r = v // 10, v % 10 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| #!/usr/bin/env python3 | |
| # -*- coding:utf8 -*- | |
| from __future__ import print_function | |
| from copy import deepcopy | |
| class MyAwesomObject(object): | |
| def __init__(self, private_value): | |
| self.__private_value = private_value | |
| @property |
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
| #!/usr/bin/env python3 | |
| # -*- coding:utf8 -*- | |
| import pandas as pd | |
| data = {"split": ["台灣 世界競爭力", "台灣股票開盤", "台電躺著賺"], | |
| "label": ["positive", "negative", "positive"]} | |
| df = pd.DataFrame(data) | |
| count = 0 | |
| for i, row in df.itertuples() | |
| if "台灣" in row.split and row.label == "positive": |
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
| #!/usr/bin/env python3 | |
| # -*- coding: utf8 -*- | |
| from __future__ import print_function | |
| import re | |
| import subprocess as sp | |
| import argparse | |
| import sys | |
| import os | |
| import yaml |
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
| #!/usr/bin/env python3 | |
| #-*- coding:utf8 -*- | |
| from __future__ import print_function | |
| import numpy as np | |
| import multiprocessing as mp | |
| import sys | |
| from multiprocessing.queues import Empty | |
| SHARE_DATA = None |
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
| #!/usr/bin/env python | |
| from __future__ import print_function | |
| import argparse | |
| import numpy as np | |
| import time | |
| # a random sequence | |
| arr = np.random.choice(['a', 'b', 'c', 'd'], 5000, replace=True) | |
| positive_values = ['a', 'b'] |
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
| #!/usr/bin/env python3 | |
| # -*- coding:utf8 -*- | |
| def main(): | |
| a = 5 | |
| def foo(): | |
| nonlocal a; | |
| a += 1 | |
| print(a) | |
| print(foo()) |
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
| # -*- coding:utf-8 -*- | |
| from __future__ import print_function | |
| from functools import wraps | |
| def log_deco(func): | |
| @wraps(func) | |
| def wrapped(*args, **kwargs): | |
| print("calling {}".format(func.__name__)) | |
| return func(*args, **kwargs) |