Skip to content

Instantly share code, notes, and snippets.

View vaiorabbit's full-sized avatar
🎮
busy playing video games

vaiorabbit

🎮
busy playing video games
View GitHub Profile
/* -*- encoding: utf-8; -*- */
/* nuklear - v1.17 - public domain */
/* Unicode character test based on:
* https://github.com/vurtun/nuklear/blob/master/demo/glfw_opengl3/main.c */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
# coding: utf-8
# $ which gcc-6
# /usr/local/bin/gcc-6
# $ CXX=`which g++-6` CC=`which gcc-6` rvm install ruby-2.3.1
# $ rvm use --default ruby-2.3.1
# $ ruby --version
# ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
# $ gem install nmatrix
@vaiorabbit
vaiorabbit / macOSDict.rb
Created November 5, 2016 13:26
Returns the definition of given word via Dictionary Services of macOS. (Install Ruby-FFI in advance)
# -*- coding: utf-8 -*-
# Usage : $ macOSDict.rb [word_to_look_up]
require 'ffi'
module MacOSDict
extend FFI::Library
# /System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h
class CFRange < FFI::Struct
@vaiorabbit
vaiorabbit / h2f.rb
Created October 22, 2016 07:08
Shows the floating point representation of a hexadecimal string.
# coding: utf-8
# ex.) $ ruby h2f.rb 0000803f -> 1.0
# $ ruby h2f.rb c3f54840 -> 3.140000
# $ ruby h2f.rb 182d4454fb210940 -> 3.141592653589793
# $ ruby h2f.rb 400921fb54442d18 -b -> 3.141592653589793
require 'getoptlong'
$cmd_opts = GetoptLong.new(
[ '-b', GetoptLong::NO_ARGUMENT ],
@vaiorabbit
vaiorabbit / f2h.rb
Created October 22, 2016 07:06
Shows the hexadecimal representation of a given floating point value.
# coding: utf-8
# ex.) $ ruby f2h.rb 1.0 -> 0000803f 00000000000000001000000000111111
require 'getoptlong'
def numeric?(str)
true if Float(str) rescue false
end
$cmd_opts = GetoptLong.new(
[ '-b', GetoptLong::NO_ARGUMENT ],
@vaiorabbit
vaiorabbit / nuklear.rb
Created June 26, 2016 05:08
(Experimental) Ruby bindings for the Nuklear GUI toolkit ( https://github.com/vurtun/nuklear )
require 'ffi'
module Nuklear
extend FFI::Library
NK_UTF_INVALID = 0xFFFD
NK_UTF_SIZE = 4
NK_INPUT_MAX = 16
NK_MAX_NUMBER_BUFFER = 64
@vaiorabbit
vaiorabbit / drawtree.rb
Last active June 22, 2016 13:12
Tree Drawing Algorithm Test
require 'opengl'
require 'glfw'
require_relative 'lib/nanovg'
require_relative 'tree'
OpenGL.load_lib()
GLFW.load_lib()
NanoVG.load_dll('libnanovg_gl3.dylib', render_backend: :gl3)
# coding: utf-8
require 'fiddle'
Dir.chdir(File.dirname(__FILE__))
require_relative './../lib/dxsdl2r'
require_relative './mmd'
require_relative './motion'
$ss_name = "ss0000.tga"
$ss_id = 0
# coding: utf-8
require 'fiddle'
Dir.chdir(File.dirname(__FILE__))
require_relative './../lib/dxsdl2r'
require_relative './mmd'
require_relative './motion'
$ss_name = "ss0000.tga"
$ss_id = 0
# coding: utf-8
Dir.chdir(File.dirname(__FILE__))
require_relative './../lib/dxsdl2r'
require_relative './mmd'
require_relative './motion'
MAX_BONE_COUNT = 96
src_vs = <<EOF
uniform vec3 boneOrigin[#{MAX_BONE_COUNT}];