Skip to content

Instantly share code, notes, and snippets.

View Santarh's full-sized avatar

Masataka SUMI Santarh

  • Tokyo, Japan
View GitHub Profile
@Santarh
Santarh / AOBench.kn
Created August 26, 2012 18:23
AOBench Kuin 書きかけ
func Init(cfg : Kuin@CCfg)
do cfg.Title :: "AOBench"
do cfg.FullScr :: false
do cfg.PadNum :: 1
do cfg.WaitTime :: 60
end func
func Main()
var ao : AOBench@AOBench
do ao :: @new AOBench@AOBench
@Santarh
Santarh / hex2bin.rb
Created August 19, 2012 05:04
ruby hex2bin
#
# input txt style
# 00 00 14 66 2a ...
#
input = open("input.hex")
output = open("output.bin", "w")
while line = input.gets
a = line.split.collect{|c| c.hex}
output.write a.pack("C*")
@Santarh
Santarh / main.coffee
Created July 29, 2012 08:13
CoffeeScript : class variable & instance variable
class C
@count = 0; # class variable
constructor: (num) ->
C.count += 1;
@hoge = num; # instance variable
console.log( C.count ); # => 0
s = new C(72);
console.log( C.count ); # => 1
t = new C(64);
#include <iostream>
#include <boost/regex.hpp>
int main()
{
std::string file_path = "/foo/bar/bunny.obj";
std::string type = "unknown";
boost::regex rx_find_extension("([^\\.]+)$");
boost::smatch result;
if ( boost::regex_match( file_path, result, rx_find_extension ) )
@Santarh
Santarh / gist:2894415
Created June 8, 2012 08:11
boost::filesystem::path
#include <iostream>
#include <boost/algorithm/string.hpp>
// Boost1.49.0
#include <boost/filesystem.hpp>
int main()
{
boost::filesystem::path p( "/hoge/fuga.foo" );
std::cout << p.filename() << std::endl; // EXC_BAD_ACCESS
}
@Santarh
Santarh / gl.jsx
Created June 7, 2012 18:06
JSX-WebGL
import "js/web.jsx";
import "js.jsx";
class _Main
{
static function getRequestAnimationFrame() : function( tick : function(:number) : void ) : void
{
if ( js.global["requestAnimationFrame"] != undefined )
{
return function( tick : function(:number) : void ) : void
import "js/web.jsx";
import "timer.jsx";
class _Main
{
static function main() : void
{
var renderer = new WebGLRenderer( dom.window.document.getElementById("webgl-canvas") as HTMLCanvasElement );
Timer.setInterval( function():void{ renderer.render(); }, 30 );
}
#include <iostream>
#include <functional>
#include <tuple>
std::tuple<unsigned long, unsigned long> fib2( unsigned long n )
{
if ( n == 0 )
{
return std::tuple<unsigned long, unsigned long>( 0, 1 );
}
@Santarh
Santarh / main.c
Created May 24, 2012 06:29
std::unique_ptr Singleton http://ideone.com/Rngaf
#include <iostream>
#include <memory>
class Hoge
{
public:
static Hoge& GetInstance();
void Hey()
{
@Santarh
Santarh / fragment.c
Created April 18, 2012 06:12
raymarching
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
vec3 y_up = vec3( 0.0, 1.0, 0.0 );
vec3 eye_pos = vec3( 0.0, 0.0, -3.0 );