Created
October 11, 2010 06:22
-
-
Save dictav/620095 to your computer and use it in GitHub Desktop.
Gists for Blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vec3 kY = vec3(0.299, 0.587, 0.114); | |
const vec3 kCr = vec3(0.5, -0.419, -0.081); | |
const vec3 kCb = vec3(-0.169, -0.332, 0.5); | |
vec4 brightness(vec4 color, float val) { | |
float Y = dot(kY, color.rgb) + val; | |
float Cr = dot(kCr, color.rgb); | |
float Cb = dot(kCb, color.rgb); | |
float R = Y+1.402*Cr; | |
float G = Y-0.714*Cr-0.344*Cb; | |
float B = Y+1.772*Cb; | |
return vec4(R,G,B,color.a); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *file = @"shader/file/name"; | |
const GLchar *source; | |
source = (GLchar *)[[NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil] UTF8String]; | |
*shader = glCreateShader(type); | |
glShaderSource(*shader, 1, &source, NULL); | |
glCompileShader(*shader); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) testWithCode:(id)code { | |
NSLog(@"Hello, Gist!"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precision mediump float; | |
vec4 inverse(vec4 color) | |
{ | |
vec4 newColor; | |
newColor.rgb = vec3(1.0) - color.rgb; | |
newColor.a = color.a; | |
return newColor; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
require 'sequel' | |
Sequel::Model.plugin :json_serializer | |
db = Sequel.connect( ENV["DATABASE_URL"] || "sqlite://app.db" ) | |
class User < Sequel::Model | |
one_to_many :check_ins, :order=>:timestamp.desc | |
many_to_many :places, join_table:"check_ins", uniq:true | |
end | |
class CheckIn < Sequel::Model | |
many_to_one :user | |
many_to_one :place | |
def before_create | |
self.timestamp ||= Time.now | |
super | |
end | |
end | |
class Place < Sequel::Model | |
one_to_many :check_ins, :order=>:timestamp.desc | |
many_to_many :users, join_table:"check_ins", uniq:true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <mruby.h> | |
#include <mruby/proc.h> | |
#include <mruby/compile.h> | |
int main(void) | |
{ | |
int n; | |
mrb_state* mrb; | |
struct mrb_parser_state* st; | |
char* code = "puts 'hello, mruby!'"; | |
mrb = mrb_open(); | |
st = mrb_parse_string(mrb, code); | |
n = mrb_generate_code(mrb, st->tree); | |
mrb_pool_close(st->pool); | |
mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_nil_value()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment