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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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`
@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 / 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 / dynamiccastunique.cpp
Created March 22, 2015 17:37
dynamic_cast with unique_ptr
#include <iostream>
#include <memory>
struct A
{
virtual ~A() {}
};
struct B : public 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 / 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 / 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 / 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 / loadhdr.py
Created March 4, 2014 12:48
Load Radiance HDR file (.hdr) with python. Used : smc.freeimage, Pillow, OpenCV
import array
import smc.freeimage as fi
from PIL import Image
import numpy as np
import cv2
def gamma_correction(a, gamma):
return np.power(a, 1/gamma)
def load_hdr(file):