Skip to content

Instantly share code, notes, and snippets.

View mmierzwa's full-sized avatar
🎯
Focusing

Marek Mierzwa mmierzwa

🎯
Focusing
View GitHub Profile
@mmierzwa
mmierzwa / falsehoods-programming-time-list.md
Created March 6, 2024 13:14 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
schema {
query: Query
mutation: Mutation
}
type Query {
session(id: ID!): Session
}
type Mutation {
@mmierzwa
mmierzwa / main.go
Created March 13, 2019 10:05
timeout and synchronization
package main
import (
"context"
"fmt"
"math/rand"
"time"
)
const timeout = time.Second
name: $(Date:yyyyMMdd).dev$(Rev:.r)
variables:
SolutionFileName: 'Please change the solution name.sln'
SolutionName: 'Please change the solution name'
MSBuildPath: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe'
UnityPath: 'C:\Program Files\Unity\Hub\Editor\2017.4.14f1\Editor\Unity.exe'
trigger:
branches:
@mmierzwa
mmierzwa / DeviceThreadDispatcher.cs
Created July 23, 2018 09:22
Example usage of `TaskCompletionSource`
public class DeviceThreadDispatcher : IThreadDispatcher
{
private static int _uiThreadId;
public bool IsOnUiThread => Environment.CurrentManagedThreadId == _uiThreadId;
public static void Initialize(int uiThreadId) => _uiThreadId = uiThreadId;
public T RequestMainThreadAsyncOperation<T>(Func<Task<T>> operation)
{
@mmierzwa
mmierzwa / PullToRefreshLayoutRenderer.cs
Created February 23, 2018 08:14
PullToRefreshLayout on Android
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Android.Support.V4.Widget;
using Android.Views;
using System.Reflection;
using System.ComponentModel;
using Android.Gms.Maps;
using Android.OS;
using View = Android.Views.View;
@mmierzwa
mmierzwa / PlaceholderEditorRenderer.cs
Last active February 5, 2018 06:06
Placeholder text in Xamarin.Forms Editor
using System;
using Cirrious.FluentLayouts.Touch;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(PlaceholderEditor), typeof(PlaceholderEditorRenderer))]
namespace EditorWithPlaceholder.iOS.Renderers
{
@mmierzwa
mmierzwa / PlacehoderEditorRenderer.cs
Last active June 12, 2017 09:21
Placeholder text in Xamarin.Forms Editor
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(PlaceholderEditor), typeof(PlaceholderEditorRenderer))]
namespace EditorWithPlaceholder.Droid.Renderers
{
public class PlacehoderEditorRenderer : EditorRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
@mmierzwa
mmierzwa / PlaceholderEditor.cs
Last active July 10, 2017 10:01
Placeholder text in Xamarin.Forms Editor
using Xamarin.Forms;
namespace EditorWithPlaceholder
{
public class PlaceholderEditor : Editor
{
public static BindableProperty PlaceholderProperty
= BindableProperty.Create(nameof(Placeholder), typeof(string), typeof(PlaceholderEditor));
public static BindableProperty PlaceholderColorProperty
@mmierzwa
mmierzwa / LoginCheckAppStart.cs
Last active April 24, 2017 08:16
Cleaning ADAL token cache on Android and iOS
public class LoginCheckAppStart : MvxNavigatingObject, IMvxAppStart
{
private readonly IApplicationSettings _applicationSettings;
private readonly ISecureStorageService _secureStorage;
public LoginCheckAppStart(IApplicationSettings applicationSettings, ISecureStorageService secureStorage)
{
_applicationSettings = applicationSettings;
_secureStorage = secureStorage;
}