Skip to content

Instantly share code, notes, and snippets.

View rasmuschristensen's full-sized avatar
💭
Working remotely

Rasmus Tolstrup Christensen rasmuschristensen

💭
Working remotely
View GitHub Profile
@rasmuschristensen
rasmuschristensen / main.dart
Created April 14, 2020 18:50
Tristate button animation
// MIT License
//
// Copyright (c) 2020 Rasmus Christensen
//
// Thanks to Simon Simon Lightfoot for inspiration.
//
// 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
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>NUnit Test Method</Title>
<Author>Rasmus Tolstrup Christensen</Author>
<Description>Code snippet for a test method</Description>
@rasmuschristensen
rasmuschristensen / ExistsAsync
Created August 18, 2019 13:53
CosmosDb Async Exists support
public static class ContainerExtensions
{
public static async Task<bool> ExistsAsync<T>(this Container container, Expression<Func<T,bool>> predicate)
{
var qdef = container.GetItemLinqQueryable<T>().Where(predicate).ToQueryDefinition();
var iterator = container.GetItemQueryIterator<T>(qdef.QueryText, null, new QueryRequestOptions { MaxItemCount = 1 });
if (!iterator.HasMoreResults) return false;
@rasmuschristensen
rasmuschristensen / appcenter-pre-build.sh
Created December 13, 2017 21:44
prebuild Appcenter script
#!/usr/bin/env bash
if [ "$APPCENTER_BRANCH" != "master" ];
then
echo "NOT Master"
else
echo "Is Master"
fi
@rasmuschristensen
rasmuschristensen / WrapPanelUsage
Created May 4, 2017 14:16
How to use WrapPanel
<ScrollView>
<appControls:WrapLayout
Margin="2"
VerticalOptions="FillAndExpand"
Spacing="6"
RowSpacing="10"
MaxColumns="3"
ItemsSource="{Binding Ads}"
x:Name="thelist">
<appControls:WrapLayout.ItemTemplate>
@rasmuschristensen
rasmuschristensen / AutoREST PS
Created December 9, 2016 22:29
A Powershell to autogenerate C# proxies from a swagger endpoint
$swaggerEndpoint = "http://localhost:9000/swagger/docs/v1"
$outputDirectory = "targetfolder"
$autoRestRelativePath = "..\..\packages\autorest.0.17.3\tools\AutoRest.exe"
& $autoRestRelativePath -Input $swaggerEndpoint -Namespace "com.myproject.Client.Proxies.targetfolder" -OutputDirectory $outputDirectory -CodeGenerator CSharp
private $TYPE$ _$name$;
public $TYPE$ $NAME$
{
get { return _$name$; }
set { SetProperty(ref _$name$, value); }
}
@rasmuschristensen
rasmuschristensen / WrapPanel
Last active May 4, 2017 17:11
Xamarin Forms WrapPanel raw 1st edition, not complete yet.....
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Xamarin.Forms;
namespace Controls.Bypassion.dk
{
public class WrapLayout : Layout<View>
{
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, UIWindow forWindow)
{
if (Xamarin.Forms.Application.Current == null || Xamarin.Forms.Application.Current.MainPage == null)
{
return UIInterfaceOrientationMask.Portrait;
}
var navigationPage = Xamarin.Forms.Application.Current.MainPage as NavigationPage;
public byte[] MakeGrayScale(byte[] imageAsBytes)
{
UIImage image = ImageFromByteArray(imageAsBytes);
var height = image.Size.Height;
var width = image.Size.Width;
var imageRect = new CGRect(0, 0, width, height);
using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero,
(int)width, (int)height, 8,