Skip to content

Instantly share code, notes, and snippets.

View YARG's full-sized avatar

YARG YARG

View GitHub Profile
@YARG
YARG / gist:d1f0aebf97390770c02464832abb1473
Created October 3, 2019 12:22
Get a certificate by thumbprint from the X509 certificate store
static X509Certificate2 GetCertificate(string thumbPrint)
{
List<StoreLocation> locations = new List<StoreLocation>
{
StoreLocation.CurrentUser,
StoreLocation.LocalMachine
};
foreach (var location in locations)
{
@YARG
YARG / gist:6ab928f53127e78bcf10
Last active May 28, 2018 19:42
C#/Xamarin iOS - Converts a UTC DateTime to the device local Time Zone as System.DateTime. Also includes functions to convert iOS native date times to System.DateTime and back again.
/// <summary>
/// Converts a UTC datestamp to the local timezone
/// </summary>
/// <returns>The UTC to local time zone.</returns>
/// <param name="dateTimeUtc">Date time UTC.</param>
public DateTime ConvertUTCToLocalTimeZone (DateTime dateTimeUtc)
{
NSTimeZone sourceTimeZone = new NSTimeZone ("UTC");
NSTimeZone destinationTimeZone = NSTimeZone.LocalTimeZone;
NSDate sourceDate = DateTimeToNativeDate (dateTimeUtc);
@YARG
YARG / gist:2b9a50abc9c3524d40fc
Last active January 15, 2020 14:15
C#/Xamarin Android - Converts a UTC DateTime to the device local Time Zone as System.DateTime. Also includes functions to convert Android native date times to System.DateTime and back again.
/// <summary>
/// Converts a UTC datestamp to the local timezone
/// </summary>
/// <returns>The UTC to local time zone.</returns>
/// <param name="dateTimeUtc">Date time UTC.</param>
public DateTime ConvertUTCToLocalTimeZone(DateTime dateTimeUtc) {
// get the UTC/GMT Time Zone
Java.Util.TimeZone utcGmtTimeZone = Java.Util.TimeZone.GetTimeZone ("UTC");
@YARG
YARG / gist:681f426b78af6d77baab
Created February 25, 2015 08:37
Simple PCL C# Timer class
using System;
using System.Threading;
using System.Threading.Tasks;
namespace YARG.Core.Utils
{
internal delegate void TimerCallback(object state);
internal sealed class Timer : CancellationTokenSource, IDisposable
{
@YARG
YARG / gist:2a45c15d7fa724cae458
Last active August 29, 2015 14:15
Simple SOAP call to retrieve a list of deleted Appointment IDs for a given Microsoft CRM user Id.
/// <summary>
/// Creates a SOAP payload to retrieve a list of deleted Appointment Ids for a given user
/// </summary>
/// <param name="userId">The GUID crm User Id</param>
/// <param name="dateFrom">From date</param>
/// <returns></returns>
private string CreateSoapPayloadForDeletedAppointments(string userId, string dateFrom)
{
StringBuilder sb = new StringBuilder();
@YARG
YARG / gist:984bab9f61d8d97e8e54
Last active August 29, 2015 14:15
Simple SOAP call to update the status of a Microsoft CRM 2011 entity. The organization service Url can be found by going into Microsoft CRM -> Customizations -> Developer Resources
public void MakeTestAppointmentUpdate()
{
string serviceUrl = "<your organization service endpoint>/web";
string userName = "username";
string password = "password";
string logicalEntityName = "appointment";
string activityId = "ba9f21c5-82ac-e411-95dc-005056be7c4c";