Skip to content

Instantly share code, notes, and snippets.

View Akira-Hayasaka's full-sized avatar
🏠
Working from home

Akira Hayasaka Akira-Hayasaka

🏠
Working from home
View GitHub Profile
@Akira-Hayasaka
Akira-Hayasaka / gist:1164666
Created August 23, 2011 08:37
openGL light
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glDisable(GL_BLEND);
glPolygonMode(GL_BACK, GL_FILL );
glEnable(GL_CULL_FACE);
@Akira-Hayasaka
Akira-Hayasaka / gist:1252362
Created September 30, 2011 00:49
Get UUID
#include <uuid/uuid.h>
uuid_t uuid;
uuid_generate_random(uuid);
char s[37];
uuid_unparse(uuid, s);
string idstr = s;
cout << idstr << endl;
@Akira-Hayasaka
Akira-Hayasaka / gist:1315108
Created October 26, 2011 01:10
c++ find and replace
template<class T>
void findandreplace(T& source, const T& find, const T& replace) {
size_t j;
for (;(j = source.find( find )) != T::npos;) {
source.replace( j, find.length(), replace );
}
}
@Akira-Hayasaka
Akira-Hayasaka / gist:3045482
Created July 4, 2012 05:13
Jamless ofxOSCReciver
/****************************************
ofxOSCReciver.h
****************************************/
/*
Copyright (c) 2007-2009, Damian Stewart
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@Akira-Hayasaka
Akira-Hayasaka / gist:3689867
Last active October 10, 2015 12:28
c++ converting string to wstring
static int strConv(const string &src, wstring &dst)
{
iconv_t cd = iconv_open("UCS-4-INTERNAL", "UTF-8");
if (cd == (iconv_t)-1)
return -1;
size_t src_length = strlen(src.c_str());
int wlen = (int)src_length/3;
size_t buf_length = src_length + wlen;
@Akira-Hayasaka
Akira-Hayasaka / gist:4949752
Last active June 23, 2022 20:15
c++ copy vector into deque
std::copy(vector.begin(), vector.end(), std::inserter(deque, deque.end()));
@Akira-Hayasaka
Akira-Hayasaka / gist:5602661
Last active September 12, 2017 03:57
Get UUID on Windows
#include <Rpc.h>
#pragma comment(lib, "Rpcrt4.lib")
static string get_uuid()
{
string rtn;
UUID uuid;
UuidCreate(&uuid);
char *str;
UuidToStringA(&uuid, (RPC_CSTR*)&str);
//
// BoxFIR.h
// FilteringTrial
//
// Created by Akira on 5/18/13.
//
//
#ifndef FilteringTrial_BoxFIR_h
#define FilteringTrial_BoxFIR_h
@Akira-Hayasaka
Akira-Hayasaka / gist:7921732
Created December 12, 2013 01:21
get openGL version
static void GetGLVersion(int* major, int* minor)
{
// for all versions
char* ver = (char*)glGetString(GL_VERSION); // ver = "3.2.0"
*major = ver[0] - '0';
if( *major >= 3)
{
// for GL 3.x
glGetIntegerv(GL_MAJOR_VERSION, major); // major = 3
@Akira-Hayasaka
Akira-Hayasaka / gist:8469033
Created January 17, 2014 05:57
zmppublish
void testApp::setup()
{
ofSetWindowPosition(0, 0);
sender_dist.setHighWaterMark(2);
sender_dist.bind(string("tcp://*:") + ofToString(9999));
int fishType = 3;
int deviceID = 5;
testTex.loadImage("imgs/testTex.jpg");