Skip to content

Instantly share code, notes, and snippets.

View jcdickinson's full-sized avatar
🐵

Jonathan Dickinson jcdickinson

🐵
View GitHub Profile
static void FizzBuzz(int number)
{
// 3 MOD 3 = 0. We actually want 1 for multiples of 3.
// So we store an incremented number so that we get 1
// for the binary operations. This applies to 5 as
// well.
// Valid numbers for X MOD 3 are { 0, 1, 2 }. Therefore
// we can simply AND it with 1. As such:
// { 0, 1, 2 } AND 1 =
private Socket _socket;
private ArraySegment<byte> _buffer;
public void StartReceive()
{
ReceiveAsyncLoop(null);
}
// Note that this method is not guaranteed (in fact
// unlikely) to remain on a single thread across
// async invocations.
private Socket _socket;
private Stream _targetStream;
private SslStream _tlsStream;
public void BeginStartTls(AsyncCallback callback, object asyncState)
{
_targetStream = _tlsStream = new SslStream(_targetStream);
_tlsStream.BeginAuthenticateAsServer(GetServerCerticate(), callback, asyncState);
}
/// <summary>
/// Represents a buffer pool.
/// </summary>
public class BufferPool
{
private readonly int _segmentsPerChunk;
private readonly int _segmentSize;
private readonly ConcurrentStack<ArraySegment<byte>> _buffers;
/// <summary>
private Encoding _encoding;
private Decoder _decoder;
private char[] _charData = new char[4];
public PushTextReader(Encoding encoding)
{
_encoding = encoding;
_decoder = _encoding.GetDecoder();
}
this.ActiveCamera.Position = new Vector3(0, 100, 200);
this.ActiveCamera.LookAt(new Vector3(0, 0, 0));
this.ActiveSceneManager.AmbientLight = ColorEx.Black;
this.ActiveSceneManager.ShadowTechnique = ShadowTechnique.TextureModulative;
Entity entity = ActiveSceneManager.CreateEntity("Ninja", "ninja.mesh");
entity.CastShadows = true;
ActiveSceneManager.RootSceneNode.CreateChildSceneNode("NinjaNode").AttachObject(entity);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Web;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.ServiceModel;
@jcdickinson
jcdickinson / SqlParserTests.cs
Created May 9, 2011 16:43
Getting a bit Crazy
// Assert.IsTrue(Environment.Developer.IsConfused, "Assumed.")
Assert.IsNotNull(select.WhereClause, "Where present");
select.WhereClause.Expression.BinaryExpr
(
a => a.BinaryExpr
(
b => b.BinaryExpr
(
c => c.BinaryExpr
(
@jcdickinson
jcdickinson / .gitignore
Created June 6, 2011 08:43
GitIgnore for Visual Studio
#
# Don't include stuff created by Windows.
#
Thumbs.db
#
# Don't include stuff created by Visual Studio.
#
*.obj
*.vshost.exe
*.user
@jcdickinson
jcdickinson / ACCESS_GetAcountUsage.json
Created July 4, 2011 09:49
ACCESS_GetAccountUsage JSON Sample
{
"api_response": {
"error_count": "0",
"method": "ACCESS_GetAccountUsage",
"response_begin": null,
"response_end": null,
"usage": {
"day_count": "31",
"days": {
"day": [