Skip to content

Instantly share code, notes, and snippets.

View joacar's full-sized avatar

Joakim Lindh joacar

View GitHub Profile
using System.ComponentModel;
using Android.App;
using Clistr.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
#if __APPCOMPAT__
using NavigationRenderer = Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer;
using Toolbar = Android.Support.V7.Widget.Toolbar;
#else
using NavigationRenderer = Xamarin.Forms.Platform.Android.NavigationRenderer;
namespace Main
{
public partial class MainView : MasterDetailPage
{
public MainView()
{
InitializeComponent();
Detail = new NavigationPage(new StartView())
{
@joacar
joacar / BindablePicker.cs
Created August 4, 2016 12:27
BindablePicker for Xamarin.Forms that handles Add, Remove, Reset,Clear and Move actions.
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using Xamarin.Forms;
namespace Clistr.Controls
{
public class BindablePicker : Picker
{
@joacar
joacar / DbContextFactoryOfT.cs
Created May 17, 2017 08:43
Base class to configure and create instances of DbContext
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Configuration;
using System;
namespace CareBreeze.Data
{
public abstract class DbContextFactory<T> : IDbContextFactory<T> where T : DbContext
{
public string BasePath { get; protected set; }
@joacar
joacar / t-sql.sql
Created February 22, 2018 10:05
Import data into SQL from Google Spreadsheet or Microsoft Excel
-- Split string Table-Valued function
CREATE FUNCTION SplitString
(
@Input NVARCHAR(MAX),
@Character CHAR(1)
)
RETURNS @Output TABLE (
Item NVARCHAR(1000)
)
AS
@joacar
joacar / deploy.sh
Last active February 23, 2018 09:44
Script to copy content from VSTS Agent release artificat to web folder
#!/bin/bash
dir=/var/<app>
src=/home/user/vstsagent/_work/r1/a/<app>/drop/<app>.zip
service=<app>.service
# Clear directory
echo "Remove content from '$dir'"
rm -r $dir >> /dev/null
@joacar
joacar / Program.cs
Last active June 5, 2018 11:27
Operation MediatR pipeline
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
namespace TestingMediatR
{
/// <summary>
@joacar
joacar / PartialSetSlicer.cs
Created June 20, 2018 08:05
Accomodate for missing values when rendering a portion of a data set with e.g. Google Pie Chart
/// <summary>
/// Model to work with a subset of a set and render charts and graphs correctly.
/// </summary>
public class PartialSetSlicer
{
/// <summary>
/// Construct a <see cref="PartialSetSlicer" /> with <see cref="Threshold" /> set to the distribution of the last element.
/// </summary>
/// <param name="set">Data set.</param>
/// <param name="size">Size for subset.</param>
@joacar
joacar / Add-Migration.bat
Last active June 28, 2018 17:14
dotnet ef command line helper files
@echo off
if "%~1"=="" (
set /p "migration=Migration name is required. Enter name: "
)
if "%migration%"=="" ( exit /b )
set "filepath=%~2"
REM Content file is just one line as "-c MyDdContext -p Path/To/Project.csproj -o Path/To/Migrations
@joacar
joacar / SqlBuildScripts.ps1
Last active October 19, 2018 13:56
Scripts for building database project in Visual Studio and generate DacPac to create update scripts
# "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
# "C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\"
# Taken from psake https://github.com/psake/psake
<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.