Skip to content

Instantly share code, notes, and snippets.

View mnrn's full-sized avatar
🏠
Working from home

mnrn

🏠
Working from home
View GitHub Profile
@mnrn
mnrn / bridge.rs
Created May 3, 2021 17:07
RustにおけるBuilderパターン
use std::marker::PhantomData;
use std::default::Default;
use serde::Serialize;
use crate::hue::light::Light;
use crate::hue::light::LightState;
/// Structure for Hue Bridge.
pub struct Bridge {
/// IP Address of the bridge on your network.
ip_address: String,
@mnrn
mnrn / 人月の神話.md
Last active April 4, 2021 04:29
人月の神話

人月

人月は見積もりとスケジューリングに使われる仕事の単位であり、そのコストは実際に人数と月数の積に比例するというものですが、 仕事の大きさを測る単位としての人月は疑うべき神話であります。人月は、人と月が互いに交換できるという意味を持っているからです。

人と月が交換可能になるのは、多くの作業者の間でコミュニケーションを取らなくても、仕事が分担可能である場合のみです。
仕事が分担可能でない場合、人を増やすという対策はスケジュールにおいては何の効果も生みません。
女性がたくさん動員されたところで、子供一人が生まれてくるまでに十月十日かかることと同じです。

また、分担は可能であるがサブタスク間でのコミュニケーションが必要な仕事においては、

@mnrn
mnrn / cpp-network-library.md
Last active April 3, 2022 08:12
boost.asio と libuv の比較

boost.asio と libuv の比較

実装がネットワークを高速化する際のボトルネックになっていることが多々ある。(コンピュータネットワーク- p.568)
このことからネットワークを構築する際には信頼できる OSS を使うのが良いと考えられます。

以下では、有名なネットワークライブラリである boost.asio と libuv について個人的な感想を述べて比較します。

  • asio
    • 良い点
  • c++ のライブラリである。
/**
* @brief RSA鍵暗号のサンプルコード
* @date 2016/07/03
* @ref techtipshoge.blogspot.com/2014/04/javarsa.html
*/
//********************************************************************************
// パッケージ宣言
//********************************************************************************
import unittest
def cycle_finding(n):
m, p = 1, 1 # m.. カメの計算のあまり p.. ウサギの計算の余り
s, t = 0, 0 # s.. 循環節の先頭小数桁位置 t.. 循環節の末尾小数桁位置
while True:
m = (m * 10) % n
p = (p * 10) % n
@mnrn
mnrn / checksum.cc
Last active February 10, 2020 14:08
checksum
#include <sys/types.h> // for network
static constexpr u_int16_t checksum(const u_int16_t* data, const size_t n)
{
u_int32_t sum = 0;
// The inner loop.
for (size_t i = n; i > 1; i -= 2, data++) {
sum += *data;
}
// Add left-over byte, if any.
@mnrn
mnrn / cycle_finding.cpp
Last active August 4, 2019 14:08
Floyd's Cycle Finding Algorithm
#include <optional>
// Let Catch provide main():
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
constexpr auto cycle_finding(std::uint64_t n) -> std::optional<std::uint64_t> {
// m.. カメの計算のあまり p.. ウサギの計算の余り
std::uint64_t m = 1, p = 1;
@mnrn
mnrn / dgemm.cu
Last active February 15, 2019 16:17
#include <iostream>
#include <chrono>
#include <cuda_runtime.h>
// N x Nの行列を扱う
constexpr std::size_t N = 1024;
// 1つのブロックでBLOCK_SIZE x BLOCK_SIZEのスレッドを管理する
constexpr std::size_t BLOCK_SIZE = 16;
@mnrn
mnrn / convex_hull.py
Last active September 15, 2020 03:08
Pythonでの凸包計算
import numpy as np
from scipy.spatial import ConvexHull
import matplotlib.pyplot as plt
if __name__ == '__main__':
points = np.loadtxt('points.csv', delimiter=' ')
plt.scatter(points[:, 0], points[:, 1])
hull = ConvexHull(points)
@mnrn
mnrn / strassen.py
Last active February 15, 2019 16:46
Strassen's algorithm implementation.
##
# @brief 行列積のためのStrassenのアルゴリズムを扱います
#
# @date 2016/04/30
#
import numpy as np # 数値計算のためのライブラリ
##