Skip to content

Instantly share code, notes, and snippets.

import glob
import os.path as osp
import subprocess
def extract_mp3(src_filename, dst_filename):
cmd = ['ffmpeg', '-i', src_filename, '-acodec', 'libmp3lame', '-ab',
'360k', dst_filename]
subprocess.call(cmd)
#include <functional>
#include <iostream>
class Data {
public:
void set(float v_) { v = v_; }
float get() const { return v; }
void print() const { std::cout << v << std::endl; }
private:
@takiyu
takiyu / nested_initializer_list.cpp
Created June 1, 2019 03:37
nested_initializer_list
template <typename T, std::size_t T_levels>
struct NestedInitList {
using type = std::initializer_list<
typename NestedInitList<T, T_levels - 1>::type>;
};
template <typename T>
struct NestedInitList<T, 0> {
using type = T;
};
@takiyu
takiyu / dirt_install.txt
Last active May 22, 2019 13:25
Dirt Install Memo
$ # Install bazel 0.5.4
$ wget https://github.com/bazelbuild/bazel/releases/download/0.5.4/bazel-0.5.4-installer-linux-x86_64.sh
$ chmod +x bazel-0.5.4-installer-linux-x86_64.sh
$ ./bazel-0.5.4-installer-linux-x86_64.sh --user
$ # Install tensorflow 1.4 (CUDA 10.1, cuDNN 7.5.1)
$ git clone https://github.com/tensorflow/tensorflow.git
$ git checkout r1.4
$ ./configure --disable-multilib
WARNING: ignoring _JAVA_OPTIONS in environment.
@takiyu
takiyu / persistent_dataloader.py
Last active May 14, 2019 15:36
Pytorch Persistent Dataloader for Windows (pytorch 1.1.0)
from torch.utils.data.dataloader import DataLoader, _DataLoaderIter
class PersistentDataLoader(DataLoader):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# --------------------------- Different here --------------------------
self._dataloader_iter = _PersistentDataLoaderIter(self)
# ---------------------------------------------------------------------
@takiyu
takiyu / first.cpp
Last active May 13, 2019 14:27
Eigen<->Numpy Binary Conversion
#include <iostream>
#include <eigen3/Eigen/Core>
#include <cstdlib>
int main(int argc, char const* argv[]) {
// Create matrix
Eigen::MatrixXf mat(10, 20);
for (size_t y = 0; y < 10; y++) {
for (size_t x = 0; x < 20; x++) {
mat(y, x) = static_cast<float>(20 * y + x) / 10.f;
@takiyu
takiyu / function_node.cpp
Created April 19, 2018 04:59
Function node which accept any type of variable.
#include <iostream>
#include <vector>
#include <memory>
#include <typeinfo>
#include <cstring>
class Variable {
public:
template<typename T, typename... Args>
@takiyu
takiyu / variable.cpp
Last active April 19, 2018 04:14
Variable class for wrapping any type variables like as a typess language.
#include <iostream>
#include <vector>
#include <memory>
#include <typeinfo>
#include <cstring>
class Variable {
public:
template<typename T, typename... Args>
@takiyu
takiyu / cv_m_creation.cpp
Created May 23, 2017 12:17
Sample of cv::Mat creation from const float*
#include <iostream>
#include <opencv2/core.hpp>
int main(int argc, char const* argv[]) {
static const float d[] = {1, 2, 3};
cv::Mat m(1, 3, CV_32FC1, const_cast<float *>(d));
printf("Address d: %p\n", d);
printf("Address m: %p\n", m.data);
@takiyu
takiyu / README.html
Last active May 26, 2024 08:32
HTML file to visualize README.md
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title></title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script>