Skip to content

Instantly share code, notes, and snippets.

View programmation's full-sized avatar

David Dancy programmation

View GitHub Profile
@richlander
richlander / modernizing-csharp9.md
Last active April 26, 2024 17:14
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";
extension UIHostingController {
convenience public init(rootView: Content, ignoreSafeArea: Bool) {
self.init(rootView: rootView)
if ignoreSafeArea {
disableSafeArea()
}
}
func disableSafeArea() {
@praeclarum
praeclarum / ListDiff.cs
Created June 15, 2017 17:36
Implements generic list diffing
using System;
using System.Collections.Generic;
namespace Praeclarum
{
/// <summary>
/// The type of <see cref="ListDiffAction{S,D}"/>.
/// </summary>
public enum ListDiffActionType
{
@vwart
vwart / Example.cs
Last active March 14, 2017 23:49
This can be used to re-layout a Grid with star (*) rows within a ScrollView. For Xamarin Forms
//usage:
// ContactGrid is the x:Name of the Grid within the ScrollView
protected override void OnAppearing()
{
base.OnAppearing();
ContactGrid.LayoutStars(((float)App.INSTANCE.Resources["PageHeight"]));
}
//In your MainActivity:
module.exports = function(grunt) {
grunt.initConfig({
adminPassword: '',
solution: '',
versionNumber: grunt.option('versionNumber'),
buildAgent: grunt.option('buildAgent'),
@georgejecook
georgejecook / FastCell.cs
Created May 4, 2015 05:20
butter smooth performance in xamarin forms listview
using System;
using Xamarin.Forms;
namespace TwinEvents.Core.Media.View
{
public class FastCell : ViewCell
{
}
}
@ChaseFlorell
ChaseFlorell / GridView.cs
Last active August 6, 2017 23:53
Xamarin.Forms GridView
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
namespace TimeTracker.Controls
{
public class GridView : Grid
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using Xamarin.Forms;
namespace WrapPanelDemo.Controls
{
public class AwesomeWrappanel : Layout<View>
{
@kristopherjohnson
kristopherjohnson / DispatchGroupDemo.swift
Last active May 28, 2021 14:40
Simple demo of dispatch_group_async/dispatch_group_notify/dispatch_group_wait in Swift
import Foundation
let notified = dispatch_semaphore_create(0)
let group = dispatch_group_create()
let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
for n in 0..<20 {
dispatch_group_async(group, queue) {
let timeInterval = Double(arc4random_uniform(1000)) * 0.01
@praeclarum
praeclarum / MarkovChain.fs
Last active August 29, 2015 14:13
Markov Chain that learns by observing data.
/// Markov chain that learns by observing data.
/// Let it observe a sequence of states.
/// Then you can ask it, given a state,
/// what are the probabilities of the next states occuring?
/// This chain can remember history to make better predictions.
type MarkovChain (numStates : int, memory : int) =
let numPrevious = 1 + memory
let matrixSize = int (System.Math.Pow (float numStates, float numPrevious))