Skip to content

Instantly share code, notes, and snippets.

View ryosuzuki's full-sized avatar

Ryo Suzuki ryosuzuki

View GitHub Profile
@ryosuzuki
ryosuzuki / index.xml
Created October 16, 2015 22:03
craftml
<craft>
<info>
<title>Untitled</title>
</info>
<param name="h" type="int" default="20"
label="height of the cylinder"/>
<param name="n" type="int" default="3"
label="number of spheres"/>
@ryosuzuki
ryosuzuki / Node-ffi.md
Last active February 29, 2016 07:52
Hello world with node-ffi

Hello world with node-ffi

Use C++ dynamic library from Node.js with node-ffi

$ g++ -dynamiclib -o libhello.dylib hello.cpp
$ ls 
libhello.dylib   hello.cpp   hello.js
$ node hello.js
hello world
@ryosuzuki
ryosuzuki / Node-ffi-array.md
Last active March 3, 2024 21:00
Node-ffi example: Passing and receiving array object between Node.js and C++ binding

Node-ffi with IntArray

Passing and receiving array object between Node.js and C++ binding

$ g++ -dynamiclib -o mylib.dylib main.cpp
$ node index.js
[matrix size: 100x100; n_nonzero: 4; density: 0.04%]

 (1, 1) 2.0000
@ryosuzuki
ryosuzuki / ARAP.md
Last active February 29, 2016 07:53

As Rigid As Possible

C++ implmentation

#include "opengl.h"
void OpenGL::initBuffers() {
glGenVertexArrays(1, &vaoMesh);
glBindVertexArray(vaoMesh);
glGenBuffers(1, &vboVertices);
glGenBuffers(1, &vboNormals);
glGenBuffers(1, &vboUVs);
glGenBuffers(1, &vboFaces);
#include "mesh.h"
void Mesh::set(const Eigen::MatrixXf &V_, const Eigen::MatrixXi &F_) {
V = V_;
F = F_;
computeNormals();
computeAdjacencyMatrix();
computeEdgeLength();
#version 330
precision lowp float;
uniform vec3 color;
out vec4 outColor;
void main() {
outColor = vec4(color, 1.0);
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>High frequency sound generator</title>
<script>
var WAcontext, oscillator, isPlay;
initSound();
function initSound() {
WAcontext = new AudioContext || new webkitAudioContext;
// make sure to select "Box Colider" option at the Inspector panel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragObject : MonoBehaviour {
//float distance = 10;