Skip to content

Instantly share code, notes, and snippets.

@jdstanhope
jdstanhope / main.cpp
Created August 1, 2023 18:19
Using Inplace New to Change Type
#include <iostream>
struct TypeA {
int data;
TypeA() { }
virtual void foo() { std::cout << "TypeA::foo()" << std::endl; }
};
struct TypeB {
int notData;
class Suite {
constructor(name, value) {
this.name = name;
this.value = value;
}
}
class Rank {
constructor(name, value) {
this.name = name;
@jdstanhope
jdstanhope / app.yaml
Created March 4, 2013 01:20
Google App Engine example of inline image uploading using Python
application: inline-upload
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
@jdstanhope
jdstanhope / app.yaml
Created March 3, 2013 19:09
AppEngine app.yaml that includes jinja2 library
application: inline-upload
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
@jdstanhope
jdstanhope / main.py
Created March 3, 2013 19:08
App Engine Template using Jinja2 template engine
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# 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
#
@jdstanhope
jdstanhope / BodyViewModel.cs
Created October 19, 2010 21:45
The BodyViewModel for the FarseerTransform example
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
using FarseerPhysics.Dynamics;
namespace FarseerTransforms
{
public class BodyViewModel : INotifyPropertyChanged
{
@jdstanhope
jdstanhope / MainPage.xaml.cs
Created October 19, 2010 21:28
The Loaded event handler for MainPage.xaml in FarseerTransform
void MainPageLoaded(object sender, RoutedEventArgs e)
{
float aspectRatio = (float)(_worldControl.ActualWidth / _worldControl.ActualHeight);
float width = 10.0f * aspectRatio;
float height = 10.0f;
float borderDepth = 0.01f;
double scaleFactor = _worldControl.ActualHeight / 10.0f;
// create transform between world and canvas
_worldToCanvas = new CompositeTransform();
@jdstanhope
jdstanhope / MainPage.xaml.cs
Created October 19, 2010 21:20
Code behind for MainPage.xaml in FarseerTransform
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
using FarseerPhysics.Common;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using Microsoft.Phone.Controls;
@jdstanhope
jdstanhope / MainPage.xaml
Created October 19, 2010 21:16
FarseerTransform MainPage
<phone:PhoneApplicationPage
x:Class="FarseerTransforms.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"