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
/* vim: set et ft=cpp.doxygen sts=2 sw=2 ts=8 : */ | |
/** | |
* Copyright © 2013 Saleem Abdulrasool <[email protected]> | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* 1. Redistributions of source code must retain the above copyright notice, | |
* this list of conditions and the following disclaimer. |
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
// The original author of this software is David M. Gay. | |
// RAD modifications from here down to the copyright notice | |
// Actual RAD version of this includes rrCore.h which does | |
// (among other things) endianness detection - you'll have to | |
// do that yourself. | |
#include "dtoa.h" | |
// Again, we normally use our own assert macros here. |
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
# Single-line version: | |
(?i)\b(https?:\/{1,3})?((?:(?:[\w.\-]+\.(?:[a-z]{2,13})|(?<=http:\/\/|https:\/\/)[\w.\-]+)\/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’])|(?:(?<!@)(?:\w+(?:[.\-]+\w+)*\.(?:[a-z]{2,13})|(?:(?:[0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]?){4})\b\/?(?!@)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))*(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’])?)) | |
# Commented multi-line version: | |
(?xi) | |
\b | |
(https?:\/{1,3})? # Capture $1: (optional) URL scheme, colon, and slashes | |
( # Capture $2: Entire matched URL (other than optional protocol://) |
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 <mongo/bson/bson.h> | |
using mongo::BSONObj; using mongo::BSONObjBuilder; | |
using mongo::BSONArray; using mongo::BSONArrayBuilder; | |
using mongo::BSONElement; | |
#include <rapidjson/document.h> | |
#include <rapidjson/reader.h> | |
#include <rapidjson/writer.h> | |
#include <rapidjson/stringbuffer.h> |
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 "hemicube.h" | |
#define PACK_HEMICUBES 1 | |
static void get_hemicube_face_normal(int index, Vector3 *forward, Vector3 *left, Vector3 *up) { | |
// Unwrapped hemicube with positive-Z in the middle. | |
switch (index) { | |
case 0: *forward = Vector3(+1, 0, 0); *left = Vector3( 0, 1, 0); break; |
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
void RasteriseTriangle3(char* buffer, int width, int height, float2 v0, float2 v1, float2 v2) | |
{ | |
// Sort vertices along the y-axis, lowest first | |
if (v1.y < v0.y) | |
std::swap(v0, v1); | |
if (v2.y < v1.y) | |
std::swap(v1, v2); | |
if (v1.y < v0.y) | |
std::swap(v0, v1); |
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
// | |
// Pre-processor scans your C/header file for the '/*$gen:' signature | |
// It consumes everything inside the C-style comment and generates a unique hash | |
// This hash is used to determine if the contents of the comment have changed since it last looked | |
// The hash is stored after the '/*$gen:' signature | |
// | |
/*$gen:0x1AF673C3 | |
// This is your generic implementation with (T) the generic type |
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
-- To run this file you just need the ghc application from the Haskell Platform bundle | |
-- With that on a command line run the following (assuming the code is in Monads.hs): | |
-- ghc Monads.hs && ./Monads | |
-- Imports needed for later: | |
import System.IO | |
-- So pretty much every language has this concept: | |
-- doThingA(); | |
-- doThingB(); | |
-- If that wasn't hugely clear, it was the concept of calling one bit of code |
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
// ---- INTERFACE | |
// Sound handle. This is a weak reference; they automatically go invalid as voices | |
// stop playing and get reused. You don't need to worry about leaks. | |
struct SoundHandle | |
{ | |
uint32_t opaque; // Mixer decides what this means (but 0=null) | |
explicit SoundHandle(uint32_t handle=0) : opaque(handle) {} |
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
class FileWatcher | |
{ | |
public: | |
FileWatcher(const Path& path) | |
: m_Path(path) | |
, m_DirHandle(INVALID_HANDLE_VALUE) | |
, m_BufferSize(CORE_KB(100)) | |
, m_Buffer(nullptr) | |
, m_ChangedFiles(1024) | |
{ |
OlderNewer