Skip to content

Instantly share code, notes, and snippets.

@mayerwin
mayerwin / Program.cs
Created September 3, 2012 16:49 — forked from svick/Program.cs
SO Task inlining
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program {
static void Main() {
Task.Factory.StartNew(() => {
Task.Factory.StartNew(() => Test1()).Wait();
Task.Factory.StartNew(() => Test2()).Wait(); //Sometimes works, sometimes deadlocks.
@mayerwin
mayerwin / SurrogateServiceTest
Created September 6, 2013 18:45
Original question on stackoverflow here: http://stackoverflow.com/q/18632361/541420 ("How to pass a Noda Time (or any third-party type) object as a parameter in WCF?"). Credits to http://blogs.msdn.com/b/carlosfigueira/archive/2011/09/14/wcf-extensibility-serialization-surrogates.aspx
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text.RegularExpressions;
Verifying that +mayerwin is my openname (Bitcoin username). https://onename.io/mayerwin
; The official HD AI
; An Artificial Intelligence Script written by Archon and Promiskuitiv
; Get in contact with Promiskuitiv by sending a mail to [email protected]
; List of taunts it reacts to:
; Standard taunts.
; 33 - Stop slinging resources. If slinging is requested early and is immediately canceled it may mess up the strategy.
; 38 - Sling Resources. Human player only, stops any unit production except for civilian units.
@mayerwin
mayerwin / EmptyArrayDtoTest.Cs
Created June 16, 2015 17:55
Bug report: Empty (but not null) DTO array property being deserialized as null if GET request (bug), but as empty array if POST request (correct).
using System;
using System.Collections.Generic;
using System.Linq;
using Funq;
using ServiceStack;
using Xunit;
namespace Bug {
public class EmptyArrayDtoTest {
public class AppHost : AppHostHttpListenerBase {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
using System.Threading.Tasks;
using EnvDTE80;
using EnvDTE90a;
@mayerwin
mayerwin / test_test.py
Created March 18, 2016 09:01
Sample unittest module for "Run a specific unit test function inside PyCharm IDE 5.0.4" question (http://stackoverflow.com/questions/36079152/run-a-specific-unit-test-function-inside-pycharm-ide-5-0-4)
import unittest
import pytest
from unittest import TestCase
# http://stackoverflow.com/questions/1323455/python-unit-test-with-base-and-sub-class
class BaseTestCases:
@mayerwin
mayerwin / .htaccess
Created May 12, 2016 19:34 — forked from jdevalk/.htaccess
These three files together form an affiliate link redirect script.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
@mayerwin
mayerwin / trakt-backup.php
Created February 11, 2019 02:41 — forked from darekkay/trakt-backup.php
Trakt.tv backup script
<?php
/*
Backup script for trakt.tv (API v2).
Live demo: https://darekkay.com/blog/trakt-tv-backup/
*/
// create a Trakt app to get a client API key: http://docs.trakt.apiary.io/#introduction/create-an-app
$apikey = "CLIENT_API_KEY";