Skip to content

Instantly share code, notes, and snippets.

Chris Yuen kizzx2

Block or report user

Report or block kizzx2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kizzx2
kizzx2 / bare_opengl_es.m
Created Apr 20, 2011
Barebone OpenGL ES initialization with iOS
View bare_opengl_es.m
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
@interface OGLESView : UIView {
EAGLContext * glContext;
GLuint framebuffer;
GLuint renderbuffer;
}
@kizzx2
kizzx2 / c++_compile_time_strlen.cpp
Created Apr 20, 2011
Compile time (static) length of string literal
View c++_compile_time_strlen.cpp
#include <iostream>
template <size_t N>
inline void foo(const char (&)[N])
{
std::cout << "strlen(x) = " << N << std::endl;
}
int main()
{
@kizzx2
kizzx2 / c++_has_function.cpp
Created Apr 20, 2011
C++ static "has_function" with SFINAE
View c++_has_function.cpp
#include <iostream>
struct Foo
{
void One();
};
struct Baz : Foo
{
void Two();
@kizzx2
kizzx2 / c++_has_member.cpp
Created Apr 20, 2011
C++ compile time detection of member variable with SFINAE
View c++_has_member.cpp
#include <iostream>
struct Foo
{
int one;
};
struct Bar
{
char one;
@kizzx2
kizzx2 / K2WordNumber.hs
Created Aug 9, 2011
Word Numbers brute force (Haskell profiling exercise)
View K2WordNumber.hs
-- Problem: Find the 51000000000-th character of the string (wordNumber Infinity)
-- where a wordNumber is defined as
--
-- wordNumber 1 = "one"
-- wordNumber 2 = "onetwo"
-- wordNumber 3 = "onetwothree"
-- wordNumber 15 = "onetwothreefourfivesixseveneightnineteneleventwelvethirteenfourteenfifteen"
-- ...
--
-- The answer should be presented as ( sum of all numbers up to that point
@kizzx2
kizzx2 / FunDep.hs
Created Sep 3, 2011
Haskell type-level programming using functional dependencies and type families
View FunDep.hs
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
-- Type-level functions using functional dependencies
@kizzx2
kizzx2 / Solitaire.hs
Created Sep 4, 2011
Solitaire Cipher in Haskell
View Solitaire.hs
-- Solitaire Cipher
-- http://www.rubyquiz.com/quiz1.html
module Solitaire where
import Data.Sequence ((><), (|>), (<|))
import qualified Data.Sequence as S
import Debug.Trace
import Control.Arrow
@kizzx2
kizzx2 / Worddy.hs
Last active Sep 27, 2015
Solution to Word Numbers (Haskell)
View Worddy.hs
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NamedFieldPuns #-}
-- Chris Yuen <chris@kizzx2.com>
-- ITA Software's "Word Numbers" puzzle (http://www.itasoftware.com/careers/puzzle_archive.html)
import Data.Function
import Data.List
-- | For this problem we'll trie like structure. An "umbrella" value is
@kizzx2
kizzx2 / Rakefile
Created Dec 29, 2011
Use premake4 to generate iOS .xcodeproj files
View Rakefile
# Usage:
# In premake4.lua use StaticLib for libraries; ConsoleApp for applications.
# Then run `rake xcode && rake xcodebuild`
ENV_DEFAULTS = {
'CONFIGURATION' => "Debug",
'SDK' => "iphonesimulator",
}
SDK_TO_ARCH = {
@kizzx2
kizzx2 / fun.cpp
Created Jan 11, 2012
Illustrative C++ Lua binding example/tutorial
View fun.cpp
// fun.cpp
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <iostream>
You can’t perform that action at this time.