Skip to content

Instantly share code, notes, and snippets.

View himkt's full-sized avatar
:octocat:

himkt himkt

:octocat:
View GitHub Profile
# -*- 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]))
@himkt
himkt / compute_clf.py
Last active January 6, 2017 06:22
sensitivityとかspecificityとか,classification_reportが計算してくれないやつを計算するためにTP, TN, FP, FNが必要
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):
import threading
import socket
import time
ADDR = '127.0.0.1'
PORT = 8890
class Server:
def __init__(self):
//#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;
//#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) {};
@himkt
himkt / hmm.py
Created September 23, 2017 08:21
import collections
import tqdm
import math
class HMM:
def __init__(self):
pass
#! /bin/zsh
acat () {
fsize=`du -k $1| awk '{print $1}'`
if [ $(($fsize)) -gt 100 ]; then
echo 'this file is too large'
else
cat $1
@himkt
himkt / vob2mov.py
Created June 9, 2019 01:56
VOB 形式の動画を MOV 形式に変換するスクリプト
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():
@himkt
himkt / a.py
Created December 11, 2019 12:40
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 ],
@himkt
himkt / b.py
Created December 11, 2019 12:40
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],