This file contains 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
/* | |
What: Exception using throw and jmp/longjmp | |
Author: Sid | |
Note: Test run with 3 cases | |
1: x(10), y(2) : Returns 2 | |
2: x(10), y(0) : Catch exception DIVIDE_EXCP, prints error and quit | |
3: x(10), y(-2) : Catch exception NEG_EXCP, does nothing | |
*/ | |
#include <iostream> |
This file contains 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 <iostream> | |
#include <cmath> | |
#include <cstring> | |
bool debug; | |
bool isFactor(long double n, long double f){ | |
long double i = 1.0; | |
long double m = f * i; | |
while(m <= n){ |
This file contains 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
// Test for two line segments intersection | |
// sid@whackylabs.com | |
// Inspired from: | |
// theory: http://www.bryceboe.com/2006/10/23/line-segment-intersection-algorithm/ | |
// source: http://www.bryceboe.com/wordpress/wp-content/uploads/2006/10/intersect.py | |
#include <iostream> | |
template<typename T> |
This file contains 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
/* | |
sid@whackylabs.com | |
Tool to test collision detection using Grapher.app | |
Create formatted data. | |
Input: cd.in | |
0.000000 320.000000 194.204971 -60.418026 244.204971 -10.418026 | |
0.000000 320.000000 194.249619 -60.418026 244.249619 -10.418026 | |
0.000000 320.000000 194.294266 -60.418026 244.294266 -10.418026 |
This file contains 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
// Using std::function for callback | |
#include <iostream> | |
#include <utility> | |
class Client; | |
// Calculator server | |
class Server{ | |
public: | |
typedef void (Client::*CB)(int result); |
This file contains 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
// | |
// EventLoop.h | |
// HideousGameEngine | |
// | |
// Created by Sid on 27/03/13. | |
// Copyright (c) 2013 whackylabs. All rights reserved. | |
// | |
#ifndef __HideousGameEngine__EventLoop__ | |
#define __HideousGameEngine__EventLoop__ |
This file contains 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
<html> | |
<head> | |
<title>Texture Coordinates</title> | |
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> | |
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script> | |
<script type="text/javascript" src="webgl-utils.js"></script> | |
<script id="shader-fs" type="x-shader/x-fragment"> |
This file contains 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
// Thank you std::unique_ptr! | |
// Compile with | |
// clang++ unique_ptr.cpp -o unique_ptr -std=c++11 -stdlib=libc++ && ./unique_ptr | |
/* OUTPUT: | |
--- START --- | |
Game | |
--- MAIN --- | |
Screen | |
MainScreen |
This file contains 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
// unique_ptr | |
// Case 1: Array of type | |
// Case 2: Array of pointer to type | |
#include <iostream> | |
#include <memory> | |
class Bar { | |
public: | |
Bar(float b) : bb(b) { |
This file contains 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<iostream> | |
#include<fstream> | |
using namespace std; | |
struct test | |
{ | |
short sss; | |
char ccc; | |
int iii; |