Skip to content

Instantly share code, notes, and snippets.

View kazmura11's full-sized avatar

Kaz Mu kazmura11

View GitHub Profile
@kazmura11
kazmura11 / dllist.cpp
Last active January 21, 2020 16:04
DoublyLinkedList implementation (C++)
#include <iostream>
#include <string>
#include <stdexcept>
using namespace std;
template <typename T>
struct Node
{
T value_;
@kazmura11
kazmura11 / csv_test.pl
Last active August 29, 2015 14:06
DBD::CSVのテスト
#!/usr/bin/perl
binmode(STDOUT, ":utf8"); # utf-8でCSVファイルを作っているための対策
use DBI;
$dbh = DBI->connect("dbi:CSV:", undef, undef, {
f_ext => ".csv/r",
RaiseError => 1,
}) or die "Cannot connect: $DBI::errstr";
my $sth = $dbh->prepare("select * from english_name");
$sth->execute;
$sth->bind_columns(\my ($eng_name, $eng_nick_name, $sex, $jpn_name));
@kazmura11
kazmura11 / csvutil.c
Last active March 28, 2016 07:40
ダブルクォートで囲まれたCSVの読込みテストプログラム
/**
* reference
* http://f4.aaacafe.ne.jp/~pointc/log1227.html
* ・一行の中のデータは ,(カンマ)で区切る。行の終りは改行。
* ・データがカンマやダブルクォートを含む場合は "(ダブルクォート)で囲む。
* ・データの中のダブルクォートはそれをダブルクォート2個("")で置き換える。
*/
#include <stdio.h>
char *setvalue(char *p, char *field, int size)
@kazmura11
kazmura11 / mondai1.cpp
Last active August 29, 2015 14:06
C++入出力1
#include <iostream>
#include <sstream>
#include <string>
#include <climits>
using namespace std;
template <typename T>
string numToString(const T &num)
{
@kazmura11
kazmura11 / mondai2.cpp
Created September 25, 2014 18:20
C++入出力2
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <climits>
using namespace std;
template <typename T>
@kazmura11
kazmura11 / list.c
Created September 27, 2014 11:31
何に使うんだ?片方向リスト
#include <stdio.h>
#include <stdlib.h>
/* * * * * * * * * * * * *
* 片方向リスト
* * * * * * * * * * * * */
typedef struct _int_list {
int iv;
struct _int_list* next;
} int_list;
@kazmura11
kazmura11 / AppMain.cpp
Last active August 29, 2015 14:06
マージソートサンプル (ひどい実装です)
#include <iostream>
#include <ctime>
#include <cstdio>
#include "MergeSort.h"
static const int DataSize = 100;
static void initRand()
{
srand((unsigned int)time(NULL));
@kazmura11
kazmura11 / monte.py
Created September 27, 2014 11:49
モンテカルロ法 Python
#! /usr/bin/python
# coding: utf-8
from random import *
from math import *
# アークコサイン 定義 => y = cos**(-1)x |x| <=1, |y| <= pi / 2
# よくわかんなけど、
# アークコサインの角度(ラジアン)が-1のときは
# 円周率らしいので、比較用にそれなりの正確な近似値を出しておく
math_pi = acos( -1 )
@kazmura11
kazmura11 / apt-cyg
Created September 27, 2014 12:04
apt-cygの断片
# this script requires some packages
ARCH='x86_64' # default
if [ $(arch) = 'x86_64' ] ; then
ARCH='x86_64'
else
ARCH='x86'
fi
echo "Architecture: $ARCH"
@kazmura11
kazmura11 / crossls.cpp
Last active August 29, 2015 14:06
Windows/Linix兼用のファイルリストを再帰的に取得するモノ
#ifdef _WIN32 /* if defined _WIN32 */
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#else /* if linux */
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <cstdio>
#include <cstdlib>