Skip to content

Instantly share code, notes, and snippets.

@fedemkr
fedemkr / LocationExtensions.cs
Last active September 8, 2020 21:54
Method extension to get a latitude, longitude Coordinates object of a location string formatted as ISO-6709 Annex H. See https://en.wikipedia.org/wiki/ISO_6709. This is used for example when getting metadata location on Xamarin Android using the MediaMetadataRetriever.
using System;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Utilities.Extensions
{
public static class LocationExtensions
{
/// <summary>
/// Retrieves latitude, longitude coordinates from a ISO-6709 standard string
@fedemkr
fedemkr / Del packages & bin & obj.workflow
Created April 9, 2019 17:02
Mac Automator script to delete all nuget packages in $Home/.nuget/packages and also the bin & obj folders of a C# solution
#!/bin/bash
nugetPackagesFolder="$HOME/.nuget/packages"
rm -r `find $nugetPackagesFolder -type d -not -path $nugetPackagesFolder
`
constrainedPath="$HOME/Documents"
if [ -z $1 ] ; then
exit 1
elif [[ $1 != *$constrainedPath* ]]; then
@fedemkr
fedemkr / ImageAsCheckboxBehavior.cs
Created October 8, 2018 18:13
Xamarin forms behavior so any Image can act as a checkbox with two states which images can be set.
using Xamarin.Forms;
namespace MyNamespace.Forms.UI.Behaviors
{
public class ImageAsCheckboxBehavior : Behavior<Image>
{
// Members
private TapGestureRecognizer tapGestureRecognizer;
// Bindable properties
@fedemkr
fedemkr / TaskWithTimeoutWrapper.cs
Last active September 12, 2017 12:39
Wrapper to run a task with a custom timeout time and a cancellation token to be triggered if the time ends.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MyNamespace
{
public class TaskWithTimeoutWrapper
{
protected volatile bool taskFinished = false;