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
// Myoga S. Tomonaka 様の「14セグメントのドットマトリックスで日付を表示するカレンダー」 | |
// ( https://gist.github.com/Myoga1012/8e56f44ecd710555a06c ) | |
// を、DirectWriteに移植してみました。 | |
// Kenny Kerr 様の | |
// 「DirectX プログラミング用の最新 C++ ライブラリ」 | |
// ( http://msdn.microsoft.com/ja-jp/magazine/dn201741.aspx ) | |
// を使用させて頂いています。また、このライブラリのサンプルコード | |
// ( http://dx.codeplex.com/SourceControl/latest ) | |
// を参考にさせて頂いています。 | |
// 例によってC++11とBoostも使用しています。 |
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
#include <complex> | |
#include <iostream> | |
#include <locale> | |
#include <string> | |
int main() | |
{ | |
std::wstring const haiku = { L"島々に 灯をともしけり春の海 正岡子規" }; | |
std::complex<int> c(3, 0), cp(c); | |
std::complex<int> const r(-1, 0), i(0, 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
require 'csv' | |
require 'json' | |
require 'net/http' | |
require 'uri' | |
def jsontocsv(instance_name) | |
target_url = 'https://instances.mastodon.xyz/api/instances/history.json?instance=' + | |
instance_name + '&start=0&end=' + Date.today.to_time.to_i.to_s | |
parsed = JSON.parse(Net::HTTP.get(URI.parse(target_url))) |
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
#include <iostream> // for std::cout, std::endl | |
#include <iterator> // for std::distance | |
#include <boost/range/algorithm/max_element.hpp> // for boost::max_element | |
int main() | |
{ | |
auto const height = { 165.5, 155.0, 170.0, 168.0, 50.0, 200.0, 250.0, 2.0, 20.0 }; | |
auto const itr = boost::max_element(height); | |
std::cout << "身長の最大値は" << *itr << "cmで、生徒の番号は" << std::distance(height.begin(), itr) + 1 << "です。" << std::endl; |
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
# 二つの任意の曲線(関数)の、共通接線を求めるJuliaプログラム | |
# それほど精度が良くないので、使用する際は注意してください | |
# ライセンスは2-Clause BSDライセンス | |
using ForwardDiff | |
using Printf | |
using Roots | |
# 内側のfind_xerosで、根を探したときに見つからなかった時に適当に返す値 | |
const FIND_G_ROOT_TMP = 1000.0 | |
# 共通接線の探索範囲 |
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
#include <fstream> // for std::ofstream | |
#include <iomanip> // for std::setprecision | |
#include <ios> // for std::scientific | |
#include <utility> // for std::make_pair, std::pair | |
#include <vector> // for std::vector | |
namespace { | |
std::pair<double, double> Runge_Kutta_4th(double x, double v, double dt, double mass, double k); | |
double force(double x, double mass, double k); | |
} |
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
use std::fs::File; | |
use std::io::Write; | |
fn main() { | |
let mass = 1.0; | |
let k = 1.0; | |
let dt = 1e-2; | |
let nt = 100000000; | |
let mut xt = vec![0.0; nt + 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
#include <chrono> // for std::chrono | |
#include <fstream> // for std::ofstream | |
#include <iomanip> // for std::setprecision | |
#include <ios> // for std::ios::fixed, std::ios::floatfield, std::scientific | |
#include <iostream> // for std::cout | |
#include <utility> // for std::make_pair, std::pair | |
#include <vector> // for std::vector | |
namespace { | |
std::pair<double, double> Runge_Kutta_4th(double x, double v, double dt, double mass, double k); |
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
#include <chrono> // for std::chrono | |
#include <fstream> // for std::ofstream | |
#include <iomanip> // for std::setprecision | |
#include <ios> // for std::ios::fixed, std::ios::floatfield, std::scientific | |
#include <iostream> // for std::cout | |
#include <utility> // for std::make_pair, std::pair | |
#include <vector> // for std::vector | |
namespace { | |
std::pair<double, double> Runge_Kutta_4th(double x, double v, double dt, double mass, double k); |
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
program main | |
implicit none | |
real(8) :: x, v | |
real(8),allocatable :: xt(:), vt(:) | |
real(8) :: mass, k, dt | |
integer :: i, it, nt, clock_rate | |
integer, dimension(5) :: cp | |
real(8) :: elapsed_time | |
mass = 1d0 |
OlderNewer