Skip to content

Instantly share code, notes, and snippets.

View codemillmatt's full-sized avatar

Matt Soucoup codemillmatt

View GitHub Profile
@codemillmatt
codemillmatt / switchstyle.xaml
Created March 4, 2020 19:28
Xamarin.Forms Styles for Switch On Color
<Style TargetType="Switch">
<Setter Property="OnColor" Value="Black" />
</Style>
@codemillmatt
codemillmatt / appcenterdatalist.cs
Created January 8, 2020 16:37
App Center Data List
// Tell app center you want the data in list form
var dbResult = await Data.ListAsync<UserInterests>(
DefaultPartitions.UserDocuments
);
var userInterests = new List<UserInterests>();
// deserialize the first page
userInterests.AddRange(dbResult.CurrentPage.Items.Select(i => i.DeserializedValue));
// check if there are additional pages
@codemillmatt
codemillmatt / appcenterdatasave.cs
Created January 8, 2020 16:28
App Center Data Save
await Data.CreateAsync<UserInterests>(newsCategory.CategoryName,
new UserInterests { NewsCategoryName = newsCategory.CategoryName },
DefaultPartitions.UserDocuments);
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"APIKey": "YOUR KEY WILL GO HERE",
"APIEndpoint": "https://westus2.api.cognitive.microsoft.com/"
}
}
@codemillmatt
codemillmatt / LetterDeliveryService.cs
Created December 9, 2019 21:54
Xamarin App Invoking Azure Function
public async Task<SantaResults> WriteLetterToSanta(SantaLetter letter)
{
SantaResults results = null;
try
{
var letterJson = JsonConvert.SerializeObject(letter);
var httpResponse = await httpClient.PostAsync(santaUrl, new StringContent(letterJson));
results = JsonConvert.DeserializeObject<SantaResults>(await httpResponse.Content.ReadAsStringAsync());
@codemillmatt
codemillmatt / writesanta.cs
Created December 9, 2019 21:42
Write Santa Function
[FunctionName("WriteSanta")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] SantaLetter theLetter,
ILogger log)
{
SantaResults result;
try
{
// Get the languages
@codemillmatt
codemillmatt / text-analytics-create.sh
Created December 9, 2019 21:14
Text Analytics Cognitive Services Account Create
az cognitiveservices account create \
--kind TextAnalytics \
--location westus2 \
--sku F0 \
--resource-group SantaTalk \
--name YOUR-SERVICE-NAME-HERE
@codemillmatt
codemillmatt / shellmenuitem.xaml
Created November 14, 2019 00:15
Shell Menu Item Example
<MenuItem>
<Shell.MenuItemTemplate>
<DataTemplate>
<StackLayout Padding="16,0,0,0" Orientation="Horizontal">
<Label FontFamily="{StaticResource SegMDL2}" Text="&#xECA5;" VerticalTextAlignment="Center" FontSize="18" TextColor="Red" />
<Label Text="Standard" FontSize="14" VerticalTextAlignment="Center"
Margin="17,0"/>
<Label FontFamily="{StaticResource SegMDL2}" Text="&#xE73E;"
Margin="0,0,20,0"
VerticalTextAlignment="Center" HorizontalOptions="EndAndExpand"
@codemillmatt
codemillmatt / multitoptabsflyout.xaml
Created November 14, 2019 00:14
Multiple top tabs in shell flyout
<FlyoutItem Title="The News">
<FlyoutItem.Icon>
<FontImageSource
Color="Red"
FontFamily="{StaticResource FabMDL2}"
Glyph="&#xE900;" />
</FlyoutItem.Icon>
<Tab Title="My News">
<ShellContent Title="My News">
<local:NewsCollectionPage Title="My News" />
@codemillmatt
codemillmatt / SingleFlyoutShell.xaml
Created November 14, 2019 00:14
Shell with Single Flyout Item
<FlyoutItem Title="My Interests">
<FlyoutItem.Icon>
<FontImageSource
Color="Red"
FontFamily="{StaticResource FabMDL2}"
Glyph="&#xE734;" />
</FlyoutItem.Icon>
<ShellContent>
<local:MyInterestsPage />
</ShellContent>