Skip to content

Instantly share code, notes, and snippets.

View YukiSakamoto's full-sized avatar

Yuki Sakamoto YukiSakamoto

  • Osaka, Japan
  • 22:22 (UTC +09:00)
View GitHub Profile
@YukiSakamoto
YukiSakamoto / mod_mdoc.sh
Created December 7, 2023 15:34
mdoc modify
mkdir -p mod_mdoc
cd mod_mdoc
for i in {01..20}
do
filename=`printf "tomo_%02d.mrc.mdoc" ${i}`
outfilename=`printf "tomo_%02d.mod.mrc.mdoc" ${i}`
grep -v DateTime ../${filename} > ${outfilename}
# echo ${filename}
done
@YukiSakamoto
YukiSakamoto / Callback.cpp
Last active August 23, 2023 15:20
Callback function via Cython
#include "Callback.hpp"
#include <iostream>
IntHolderCallback::IntHolderCallback(iMethod method, void *user_data)
{
this->_method = method;
this->_user_data = user_data;
}
int
@YukiSakamoto
YukiSakamoto / build_qe.md
Last active November 18, 2022 08:20
How to build QE

Quantum ESPRESSOは、オープンソースの第一原理計算ソフトウェアです。 QEのビルド・テスト・ポテンシャルの作成あたりまでやります。

前提

ここでは、Intel compiler及びIntelMKLを使った並列計算用のビルド方法を書きます。 OpenMPは使っていません。

pw.x のビルド

@YukiSakamoto
YukiSakamoto / order.cpp
Created March 14, 2022 07:39
The order of the arguments evaluation in C++
#include <cstdio>
void func(int a, int b, int c) {
std::printf("%d %d %d\n", a, b, c);
}
int main(void)
{
int i = 0;
func(i++, i++, i++);
@YukiSakamoto
YukiSakamoto / hdf5_simple.cpp
Created August 23, 2013 13:41
simple example to write hdf5 using c++.
#include <string>
#include <iostream>
#include "H5Cpp.h"
#define MAX_NAME_LENGTH 32
const std::string FileName("SimpleCompound.h5");
const std::string DatasetName("PersonalInformation");
const std::string member_age("Age");
const std::string member_sex("Sex");
const std::string member_name("Name");
@YukiSakamoto
YukiSakamoto / random.c
Created September 24, 2012 14:22
Disable ASLR on MacOSX
#include <stdio.h>
/*
This source is testing for address layout randomization.
If ASLR is enabled, output of this program will be variable.
*/
int main(void)
{
printf("%p\n", main);
@YukiSakamoto
YukiSakamoto / .gitignore
Last active February 13, 2021 09:32
sincos_add
*.eps
*.pdf
*.png
*.dat
@YukiSakamoto
YukiSakamoto / makefile
Last active November 23, 2020 08:02
Practice of Matrix product implementation
OPT_FLAG=-O3
all: matrix.x
matrix.x: matrix.cpp
g++ -std=c++11 $(OPT_FLAG) matrix.cpp -o matrix.x
.PHONY: run
run: matrix.x
./matrix.x
@YukiSakamoto
YukiSakamoto / binary_type.cpp
Last active February 19, 2020 12:20
Get binary type on Mac.
#include <mach-o/loader.h>
#include <cstdio>
void print_filetype(const uint32_t filetype)
{
const char *msg;
switch(filetype) {
case MH_OBJECT:
msg = "MH_OBJECT";
break;
@YukiSakamoto
YukiSakamoto / cputype.cpp
Created February 19, 2020 11:59
Get CPU type of Mac
#include <mach-o/arch.h>
#include <iostream>
int main(void)
{
const NXArchInfo *pNXArchInfo = NXGetLocalArchInfo();
std::cout << pNXArchInfo->name << std::endl;
std::cout << pNXArchInfo->description << std::endl;
return 0;
}