Skip to content

Instantly share code, notes, and snippets.

View wackoisgod's full-sized avatar

Andrew Spiering wackoisgod

  • San Francisco
  • 20:25 (UTC -07:00)
View GitHub Profile
namespace Music {
struct TrackInfo {
const string m_length;
const u32 m_playerCount;
};
struct EncodingInfo {
const u32 m_bitrate; // this could be stored in a smaller value ?
const u8 m_channels; // no more than 255 channels
};
@wackoisgod
wackoisgod / proto.cpp
Created June 14, 2012 05:15
C++ Protobufs
public void Socket::WriteDelimitedTo(protoBuf& msg) {
std::ostream requestStream(&someInputStream);
google::protobuf::io::OstreamOutputStream rawBuffer(&requestStream);
google::protobuf::io::CodedOutputStream codedOutput(&rawBuffer);
codedOutput.WriteVarint32(msg.ByteSize());
msg.SerializeToCodedStream(&codedOutput);
#ifndef ENYO_PROTOBUF_CONNECTION_HPP
#define ENYO_PROTOBUF_CONNECTION_HPP
#include "asioconnection.hpp"
#include <boost/cstdint.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/shared_ptr.hpp>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
int size = m.ByteSize();
void *buffer = malloc(size);
m.SerializeToArray(buffer, size);
wm.set_payload(static_cast<char*>(buffer));
free(buffer);
#include "stdafx.h"
class PrivateClass{
private:
void SomeFunction() { printf("Hello World"); };
};
template <class Tag>
struct touch
class PrivateClass{
private:
void SomeFunction() { printf("Hello World"); };
};
template <class Tag>
struct touch
{
static typename Tag::type value;
var x = new Point(3, 3);
var y = new Point(1, 2);
var x1 = y.X - x.X;
var y1 = y.Y - x.Y;
var scale = Math.Max(Math.Abs(x1), Math.Abs(y1));
var direction = new Point(x1 / scale, y1 / scale);

Keybase proof

I hereby claim:

  • I am wackoisgod on github.
  • I am wacko (https://keybase.io/wacko) on keybase.
  • I have a public key ASDdMcUPNQo86gWlfSjDxGBH6gYKTkJrzqOzEo_Xizk-6Qo

To claim this, I am signing this object:

@wackoisgod
wackoisgod / EventDataConverter.cs
Created February 4, 2018 02:23 — forked from joshgarnett/EventDataConverter.cs
zsharp list support
using Zynga.Protobuf.Runtime.EventSource;
namespace Zynga.Protobuf.Runtime {
public abstract class EventDataConverter<T> {
/// <summary>
/// Returns EventContent for the specified data
/// </summary>
public abstract EventContent GetEventData(T data);
/// <summary>
public class UnityConsoleTraceListener : TextWriterTraceListener
{
public override void Write(string message)
{
UnityEngine.Debug.LogError(message);
base.Write(message);
}
public override void WriteLine(string message)
{