Skip to content

Instantly share code, notes, and snippets.

View aschearer's full-sized avatar

Alex Schearer aschearer

View GitHub Profile
// Updates the player object in Azure Mobile Services and then the player's games
function update(item, user, request) {
var gamesTable = tables.getTable('GameData');
request.execute({
success: function(result) {
// Asychronously update games the player is part of
gamesTable.where(function(player)
{
return this.OwnerId == player.PlayerId ||
this.OpponentId == player.PlayerId
@aschearer
aschearer / SerializationExample.cs
Created May 23, 2013 18:31
Example using DataContractSerializer to persist an object. Requires adding a reference to the System.Runtime.Serialization dll.
namespace SpottedZebra.Examples.Serialization
{
using System.IO;
using System.Runtime.Serialization;
public class SerializationExample
{
[DataContract]
public class Sandwich
{
namespace SpottedZebra.Examples.WinRT
{
using System;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
public sealed partial class SpritesheetExamplePage : Page
{
@aschearer
aschearer / CanvasExamplePage.xaml
Last active December 17, 2015 11:29
Example code to animate sprites using C# and XAML on Windows 8.
<Page
x:Class="SpottedZebra.Examples.WinRT.CanvasExamplePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Canvas>
@aschearer
aschearer / Coordinates.tt
Created November 16, 2012 00:33
T4 template file to create code from CSV
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ import namespace="System.IO" #>
/* THIS FILE IS AUTOGENERATED DO NOT EDIT
*
* This file is autogenerated from Coordinates.csv.
* If you want to add a new user interface coordinate
* do so in the CSV file then rebuild.
*/
@aschearer
aschearer / StreamUtilities.cs
Created August 11, 2012 16:25
Compressing Json
using System.IO;
using System.IO.Compression;
using System.Runtime.Serialization.Json;
using System.Text;
namespace Petunk.Common.Models
{
public class StreamUtilities
{
public static Stream StringToStream(string json)
class XnaVisualSquare : IComponent
{
public const string Name = "XnaVisualSquare";
private Square subject;
private Texture2D square;
private Texture2D border;
private Rectangle dimensions;
public XnaVisualSquare(Square target, int x, int y, int width, int height, Texture2D square, Texture2D border)
class Square : AbstractEntity
{
public const int Width = 80;
public const int Height = 80;
public ColorCode ColorCode { get; private set; }
public Square(int x, int y, ColorCode code)
{
// TODO figure out where the texture should come from
<html>
<head>
<title>Example Page</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<ul id="list">
<li>One Item</li>
</ul>
package atplaygames.common
{
import flash.display.MovieClip;
import flash.events.Event;
/**
* Base game object which can be added to the stage.
*
* Use the onInit method to initialize the object. The entire