Skip to content

Instantly share code, notes, and snippets.

/*
DynamicMethod creation: 0.0053597000ms
LINQ expressions creation: 0.1050939000ms
DynamicMethod invocation: 0.0000474000ms
Expression invocation: 0.0000450000ms
MethodInfo invocation: 0.0002190000ms
Calls to reach even with MethodInfo:
DynamicMethod: 24.6899543379
List<string> buttons = new List<string>();
if (UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Rear))
{
hasPhoto = true;
buttons.Add("Take a photo");
}
hasExisting = true;
buttons.Add("Choose Existing");
@bojanrajkovic
bojanrajkovic / GCDTest.cs
Created June 19, 2012 22:58
A bit of fun with Grand Central Dispatch...
using System;
using System.Threading.Tasks;
using MonoMac.CoreFoundation;
using MonoMac.AppKit;
using System.Threading;
namespace GCDTest
{
class MainClass
{
@glennblock
glennblock / gist:2722523
Created May 18, 2012 00:57
Autofac dependency resolver and scope
public class AutofacApiDependencyResolver : AutofacDependencyScope, IDependencyResolver
{
private readonly ILifetimeScope _container;
public AutofacApiDependencyResolver(ILifetimeScope container) : base(container)
{
_container = container;
}
public IDependencyScope BeginScope()
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@anujb
anujb / gist:1976020
Created March 5, 2012 02:07
dispatch_sync task extensions pattern
public static class Db {
public static bool IsInitialized { get; private set; }
static SQLiteConnection _db;
static SyncTaskScheduler _syncScheduler;
public static void Initialize(string dbPath) {
if(IsInitialized) return;
@nicwise
nicwise / gist:1431457
Created December 4, 2011 22:13
threading stuff
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
Task.Factory.StartNew(() => {
Console.WriteLine ("ping");
Thread.Sleep(4000);
Console.WriteLine ("pong");
return "from the thread";
@mloenow
mloenow / MonoTouch.Utils.Extensions.cs
Created December 1, 2011 12:50
NSDictionary and NSArray dumping with extension methods
using System.Collections.Generic;
using System.Diagnostics;
using MonoTouch.Foundation;
namespace MonoTouch.Utils {
public static class Extensions {
public static string Dump(this NSDictionary dictionary, int level = 0) {
var dump = "";
@nicwise
nicwise / scale.cs
Last active November 13, 2018 08:17
Scale and Rotate an image in iOS / MonoTouch, using the EXIF data
//MIT license
public static UIImage ScaleImage(UIImage image, int maxSize)
{
UIImage res;
using (CGImage imageRef = image.CGImage)
{
CGImageAlphaInfo alphaInfo = imageRef.AlphaInfo;
@hgarcia
hgarcia / file0.cs
Created September 2, 2010 04:18
2008-01-20-css-parser-class-in--net.textile
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace LaTrompa.Web
{
public class CssParser