Skip to content

Instantly share code, notes, and snippets.

@foobit
foobit / gist:7930545
Last active December 31, 2015 03:49
my simple text data format
//
// C++ style comments
//
name "Test model" // key-value pair (kvp)
version 1.0 // kvp as number
rev 3182 // ...
full_screen true // boolean value - can not use 'true'/ 'false as kvp key
resizable false
@foobit
foobit / fancyprint.cpp
Created December 8, 2013 16:03
Hacking variadic functions for converting types to string
#include <stdio.h>
#include <string>
std::string printy(const std::string& p)
{
return std::move(p);
}
template<typename ... Types>
std::string printy(const std::string& p, float first, Types ... rest)
@foobit
foobit / WinMainNot.cpp
Created November 16, 2013 02:22
Make Windows app entry point portable main() vs WinMain
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
int main(int, const char**)
{
// create window normally
return 0;
}
@foobit
foobit / main.cpp
Created November 14, 2013 02:40
DirectX 11 creation with C++11 fun
// main.cpp
//
#include <windows.h>
#include <windowsx.h>
#include <d3d11.h>
#include <d3d11_2.h>
#include <algorithm>
@foobit
foobit / gglass_specs.md
Created August 2, 2013 15:32
Google Glass Specs (pun)
  • Screen aspect ratio: 16x9
  • Screen resolution: 640 x 360 pixels
  • Share contact icon size: 640 x 360 pixels
  • Menu option icon size: 50 x 50 pixels
  • Supported media format: MP4
  • Video: H.264 baseline and H.263 baseline
  • Audio: AAC and MP3
@foobit
foobit / scope_singleton.cpp
Last active December 18, 2015 21:09
C++11 singleton like class with scoped lifetime via receipt
/*
Copyright 2013 Scott Ramsay
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@foobit
foobit / exec.py
Created May 19, 2013 23:46
Enable GUI support for Sublime Text build command
class AsyncProcess(object):
def __init__(self, arg_list, env, listener,
# .... (removed) code
# Hide the console window on Windows
startupinfo = None
if os.name == "nt":
startupinfo = subprocess.STARTUPINFO()
# comment line below to enable GUI processes
@foobit
foobit / find.sh
Created May 17, 2013 19:51
recurse folder find all by optional ext and return only file name
#!/bin/bash
if [-z "$1" ]; then
BASE_PATH=.
else
BASE_PATH=$1
fi
if [-z "$2" ]; then
FILTER_EXT=*
@foobit
foobit / gist:5497649
Created May 1, 2013 19:23
MSBuild conditional Assembly Reference
<Reference Include="MonoMac" Condition="'$(Configuration)'=='DebugMono'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Mono|AnyCPU' ">
<DefineConstants>PLATFORM_MONO</DefineConstants>
<PropertyGroup />
@foobit
foobit / gist:5126115
Created March 9, 2013 22:46
Configure p4merge as git's default merge/diff tool
git config --global merge.tool p4merge
git config --global mergetool.p4merge.trustExitCode false
git config --global diff.tool p4merge