Skip to content

Instantly share code, notes, and snippets.

View codemillmatt's full-sized avatar

Matt Soucoup codemillmatt

View GitHub Profile
@codemillmatt
codemillmatt / AkaConsumer.cs
Created March 21, 2016 16:09
Akavache Sample From Akavache Is AKA Awesome Blog
public class App : Application
{
AkaConsumer consumer;
public App()
{
// The root page of your application
consumer = new AkaConsumer();
var contentLabel = new Label() { HorizontalTextAlignment = TextAlignment.Center };
@codemillmatt
codemillmatt / NavigationService.cs
Last active April 16, 2016 00:27
Xamarin Forms VM First Nav - Passing Parameters
public async Task PushAsync<T>(Action<T> initialize = null) where T : BaseViewModel
{
T viewModel;
// First instantiate the view model
// "IoC" is a static AutoFac IContainer property in the main Xam Forms Application class
using (var scope = App.IoC.BeginLifetimeScope ()) {
viewModel = App.IoC.Resolve<T> ();
if (initialize != null)
@codemillmatt
codemillmatt / NavigationService.cs
Created August 3, 2016 00:57
Using view-model first navigation, pop the current view from the stack and then call an initialization function on the next view model that's about to be shown.
public async Task PopAsync<T>(Action<T> reInitialize = null) where T : BaseViewModel
{
await PopAsync();
var topPage = FormsNavigation.NavigationStack.Last() as IViewFor<T>;
if (topPage != null)
reInitialize?.Invoke(topPage.ViewModel);
}
@codemillmatt
codemillmatt / NavigationService.cs
Last active August 25, 2016 11:09
Example of how to pop to an arbitrary page within the navigation stack using view model first navigation
public void PopTo<T>() where T : BaseViewModel
{
var pagesToRemove = new List<Page>();
var upper = FormsNavigation.NavigationStack.Count - 1;
// Loop through the nav stack backwards
for (int i = upper; i >= 0; i--)
{
var currentPage = FormsNavigation.NavigationStack[i] as IViewFor;
@codemillmatt
codemillmatt / XamlCompile.md
Last active December 13, 2016 20:03
XAML Compilation Include & Skip

To compile XAML

This should be in the PCL's AssemblyInfo.cs

using Xamarin.Forms.XAML;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

To selectively skip XAML compilation

This will be in the code behind of the XAML page

@codemillmatt
codemillmatt / FriendlyThickness.cs
Created July 10, 2017 11:31
Xamarin.Forms Markup Extension Example
[ContentProperty("FriendlyName")]
public class FriendlyThickness : IMarkupExtension
{
public FriendlyThickness()
{
}
public string FriendlyName { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
@codemillmatt
codemillmatt / README.md
Last active August 16, 2018 18:17
Everything You Always Wanted To Know About Machine Learning ... But Were Too Afraid To Ask

Always Wanted To Know About Machine Learning ... But Were Too Afraid To Ask

Abstract

Classification algorithms, supervised learning, neural networks, generative models, and multivariate linear regression! The terminology of machine learning can be intimidating... then you get to the math. Machine learning doesn't need to live in the halls of academia however, and this session aims to answer some of the questions you have about machine learning. In this session, you'll see how to use generic algorithms to make "intelligent" predictions about sets of data. How that algorithm can be reused across domains, to predict entirely different scenarios. Then we'll get into the fun stuff, using deep learning to recognize objects. You'll also learn where machine learning can fall short and when it can produce less than desirable results. And you'll also see that sometimes we have no idea how the machine gets the answer ... it just does! By the end of this session, you'll have a foundational level of understanding

@codemillmatt
codemillmatt / moviereview.json
Created September 4, 2018 17:17
Movie Review
{
"id": "f58f93de-4f3c-464c-a72f-61c770c870ef",
"movieName": "Ant Man and the Wasp",
"starRating": 2,
"reviewText": "I'm embarassed I even watched the trailer.",
"isPremium": true
}
[FunctionName("MovieReviewPermission")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req,
[DocumentDB(databaseName: "moviereview-db", collectionName: "reviews", ConnectionStringSetting = "CosmosConnectionString")] DocumentClient client,
TraceWriter log)
string userId = GetUserId(log);
Permission token = await GetPartitionPermission(userId, client, dbName, collectionName);
return req.CreateResponse<string>(HttpStatusCode.OK, token.Token);