Skip to content

Instantly share code, notes, and snippets.

View dalexsoto's full-sized avatar

Alex Soto dalexsoto

View GitHub Profile
@dalexsoto
dalexsoto / HttpClientProgressExtensions.cs
Last active April 3, 2024 15:01
Add Progress reporting to capabilities to HttpClient
using System;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace HttpClientProgress {
public static class HttpClientProgressExtensions {
public static async Task DownloadDataAsync (this HttpClient client, string requestUrl, Stream destination, IProgress<float> progress = null, CancellationToken cancellationToken = default (CancellationToken))
{
@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();
@dalexsoto
dalexsoto / IsPalindrome.cs
Created February 3, 2020 01:37 — forked from davidfowl/IsPalindrome.cs
Works for surrogate pairs
static bool IsPalin(string s)
{
var bi = s.Length - 1;
foreach (var r in s.EnumerateRunes())
{
if (!Rune.TryGetRuneAt(s, bi - (r.Utf16SequenceLength - 1), out var b) || !r.Equals(b))
{
return false;
}
This file has been truncated, but you can view the full file.
d=DevsDNA.GettingStarted.XamarinForms
NuGetPackageVersion=1.0.0-beta
NuGetSourceType=Package
OriginalItemSpec=/Users/alex/.nuget/packages/devsdna.gettingstarted.xamarinforms/1.0.0-beta/lib/netstandard2.0/System.Security.Cryptography.Encoding.dll
PackageName=DevsDNA.GettingStarted.XamarinForms
PackageVersion=1.0.0-beta
Path=lib/netstandard2.0/System.Security.Cryptography.Encoding.dll
Private=false
ReferenceAssembly=/Users/alex/.nuget/packages/devsdna.gettingstarted.xamarinforms/1.0.0-beta/lib/netstandard2.0/System.Security.Cryptography.Encoding.dll
ReferenceSourceTarget=ResolveAssemblyReference
@dalexsoto
dalexsoto / Linker.xml
Created January 29, 2018 15:36
Xamarin.iOS System.ComponentModel.ReferenceConverter Newtonsoft.Json https://github.com/xamarin/xamarin-macios/issues/3144
<?xml version="1.0" encoding="UTF-8" ?>
<linker>
<assembly fullname="System">
<type fullname="System.ComponentModel.ReferenceConverter">
<method signature="System.Void .ctor(System.Type)" />
</type>
</assembly>
</linker>
@dalexsoto
dalexsoto / iterm2-solarized.md
Created May 8, 2017 13:37 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@dalexsoto
dalexsoto / EasyLayout.cs
Created March 5, 2017 16:19 — forked from praeclarum/EasyLayout.cs
EasyLayout makes writing auto layout code in Xamarin.iOS easier. See [the example](https://gist.github.com/praeclarum/8185036) for hints on how to use this library.
//
// Copyright (c) 2013-2015 Frank A. Krueger
//
// 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 the following conditions:
//
#!/usr/bin/env bash
#
# simple recursive search and replace string in files
# setup: alias replace='~/replace.sh'
# notes: you will need to escape special chars! eg: replace '\/dir1' '\/dir2' .
# usage: replace <oldstring> <newstring> <path> <depth>
# examples:
# replace "([^\s]+.php)" "\/\1" .
# replace "\"\/([^\/]+.php)" "\"\/dir\/\1" .
[Register ("MyComboBoxDelegate")]
public class MyComboBoxDelegate : NSTextFieldDelegate
{
[Export ("comboBoxSelectionDidChange:")]
void SelectionDidChange (NSNotification notification)
{
Console.WriteLine ("Changed");
}
@dalexsoto
dalexsoto / Monotouch SSL ignore trusted host.cs
Created November 6, 2012 16:10
add a host to the undocumented static trustedHosts property on NSURLConnection to ignore SSL validation failures
//add a host to the undocumented static trustedHosts property on NSURLConnection to ignore SSL validation failures
public class NSUrlExtensions
{
public static void AddTrustedHost (string trustedHost)
{
IntPtr classPtr_NSURLConnection = Class.GetHandle("NSURLConnection");
IntPtr sel_trustedHosts = Selector.GetHandle("trustedHosts");
IntPtr p = Messaging.IntPtr_objc_msgSend(classPtr_NSURLConnection, sel_trustedHosts);