Skip to content

Instantly share code, notes, and snippets.

View Shitaro's full-sized avatar

Taro P. Shimizu Shitaro

View GitHub Profile
#include <cstdio> // printf
#include <algorithm> // make_heap, pop_heap, greater
#include <vector> // vector
#include <random> // mt19937_64, uniform_real_distribution
// Initialize each element of a vector using Mersenne Twister
std::vector<int> randomize(const int n) {
std::mt19937_64 mt{1};
std::uniform_int_distribution<int> dist{0, 100};
@Shitaro
Shitaro / main.f90
Last active February 23, 2016 15:33
Modern OpenGL with only Fortran2003
program main
use glew_wrapper
use glfw3_wrapper
implicit none
type(c_ptr) :: window
integer(GLuint) :: programID, vertexPositionModelSpaceID = 114514
character(kind=c_char, len=*), parameter :: vertexPositionModelSpaceName = "vertexPosition_modelspace"//c_null_char
real(GLfloat), target :: g_vertex_buffer_data(9)
real(GLfloat), pointer :: g_vertex_buffer_data_ptr => null()
@Shitaro
Shitaro / main.m
Created November 25, 2015 08:32
線形系に従うロミオとジュリエットの恋の微分方程式
function main
[x, y] = meshgrid(-3:.5:3);
[R, J] = romeo_juliet(x, y);
%graph
quiver(x, y, R, J);
xlabel('R');
ylabel('J');
cxxflags = -Wextra -g -O2 -std=c++11
cxx = clang++
rule compile
command = $cxx $cppflags -c $in -o $out
rule link
command = $cxx $in -o $out
build main.o : compile main.cpp
@Shitaro
Shitaro / compile.sh
Created September 4, 2014 14:30
The Game which I make now.This is still incomplete.
#!/bin/bash
export LD_LIBRARY_PATH=/usr/local/include/SFML/lib
clang++ -o main -std=c++11 -O3 -lsfml-system \
-lsfml-graphics -lsfml-window -lsfml-audio "./main.cpp" && ./main
@Shitaro
Shitaro / lcd.c
Last active August 29, 2015 13:57
Using SC1602 with PIC18F2550.
#include "lcd.h"
void lcdInit(){
LCD_RW=0;
Delay1KTCYx(180); // wait more than 14.94m sec
LCD_RS=0;
// set 8-bit mode
lcdPut8bits(0x03);
Delay10KTCYx(5); // wait more than 4.15m sec
lcdPut8bits(0x03);
@Shitaro
Shitaro / MerrittCoil.cpp
Created March 12, 2014 03:33
Computing the magnetic field which a Merritt 4-coil produces using the Builder design pattern.
#pragma warning(disable : 4996) // If we use VS, we should write this in order to avoid error C4996.
#include <iostream>
#include <valarray>
#include <numeric>
// Merritt coil class
class MerrittCoil
{
public:
#include <iostream>
int main(){
std::cout << "test" << std::endl;
return 0;
}