Skip to content

Instantly share code, notes, and snippets.

View txdv's full-sized avatar

Andrius Bentkus txdv

  • Lithuania, Vilnius
View GitHub Profile
@txdv
txdv / gist:1083740
Created July 14, 2011 23:45
DNS dislove
void ParseHost(string host, TimeSpan timeSpan, Action<Exception, string, IPAddress> callback)
{
IPAddress ipaddress;
if (IPAddress.TryParse(host, out ipaddress)) {
callback(null, host, ipaddress);
} else {
bool timeout = false;
Context.CreateTimerWatcher(timeSpan, delegate {
callback(new Exception("Timeout while resolving"), null, null);
timeout = true;
@txdv
txdv / gist:1067063
Created July 6, 2011 12:00
Manos Udp proposal
using System;
using System.Text;
using Manos.IO;
namespace Test
{
public static class ByteBufferExtensions
{
public static string GetString(this ByteBuffer buffer, Encoding encoding)
@txdv
txdv / gist:1064214
Created July 5, 2011 03:29
Proposed boundary extensions
using Manos;
using Manos.IO;
using Manos.Threading;
using Manos.IO.Managed;
using System.Threading;
namespace Manos
{
public static class BoundaryExtensions
@txdv
txdv / gist:1064211
Created July 5, 2011 03:23
RandomGenerator for C#
using System.Security.Cryptography;
namespace Awesome
{
public static class RandomGenerator
{
private static RNGCryptoServiceProvider global =
new RNGCryptoServiceProvider();
[ThreadStatic]
@txdv
txdv / test.cs
Created July 1, 2011 07:21
A showcase how to create an IRC bot with a web frontend (all in 1 thread)
using System;
using System.Collections;
using System.Collections.Generic;
// Modified version of SmartIrc4Net available at: https://github.com/txdv/smartirc4net
using Meebey.SmartIrc4net;
using Manos.Http;
public class Test
{
@txdv
txdv / gitwiki.cs
Created March 16, 2011 23:01
manos memory leak
using Manos;
using System.IO;
using LibGit2Sharp.Core;
namespace GitWiki
{
public class GitWiki : ManosApp
{
static string repodir = "testrepo.git/.git/";