Skip to content

Instantly share code, notes, and snippets.

View komasaru's full-sized avatar

mk-mode komasaru

View GitHub Profile
@komasaru
komasaru / tinyurl_shorten.py
Last active June 28, 2022 02:08
Python script to shorten a url with TinyURL API.
#! /usr/local/bin/python3.6
"""
URL shorten with TinyURL API
"""
import requests
import sys
import traceback
import urllib
@komasaru
komasaru / factorial.f95
Last active June 23, 2022 10:00
Fortran 95 source code to compute the factorial.
!****************************************************
! 階乗計算
!
! date name version
! 2018.08.20 mk-mode.com 1.00 新規作成
!
! Copyright(C) 2018 mk-mode.com All Rights Reserved.
!****************************************************
!
program fact_main
@komasaru
komasaru / ecef2blh.rb
Created February 24, 2019 04:16
Ruby script to convert ECEF to WGS84(BLH) coordinate.
#! /usr/local/bin/ruby
#---------------------------------------------------------------------------------
# ECEF -> BLH 変換
# : ECEF(Earth Centered Earth Fixed; 地球中心・地球固定直交座標系)座標を
# WGS84 の緯度(Latitude)/経度(Longitude)/楕円体高(Height)に変換する。
#
# Date Author Version
# 2019.02.19 mk-mode.com 1.00 新規作成
#
# Copyright(C) 2019 mk-mode.com All Rights Reserved.
@komasaru
komasaru / calc.cpp
Created June 20, 2022 04:49
C++ source code to calculate a simple regression curve(5d).
#include "calc.hpp"
/*
* @brief 単回帰曲線(5次)の計算
*
* @param[ref] a (double)
* @param[ref] b (double)
* @param[ref] c (double)
* @param[ref] d (double)
* @param[ref] e (double)
@komasaru
komasaru / regression_curve_5d.rb
Last active June 20, 2022 04:38
Ruby script to calculate a simple regression curve.(5d)
#! /usr/local/bin/ruby
#*********************************************
# Ruby script to calculate a simple regression curve.
# : y = a + b * x + c * x^2 + d * x^3 + e * x^4 + f * x^5
# : 連立方程式を ガウスの消去法(ピボット選択)で解く方法
#*********************************************
#
class Array
def reg_curve_5d(y)
# 以下の場合は例外スロー
@komasaru
komasaru / calc_napier.py
Last active May 25, 2022 11:56
Python script to compute Napier constant.
#! /usr/local/bin/python3.6
"""
Computation of Napier's constant
"""
import sys
import traceback
class CalcNapier:
L = 1000 # Digits of computation
@komasaru
komasaru / calc.cpp
Last active May 23, 2022 19:53
C++ source code to calculate a Spearman's Rank Correlation Coefficient.
#include "calc.hpp"
#include <algorithm> // for std::count
#include <cmath> // for std::sqrt
#include <iostream>
#include <unordered_map>
#include <vector>
Calc::Calc(std::vector<std::vector<double>>& data) {
try {
@komasaru
komasaru / SubStrUtf8.cpp
Created September 2, 2014 03:42
C++ source code to get substrings of UTF-8.
#include <iostream>
#include <string.h>
using namespace std;
/*
* [CLASS] Proc
*/
class Proc
{
@komasaru
komasaru / ecef2blh.py
Created June 29, 2018 00:25
Python script to convert ECEF to WGS84(BLH) coordinate.
#! /usr/local/bin/python3.6
"""
ECEF -> BLH 変換
: ECEF(Earth Centered Earth Fixed; 地球中心・地球固定直交座標系)座標を
WGS84 の緯度(Latitude)/経度(Longitude)/楕円体高(Height)に変換する。
Date Author Version
2018.06.28 mk-mode.com 1.00 新規作成
Copyright(C) 2018 mk-mode.com All Rights Reserved.
@komasaru
komasaru / ps_check.sh
Created December 1, 2014 07:19
Bash script to check processes.
#!/bin/bash
# ------------------------------------------------------------
# Bash script to check processes.
# ------------------------------------------------------------
# RETURN CODE
# 0: processes are not running.
# 1: one process is running. (CPU time < configured value)
# 2: one process is running. (CPU time >= configured value)
# 3: more than two processes are running.
# ------------------------------------------------------------