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
# -*- coding: utf-8 -*- | |
def quick_sort(arr): | |
lower_than_or_equal_head = [elem for elem in arr if elem < arr[0]] | |
greater_than_head = [elem for elem in arr if elem > arr[0]] | |
if len(arr) < 2: return arr | |
return quick_sort(lower_than_or_equal_head) + [arr[0]] + quick_sort(greater_than_head) | |
print(quick_sort([1, 3, 4, 2, 1000, 10, 4])) |
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 compute_clf(confusion_matrix: numpy.ndarray, classes: list): | |
""" | |
return TP, TN, FP, FN followed by the order of classes | |
shape: (n_classes, 4) | |
""" | |
ret = list() | |
total = confusion_matrix.sum() | |
for index, _class in enumerate(classes): |
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 threading | |
import socket | |
import time | |
ADDR = '127.0.0.1' | |
PORT = 8890 | |
class Server: | |
def __init__(self): |
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
//#define _GRIBCXX_DEBUG | |
#include <bits/stdc++.h> | |
# define rep(i, n) for (int i = 0; i < (int)(n); i++) | |
using namespace std; | |
int v, e, r; | |
vector<long long> s, t, d; | |
vector<long long> dist; | |
const long long INF = 1LL<<50; |
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
//#define _GRIBCXX_DEBUG | |
#include <bits/stdc++.h> | |
# define rep(i, n) for (int i = 0; i < (int)(n); i++) | |
using namespace std; | |
using ll = long long; | |
using P = pair<ll, int>; | |
struct edge{ | |
edge(int to, ll cost) : to(to), cost(cost) {}; |
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 collections | |
import tqdm | |
import math | |
class HMM: | |
def __init__(self): | |
pass |
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
#! /bin/zsh | |
acat () { | |
fsize=`du -k $1| awk '{print $1}'` | |
if [ $(($fsize)) -gt 100 ]; then | |
echo 'this file is too large' | |
else | |
cat $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
import argparse | |
import subprocess | |
import pathlib | |
BASE_COMMAND = 'ffmpeg -fflags +genpts -i {input}' | |
BASE_COMMAND += ' -c:a copy -c:v copy -threads 8 -sn -y {output}' | |
def load_arguments(): |
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
In [39]: a = chainer.initializers.GlorotUniform(rng=numpy.random.seed(1)) | |
In [40]: a2 = copy.deepcopy(a) | |
In [41]: a(b) | |
In [42]: b | |
Out[42]: | |
array([[-0.09089784, 0.24135339, -0.54759727, -0.21653382, -0.38695953, | |
-0.44657069, -0.34368472, -0.16917975, -0.11308557, 0.0425216 ], |
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
In [33]: a = chainer.initializers.GlorotUniform(rng=numpy.random.seed(1)) | |
In [34]: a(b) | |
In [35]: b | |
Out[35]: | |
array([[-0.09089784, 0.24135339, -0.54759727, -0.21653382, -0.38695953, | |
-0.44657069, -0.34368472, -0.16917975, -0.11308557, 0.0425216 ], | |
[-0.08851797, 0.2028978 , -0.32375634, 0.4142069 , -0.51772095, | |
0.1867378 , -0.09058805, 0.06429149, -0.39393637, -0.33071325], |
OlderNewer