Skip to content

Instantly share code, notes, and snippets.

View kamino410's full-sized avatar

kamino410 kamino410

View GitHub Profile

combination

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
@kamino410
kamino410 / gl-cuda-test.cpp
Created May 20, 2018 16:03
Render on CUDA, display with OpenGL
#include <iostream>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#define WIDTH 512
#define HEIGHT 512
extern "C" void kernelBindPbo(GLuint pixelBufferObj);
@kamino410
kamino410 / BehaviourScript.cs
Last active May 16, 2018 03:02
Unity C# script for AlbaSim; flight simulator of human powered aircraft (https://www.youtube.com/watch?v=gkGf1dIYQEk)
using UnityEngine;
using System.Collections;
class WingElem {
public WingElem(Vector3 pos, float dih, float coef, LineRenderer dlr, LineRenderer llr) {
Pos = pos;
var rad = Mathf.Deg2Rad * dih;
BeamVec = new Vector3(Mathf.Cos(rad), Mathf.Sin(rad), 0);
Normal = new Vector3(-Mathf.Sin(rad), Mathf.Cos(rad), 0);
Coef = coef;
@kamino410
kamino410 / .cVimrc
Last active October 19, 2017 21:59
unmap J
unmap H
unmap K
unmap L
map J goBack
map H previousTab
map K goForward
map L nextTab
#メッシュの作製
mesh = bpy.data.meshes.new("new_mesh")
#点を描画する場合
mesh.from_pydata([(0,0,0),(1,0,0),(1,1,0)], [], [])
mesh.update()
#加えて線を描画する場合(何番目の点と何番目の点を結ぶかのリストを渡す)
mesh.from_pydata([(0,0,0),(1,0,0),(1,1,0)], [(0,1),(1,2),(2,0)], [])
mesh.update()
#加えて面を描画する場合)
mesh.from_pydata([(0,0,0),(1,0,0),(1,1,0)], [], [(0,1,2)])
@kamino410
kamino410 / pg.sql
Last active February 23, 2017 03:57
SELECT
nsp.nspname AS schema,
cls.relname AS table_name,
own.rolname AS owner,
dsc.description
FROM
pg_catalog.pg_class cls
LEFT JOIN pg_catalog.pg_namespace nsp ON cls.relnamespace = nsp.oid
LEFT JOIN pg_catalog.pg_authid own ON cls.relowner = own.oid
LEFT JOIN pg_catalog.pg_description dsc ON cls.oid = dsc.objoid