Skip to content

Instantly share code, notes, and snippets.

@Vannevelj
Vannevelj / MiniMax
Last active August 29, 2015 13:56
Vlaamse Programmeer Wedstrijd
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Test {
private static Scanner sc = new Scanner(System.in);
private static List<MiniMax> lijsten = new ArrayList<MiniMax>();
public static void main(String[] args) {
int aantalLijsten = sc.nextInt();
@Vannevelj
Vannevelj / PacketTracer
Created February 23, 2014 18:06
Packet tracing sample
void Main()
{
Capture();
}
private readonly byte[] _data = new byte[4096];
private Socket _mainSocket;
public void Capture()
void Main()
{
for(int i = 0; i < 5; i++){
var list = GetList();
DisplayList(list);
GetHotStreaks(list);
}
}
private static Random rand = new Random();
@Vannevelj
Vannevelj / CodeDomEquals
Last active August 29, 2015 13:58
Generating the .Equals() method through CodeDom
private void AddEqualsMethod(ref CodeTypeDeclaration type, TinyType tinyType)
{
// Create method
var method = new CodeMemberMethod()
{
Name = "Equals",
Attributes = MemberAttributes.Public | MemberAttributes.Override,
ReturnType = new CodeTypeReference(typeof (bool)),
};
method.Parameters.Add(new CodeParameterDeclarationExpression(typeof (object), "o"));
foreach (var argument in genericTypeParameters.Arguments)
{
var typeInfo = semanticModel.GetTypeInfo(argument);
var dir = @"C:\Users\Jeroen\Documents\Visual Studio 2013\Projects\RoslynTester";
var solution = MSBuildWorkspace.Create().OpenSolutionAsync(dir).Result;
var syntaxRoots =
from project in solution.Projects
from document in project.Documents
"features": [
{
"name":"kiosk_mode"
},
{
"name":"create_contacts"
},
{
"name":"create_quotes",
"dependencies": [
public void Unit_CanParse_Organisation()
{
var data = GetResponse("organisation");
var obj = JsonConvert.DeserializeObject<Organisation>(data);
Assert.IsNotNull(obj);
Assert.AreEqual(165, obj.Id);
Assert.AreEqual("qa", obj.Alias);
Assert.AreEqual("Some name", obj.Name);
try
{
var irrelevant = myApi.GetUserInfoAsync().AsTask().Result;
}
catch (AggregateException ae)
{
if (ae.InnerException.GetType() == typeof(InvalidOperationException))
{
Assert.IsTrue(true);
}
@Vannevelj
Vannevelj / gist:f1bcd31e45689f1e6bf7
Last active August 29, 2015 14:03
Eventcalling from WinRT
public sealed class TestClass
{
public event TypedEventHandler<TestClass, LogoutEventArgs> Logout;
public void DoSomething()
{
if (Logout != null)
{
Logout(this, new LogoutEventArgs());
}
void Main()
{
var invocations = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
var random = new Random();
var iterations = 100000000;
var data = new object[] { 5, 5L, (sbyte) 5, (short) 5, (byte) 5, (ushort) 5, (uint) 5, 5ul, "lala", SomeEnum.SomeValue };
var times = new long[] { 0L, 0L };
var sw = new Stopwatch();
sw.Start();