Skip to content

Instantly share code, notes, and snippets.

View chkn's full-sized avatar
🐔
hacking away!

Alex Corrado chkn

🐔
hacking away!
View GitHub Profile
@chkn
chkn / JSON.cs
Last active November 17, 2019 15:17
// Now with more love at:
// https://github.com/chkn/JSON.cs/blob/master/JSON.cs
static class Extensions {
#if __IOS__
public static Font ToFont (this UIKit.UIFont font)
{
return Font.OfSize (font.Name, font.PointSize);
}
#endif
}
@chkn
chkn / LocalCache.cs
Last active December 21, 2015 02:39
Xamarin async gems
public static class LocalCache {
static HashSet<string> tempKeys = new HashSet<string> ();
public static Task<Stream> GetCachedOrDownload (string key, Uri uri, bool temporary = true)
{
return GetCachedOrDownload (key, uri, CreateNativeHttpClient, temporary);
}
public static Task<Stream> GetCachedOrDownload (string key, Uri uri, Func<HttpClient> createHttpClient, bool temporary = true)
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Android.OS;
using Android.App;
using Android.Content;
public static class AndroidExtensions {
static BinaryFormatter binaryFormatter;
@chkn
chkn / mtouch
Created April 15, 2012 06:05
Enable IL instrumentation in MonoTouch
#!/bin/bash -e
# This mtouch wrapper adds an argument for a "postcompile" command to be run
# after the managed code is compiled to IL but before it is compiled to native code.
#
# It may be passed as "Additional mtouch arguments" in MD like so:
#
# -postcompile "mono ${SolutionDir}/postcompiler.exe ${TargetPath}"
#
# To use, rename mtouch to mtouch_real and put this script in its place.
@chkn
chkn / JsonReader.cs
Created August 12, 2011 23:51
Super easy .NET 4 JSON parser
//
// JsonReader.cs
// Copyright 2011 Alexander Corrado
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
open System
open System.Collections.Generic
type Foo() =
let list = List<obj>()
member x.List = list
type Bar() =
let doSomething (foo : Foo) =
let inner() =
After about a year in the making for MimeKit and nearly 8 months for MailKit,
they've finally reached 1.0 status.
I started really working on MimeKit about a year ago wanting to give the .NET
community a top-notch MIME parser that could handle anything the real world could
throw at it. I wanted it to run on any platform that can run .NET (including mobile),
and do it with remarkable speed and grace. I wanted to make it such that re-serializing
the message would be a byte-for-byte copy of the original, so that no data would
ever be lost. This was also very important for my last goal, which was to support
S/MIME and PGP.
@chkn
chkn / DI.cs
Last active August 29, 2015 14:01
A simple stab at a dependency injector
using System;
using System.Text;
using System.Linq;
using System.Threading;
using System.Reflection;
using System.Collections.Generic;
using System.ComponentModel;
public static class DI {
@chkn
chkn / monobt.py
Last active August 29, 2015 13:55
import lldb
def monobt(debugger, command, result, dict):
target = debugger.GetSelectedTarget()
process = target.GetProcess()
thread = process.GetSelectedThread()
for frame in thread:
pc = str(frame.GetPCAddress())
if pc[0] == '0':
try: