Skip to content

Instantly share code, notes, and snippets.

@suzumura-ss
suzumura-ss / teapot.c
Last active December 17, 2015 16:59
GLUTでteapotを表示
#include <GL/glut.h>
void display(void)
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glClearColor(0.0, 0.0, 1.0, 1.0);
@suzumura-ss
suzumura-ss / teapot.rb
Last active December 17, 2015 16:59
Ruby/openGLでteapotを表示
require 'opengl'
$rot = 0.0
def display
glEnable(GL_DEPTH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glClearColor(0.0, 0.0, 1.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
@suzumura-ss
suzumura-ss / register_route53
Last active December 18, 2015 03:59
Regist public-hostname to Route53.
#!/usr/local/bin/ruby
require 'aws-sdk'
require 'yaml'
# Get informations of the instance.
instance_id = `curl -s http://169.254.169.254/latest/meta-data/instance-id`
endpoint = ['ec2', `curl -s http://169.254.169.254/latest/meta-data/public-hostname`.split('.')[1], 'amazonaws.com'].join('.')
ip = `curl -s http://169.254.169.254/latest/meta-data/public-ipv4`
uniform sampler2D tex;
float M_2PI = 6.283185307179586;
float SQRT2 = 1.4142135623730951;
void main()
{
float x = (gl_TexCoord[0].x - 0.5);
float y = (gl_TexCoord[0].y - 0.5);
float r = sqrt(x*x+y*y);
@suzumura-ss
suzumura-ss / GPUImageLittlePlanetProjectionFilter.h
Created July 2, 2013 07:52
`LittlePlanet` projection with GPUImage.framework
//
// GPUImageLittlePlanetProjectionFilter.h
//
// Created by Toshiyuki Suzumura on 2013/07/02.
// Copyright (c) 2013 Toshiyuki Suzumura. All rights reserved.
//
#import "GPUImageFilter.h"
@interface GPUImageLittlePlanetProjectionFilter : GPUImageFilter
@suzumura-ss
suzumura-ss / BilinearSampler.hpp
Created February 20, 2014 17:30
BilinearSampler with SSE.
#ifndef __simd_bilinear_sampler__
#define __simd_bilinear_sampler__
#include <immintrin.h>
class BilinearSampler {
protected:
const uint8_t* _pixels;
int _rowInBytes;
@suzumura-ss
suzumura-ss / dylib_patch.rb
Created July 17, 2015 05:46
shared libraryの参照パスを @executable_path/ 直下に再帰的に更新
#!/usr/bin/env ruby
class ModifyPath
def initialize(exe)
@exe = exe
@dylibs = `otool -L #{exe}`.each_line.map{|line|
$1 if line=~%r{\t([^/@].+\.dylib) .*$}
}.compact.delete_if{|dy|
File.basename(dy)==File.basename(exe) or !File.exist?(File.basename(exe))
}
@suzumura-ss
suzumura-ss / peewee-example.py
Created November 12, 2015 08:45
peewee with BIGINT primary key.
#from peewee import *
#import pymysql
import peewee
# 'id' to 'BIGINT AUTO_INCREMENT'
peewee.MySQLDatabase.field_overrides['primary_key'] = 'BIGINT AUTO_INCREMENT'
db = peewee.MySQLDatabase(
database='peewee_development',
user='root',
password='',
@suzumura-ss
suzumura-ss / getmyip.py
Created November 13, 2015 04:50
Get IP myself in AWS Lambda
import json
import commands
class MyIP:
def rawips(self):
cmd = "awk 'NR!=1 { split($2,arr,\":\"); print arr[1] }' /proc/net/tcp|sort|uniq"
return commands.getoutput(cmd).split("\n")
def raw2str(self, raw):
n = [int(raw[n:n+2],16) for n in [6,4,2,0]]
@suzumura-ss
suzumura-ss / fileUploader.ru
Last active December 11, 2015 07:16
fileUploader example with ruby-grape
#!/usr/bin/env rackup
# encoding: UTF-8
=begin
# start application
$ mkdir files
$ ./fileUploader.ru
# upload
$ curl localhost:9292/files -F comment="hello,world" -F "body=@example.txt;type=image/jpg"