Skip to content

Instantly share code, notes, and snippets.

@jstedfast
jstedfast / EmailValidator.cs
Created October 7, 2013 21:18
Email address validator
//
// EmailValidator.cs
//
// Author: Jeffrey Stedfast <[email protected]>
//
// Copyright (c) 2013 Xamarin Inc.
//
// 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
public static ImageInfo ReadPng (string fileName)
{
int w, h;
if (GetPngImageSize (fileName, out w, out h))
return new ImageInfo { FileName = fileName, Width = w, Height = h };
return new ImageInfo ();
}
public static ImageInfo ReadJpg (string fileName)
@jstedfast
jstedfast / gist:4119319
Created November 20, 2012 17:11
How to run a modal dialog & pump the main loop
IntPtr session = NSApplication.SharedApplication.BeginModalSession (window);
NSRunResponse result = NSRunResponse.Continues;
// Loop until some result other than continues:
while (result == NSRunResponse.Continues) {
using (var pool = new NSAutoreleasePool ()) {
// Run the window modally until there are no events to process:
result = (NSRunResponse) NSApplication.SharedApplication.RunModalSession (session);
// Give the main loop some time:
tell application "Xcode"
set theProject to first project
set theTarget to first target of theProject
set theBuildPhase to compile sources phase of theTarget
tell first group of theProject
set theFileRef to make new file reference with properties {full path:"/Users/fejj/Projects/XcodeTest/XcodeTest/MyViewController.h", name:"MyViewController.h", path:"XcodeTest/MyViewController.h", path type:group relative}
--add theFileRef to theProject
end tell
tell theBuildPhase to make new build file with properties {build phase:theBuildPhase, name:"MyViewController.h", file reference:theFileRef, target:theTarget, project:theProject}
end tell
@jstedfast
jstedfast / gist:1227424
Created September 19, 2011 19:57
Storyboard support patch
diff --git a/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs b/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs
index 3feb9b1..d47aebd 100644
--- a/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs
+++ b/main/src/addins/MonoDevelop.MacDev/XcodeSyncing/XcodeMonitor.cs
@@ -46,6 +46,7 @@ namespace MonoDevelop.MacDev.XcodeSyncing
class XcodeMonitor
{
FilePath originalProjectDir;
+ bool updating = false;
int nextHackDir = 0;
@jstedfast
jstedfast / gist:1220774
Created September 15, 2011 23:20
email address regex
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)