Skip to content

Instantly share code, notes, and snippets.

View hi2p-perim's full-sized avatar
💭
Nothing just works

Hisanari Otsu hi2p-perim

💭
Nothing just works
View GitHub Profile
@hi2p-perim
hi2p-perim / boostpoolperf.cpp
Created August 5, 2014 07:05
Simple performance test of boost::pool
#include <iostream>
#include <boost/pool/object_pool.hpp>
#include <vector>
#include <chrono>
class Pool
{
public:
virtual ~Pool() {}
@hi2p-perim
hi2p-perim / assumetest.cpp
Last active August 29, 2015 14:07
Tricky compilation error with __assume. Checked with VS2013 (/W4 /WX options enabled)
#include <iostream>
struct A
{
int n;
A(int n) : n(n) {}
};
A Func(int n)
{
@hi2p-perim
hi2p-perim / cocoa.cpp
Created January 17, 2015 10:34
Composite numbers that Cocoa-chan should be careful to remember (cf. Gochiusa episode #10)
#include <iostream>
#include <vector>
int main()
{
for (int n = 2; n <= 9719; n++)
{
bool found = false;
int nn = n;
std::vector<int> a;
@hi2p-perim
hi2p-perim / seed.cpp
Created March 12, 2015 12:50
Utilizing 種田梨沙さん as random seed for std::mt19937. Checked with VS2013.
#include <iostream>
#include <random>
#include <functional>
#pragma execution_character_set("utf-8")
int main()
{
std::mt19937 eng(std::hash<std::string>()("種田梨沙"));
std::uniform_int_distribution<int> dist;
@hi2p-perim
hi2p-perim / vectorelementpointer.cpp
Last active August 29, 2015 14:18
A notice on utilizing pointer to vector elements
#include <iostream>
#include <vector>
#include <memory>
struct A { int v; };
struct B { const A* a; };
int main()
{
// NG. Taking raw pointer of an element of the vector.
@hi2p-perim
hi2p-perim / gatest.cpp
Created June 18, 2012 16:46
Solve f(x)=0 by GA
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <ctime>
const int maxGeneration = 1024;
const int populationSize = 1024;
const int gtypeLength = 20;
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <random>
#include <iostream>
#include <intrin.h>
#include <stdint.h>
#include <chrono>
#define M_PI 3.14159265358979323846
@hi2p-perim
hi2p-perim / bugged.cpp
Created January 21, 2014 09:13
A bug. Segmentation fault with g++ 4.7.2, boost 1.54.0
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <chrono>
#include <boost/signals2.hpp>
class A
{
public:
@hi2p-perim
hi2p-perim / exrtopng.sh
Last active April 25, 2016 11:35
Convert multiple .exr files to .png with gamma correction
find . | grep \.exr$ | sed 'p;s/\.exr/\.png/' | xargs -n2 convert -gamma 2.2
@hi2p-perim
hi2p-perim / open_latest.sh
Created June 22, 2016 05:26
Open the latest file from the terminal (checked with msys2)
start `ls -t | head -1`