Skip to content

Instantly share code, notes, and snippets.

View tai2's full-sized avatar
🐢

Taiju Muto tai2

🐢
View GitHub Profile
@tai2
tai2 / drop_shadow3.py
Last active December 14, 2015 01:39
Drop shadow using distans from edge. This method is fast because shadow area is filled by one pass and flexible because attenuation can be represented by a function of distance from edge.
import sys
import os
import math
import Image
def create_shadow_image(image_size, shadow_size):
mergin = (shadow_size, shadow_size)
new_size = map(sum, zip(image_size, mergin, mergin))
im = Image.new('RGBA', new_size, 0xFFFFFFFF)
buf = im.load()
@tai2
tai2 / whitenoize.c
Created February 21, 2013 20:56
White noize(very slow and strange grid appeared)
#include <stdio.h>
#include <stdlib.h>
#include <GLUT/glut.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 360
static int curr_width = 0;
static int curr_height = 0;
@tai2
tai2 / helloworld.c
Last active December 14, 2015 08:49
Hello world!
#include <stdio.h>
int
main() {
printf("Hello world!\n");
return 0;
}
@tai2
tai2 / gist:5129172
Last active December 14, 2015 18:28
A patch to ADODB Active Record cache bug. c.f. http://phplens.com/lens/lensforum/msgs.php?id=18288&x=1
diff --git a/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php b/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php
index 474f2a7..4a214ed 100644
--- a/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php
+++ b/src/concrete/libraries/3rdparty/adodb/adodb-active-record.inc.php
@@ -343,20 +343,11 @@ class ADODB_Active_Record {
$table = $this->_table;
$tables = $activedb->tables;
$tableat = $this->_tableat;
- if (!$forceUpdate && !empty($tables[$tableat])) {
-
@tai2
tai2 / ao.php
Created March 13, 2013 13:17
aobench php port. About 200 times slower than C implementation. c.f. https://code.google.com/p/aobench/, http://tai2.net/docs/aobench_php/
<?php
error_reporting(E_ALL);
define('WIDTH', 256);
define('HEIGHT', 256);
define('NSUBSAMPLES', 2);
define('NAO_SAMPLES', 8);
class vec
@tai2
tai2 / test.md
Last active December 14, 2015 23:39
markdown test

THIS IS A TEST

content.

  • item1
  • item2
  • item3

orderd list.

#include <stdio.h>
int lcg() {
static int seed = 8;
seed = (1664525 * seed + 1013904223) & 2147483647;
return seed;
}
int
main() {
@tai2
tai2 / bufferbits.c
Created April 3, 2013 20:27
Display buffer bits on Mac OSX
#include <stdio.h>
#include <stdlib.h>
#include <GLUT/glut.h>
int
main(int argc, char** argv)
{
GLint red_bits, green_bits, blue_bits, alpha_bits;
GLint depth_bits, stencil_bits;
GLint accum_red_bits, accum_green_bits, accum_blue_bits, accum_alpha_bits;
@tai2
tai2 / whitenoize2.c
Created April 3, 2013 23:35
Improved version of https://gist.github.com/tai2/5008183 using glDrowPixels().
#include <stdio.h>
#include <stdlib.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 / connect.py
Last active December 16, 2015 02:39
Test whether a host and port pair is connectable.
import sys
import socket
if __name__ == '__main__':
host = sys.argv[1]
port = sys.argv[2]
timeout = sys.argv[3] if 4 <= len(sys.argv) else 30
s = socket.socket(socket.AF_INET)
s.settimeout(int(timeout))
try: