Skip to content

Instantly share code, notes, and snippets.

View tai2's full-sized avatar
🐢

Taiju Muto tai2

🐢
View GitHub Profile
@tai2
tai2 / cglinks.md
Last active December 16, 2015 09:08
CG links.
@tai2
tai2 / ldap.php
Created April 18, 2013 13:41
LDAP authentication.
$conn = ldap_connect($host, $port);
if ($conn) {
echo "ldap connected\n";
if (ldap_bind($conn, $bind_dn, $password)) {
echo "bind suceeded\n";
$search_result = ldap_search($conn, $base_dn, "(&(objectClass=person)(uid={$username}))");
if ($search_result) {
echo "search suceeded\n";
$entries = ldap_get_entries($conn, $search_result);
if (0 < count($entries)) {
@tai2
tai2 / astroterms.md
Created April 23, 2013 05:09
Astronomy Terms

Astronomy Terms

  • 公転 orbit
  • 自転 rotation
  • 赤道 equator
  • 天球 celestial sphere
  • 宇宙の距離梯子 cosmic distance ladder
  • 天文単位 astronomical unit
  • 太陽質量 solar mass
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <GLUT/glut.h>
#define KEY_ESC 27
#define WINDOW_POS_X 100
#define WINDOW_POS_Y 100
#define DEF_SCREEN_WIDTH 640
#define DEF_SCREEN_HEIGHT 360
@tai2
tai2 / SntpClient.java
Created April 26, 2013 11:32
SNTP client. RFC 2030.
package net.tai2.test;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.PortUnreachableException;
import java.net.SocketTimeoutException;
@tai2
tai2 / clover.c
Created April 30, 2013 09:21
Smoking Clover. This code is ported from http://sourceforge.net/projects/smokingclover/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <GLUT/glut.h>
#define KEY_ESC 27
#define WINDOW_POS_X 100
#define WINDOW_POS_Y 100
@tai2
tai2 / declaration.md
Last active June 21, 2017 01:35
理想のプログラミングスタイル
  • Explicit is better than implicit.
  • Design From The Client Side
  • 高凝集・疎結合
  • テストしやすいインターフェイス
  • 異なる抽象度のレイヤー構造
  • デバッグ機能の作り込みはたいせつ
  • コメントは必要最低限に(コードそのものをドキュメントにする)
  • メッセージパッシングはすばらしい
  • ボイラープレートの最小化
@tai2
tai2 / hsv_to_rgv.c
Created May 5, 2013 07:37
HSV to RGV conversion
void
hsv_to_rgb(double h, double s, double v, double *r, double *g, double *b):
if (s * v == 0) {
*r = *g = *b = v;
} else {
hi = ((int)(floor(3 * h / M_PI))) % 6
f = 3 * h / M_PI - hi;
p = v * (1.0 - s)
q = v * (1.0 - f * s)
t = v * (1.0 - (1.0 - f) * s)
@tai2
tai2 / plasma.c
Created May 5, 2013 09:19
Old school plasma effect. c.f. http://www.bidouille.org/prog/plasma
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <GLUT/glut.h>
#define KEY_ESC 27
#define WINDOW_POS_X 100
#define WINDOW_POS_Y 100
#define DEF_SCREEN_WIDTH 640
@tai2
tai2 / tunnel.c
Last active December 17, 2015 04:48
Old school tunnel effect. c.f. http://benryves.com/tutorials/tunnel/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GLUT/glut.h>
#include <FreeImage.h>
#define MIN(x,y) ((x) > (y) ? (y) : (x))
#define KEY_ESC 27
#define WINDOW_POS_X 100