Skip to content

Instantly share code, notes, and snippets.

View dalexsoto's full-sized avatar

Alex Soto dalexsoto

View GitHub Profile
NSUrl url = new NSUrl (UPLOAD_LOCATION);
NSMutableUrlRequest request = new NSMutableUrlRequest (url);
request.HttpMethod = "POST";
{
// Unfortunately set_HTTPBodyStream isn't implemented in monotouch yet
Selector s = new Selector("setHTTPBodyStream:");
NSInputStream stream = new NSInputStream (random_file_path);
Messaging.void_objc_msgSend_IntPtr (request.Handle, s.Handle, stream.Handle);
@dalexsoto
dalexsoto / ObjectiveCParser.cs
Created November 8, 2011 15:42 — forked from kevinmcmahon/ObjectiveCParser.cs
An Objective C brute force parser from #monotouch irc
// no claim or warranty is made on this code
// it is very brute force
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
@dalexsoto
dalexsoto / MojoElement.cs
Created January 31, 2012 16:24
MojoDK MT.Dialog right aligned EntryElement
//
// Elements.cs: defines the various components of our view
//
// Author:
// Miguel de Icaza (miguel@gnome.org)
//
// Copyright 2010, Novell, Inc.
//
// Code licensed under the MIT X11 license
//
@dalexsoto
dalexsoto / gist:1739634
Created February 4, 2012 19:30
Active Directory Account Manager
using System.DirectoryServices.AccountManagement;
......
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, ADDomain))
{
var user = UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, ADDomain + "\\" + username);
var group = GroupPrincipal.FindByIdentity(pc, "Admins. del dominio");
var y = user.IsMemberOf(group);
var z = user.GetGroups().ToList();
//most of the non-declared variables here are at the class level - eg window is:
// UIWindow window
// etc.
window = new UIWindow (UIScreen.MainScreen.Bounds);
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;
@dalexsoto
dalexsoto / gist:1893318
Created February 23, 2012 15:33 — forked from nicwise/gist:1889882
Gestures on MT.D
public class BTPinchGestureRecognizer : UIPinchGestureRecognizer
{
public BTPinchGestureRecognizer(NSObject target, Selector action) : base(target, action)
{
ShouldReceiveTouch += (sender, touch) => {
//if (touch.View is UISlider || touch.View is MPVolumeView) return false;
return true;
};
@dalexsoto
dalexsoto / gist:2373563
Created April 13, 2012 03:58
C# function to get the string between 2 strings
//This function gets the string between 2 strings
//Usage
string myString = "<span>Joe Smith</span>";
string [] result = GetStringInBetween("<span>", "</span>", myString);
string output = result[0];
string next = result[1];
//Function
@dalexsoto
dalexsoto / gist:3506454
Created August 29, 2012 03:16
PSPDFKitGlobal
//////////////////////////////////////////
//// PSPDFKitGlobal.h //
//////////////////////////////////////////
public partial class PSPDFKitGlobal
{
private static PSPDFLogLevel _PSPDFLogLevel;
public static PSPDFLogLevel LogLevel
{
get
@dalexsoto
dalexsoto / gist:3539139
Created August 30, 2012 19:49 — forked from Krumelur/gist:3537539
CATransform3D
/// <summary>
/// Sets the anchor point and translates the view so that it stays in its current position.
/// Normally, changing the anchor point also adjusts the view's position.
/// </summary>
/// <param name='oView'>the view whose anchor point has to be modified</param>
/// <param name='oNewAnchorPoint'>the new anchor point</param>
public void SetAnchorPointAndTranslate(PointF oNewAnchorPoint )
{
UIView oView = this;
PointF oNewPoint = new PointF(oView.Bounds.Width * oNewAnchorPoint.X, oView.Bounds.Height * oNewAnchorPoint.Y);
@dalexsoto
dalexsoto / gist:3661457
Created September 6, 2012 23:42 — forked from nicwise/gist:3656362
utils class
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
using System.IO;
using MonoTouch.MessageUI;
using System.Threading;
using MonoTouch.ObjCRuntime;
using System.Globalization;
using System.Xml.Linq;