Skip to content

Instantly share code, notes, and snippets.

View sthewissen's full-sized avatar
🤷‍♂️
Developing tings.

Steven Thewissen sthewissen

🤷‍♂️
Developing tings.
View GitHub Profile
@sthewissen
sthewissen / RouteDataExtensions.cs
Last active July 23, 2018 05:02
Extension method for getting Route data in ASP.NET MVC Razor pages
public static class RouteDataExtensions
{
// Usage can be seen here: http://www.dvolve.org/2016/01/getting-route-data-in-asp-net-razor/
public static bool Contains(this RouteData route, string action = null, string controller = null, string area = null, StringComparison comparison = StringComparison.CurrentCultureIgnoreCase)
{
// Get the parts that we'll check.
var areaToCheck = route.DataTokens["Area"];
var actionToCheck = route.Values.ContainsKey("Action") ? route.Values["Action"] : null;
var controllerToCheck = route.Values.ContainsKey("Controller") ? route.Values["Controller"] : null;
@sthewissen
sthewissen / CustomFontLabelRenderer.cs
Last active February 15, 2016 10:41
Renders a label using a custom font, as described @ http://bit.ly/20yzZ7i
using System;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using Android.Graphics;
[assembly:ExportRenderer(typeof(Label), typeof(CustomFontLabelRenderer))]
namespace CustomXamFormsFont.Droid
{
public class CustomFontLabelRenderer : LabelRenderer
{
@sthewissen
sthewissen / CustomFontsAppDelegate.cs
Last active February 15, 2016 10:42
Loop through the fonts on iOS to find the internal name as described @ http://bit.ly/20yzZ7i
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace CustomXamFormsFont.iOS
{
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage Title="Login" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyProject.LoginPage">
<Grid Padding="20" HorizontalOptions="CenterAndExpand" AutomationId="LoginPageIdentifier">
<Entry AutomationId="FullNameTextField" Keyboard="Text" Text="{Binding Fullname}" />
<Entry AutomationId="EmailTextField" Keyboard="Email" Text="{Binding Email}" />
<Button AutomationId="SignInButton" Text="Send" Command="{Binding LoginCommand}" />
</Grid>
</ContentPage>
@sthewissen
sthewissen / LoginPage.cs
Last active June 9, 2016 20:17
LoginPage UI tests for Xamarin
public class LoginPage : BasePage
{
readonly string SignInButton = "SignInButton";
readonly string EmailField = "EmailTextField";
readonly string FullNameField = "FullNameTextField";
public LoginPage() : base("LoginPageIdentifier", "LoginPageIdentifier")
{
}
@sthewissen
sthewissen / AppDelegate.cs
Last active June 9, 2016 20:15
Piece of startup code for Xamarin Test Cloud UI testing - iOS
void SetupTestCloud()
{
// Code for starting up the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
Xamarin.Calabash.Start();
//Mapping AutomationId to iOS Labels
Forms.ViewInitialized += (object sender, ViewInitializedEventArgs e) =>
{
if (null != e.View.AutomationId)
@sthewissen
sthewissen / MainActivity.cs
Last active June 9, 2016 20:15
Piece of startup code for Xamarin Test Cloud UI testing - Android
void SetupTestCloud()
{
// Code for starting up the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
Xamarin.Forms.Forms.ViewInitialized += (object sender, Xamarin.Forms.ViewInitializedEventArgs e) => {
if (!string.IsNullOrWhiteSpace(e.View.AutomationId))
{
e.NativeView.ContentDescription = e.View.AutomationId;
}
};
@sthewissen
sthewissen / Sample.nuspec
Created August 8, 2016 14:49
Rebex sample nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Rebex.2016-R2</id>
<version>1.0.1</version>
<title>Rebex 2016-R2</title>
<authors>Steven Thewissen</authors>
<owners>Rebex</owners>
<iconUrl>https://somefancything.com/rebex.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
@sthewissen
sthewissen / nuget.config
Last active August 8, 2016 19:18
A nuget config connecting to a custom feed
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- remove any machine-wide sources with <clear/> -->
<clear />
<!-- add a Team Services feed -->
<add key="MyFeed" value="https://myfeed.pkgs.visualstudio.com/DefaultCollection/_packaging/MyFeed/nuget/v3/index.json" />
<!-- also get packages from the NuGet Gallery -->
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
@sthewissen
sthewissen / Constants.cs
Last active June 20, 2017 14:03
Constants used for YouTube embed sample
// Get your API Key @ https://console.developers.google.com/apis/api/youtube/
const string ApiKey = "AIzaSyB2Hu4D97zOB8f410cwT2rCc6JnmwoLCAo";
const string ChannelId = "{PUT YOUR API KEY HERE}";
// Documentation @ https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list
string channelUrl = $"https://www.googleapis.com/youtube/v3/search?part=id&maxResults=20&channelId={ChannelId}&key={ApiKey}";
string detailsUrl = "https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&key=" + ApiKey + "&id={0}";