Skip to content

Instantly share code, notes, and snippets.

View deurell's full-sized avatar

Mikael Deurell deurell

View GitHub Profile
import SwiftUI
struct GameMetricsView: View {
@Environment(\.colorScheme) var colorScheme
var gameMode: String
var totalPlays: Int
@Binding var totalAverage: Double
@State private var animatedTotalAverage: Double = 0.0
@deurell
deurell / ConfettiView.swift
Created July 21, 2023 09:20
SwiftUI confetti effect.
//
// ConfettiView.swift
// Glosify
//
// Created by Mikael Deurell on 2023-07-21.
//
import Foundation
import SwiftUI
@deurell
deurell / scroller.asm
Created April 23, 2017 15:49
6510 scroller
BasicUpstart2(start)
* = $1000
start:
sei
lda #$7f
sta $dc0d
sta $dd0d
lda #$01
sta $d01a
@deurell
deurell / gist:10f4108d0aff5e97e70d
Created May 10, 2015 08:46
WinRT string conversion
std::wstring StringConverter::StringToWideString(const std::string& s) {
int len = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), s.length(), NULL, 0);
std::wstring ws(L"", len);
wchar_t* pWSBuf = const_cast<wchar_t*>(ws.c_str());
MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, pWSBuf, len);
return ws;
}
std::string StringConverter::WideStringToString(const std::wstring& ws) {
int len = WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.length(), 0, 0, NULL, NULL);
@deurell
deurell / win10-convert.ps1
Last active August 29, 2015 14:20
project file conversion utility
# project file conversion utility
param (
[string]$folderPath = $(throw "-folderPath is required.")
)
$allProjectFiles = get-childitem -path $folderPath -Filter *.vcxproj -Recurse
foreach ($projectFile in $allProjectFiles){
$projectFileContent = get-content $projectFile.FullName
$projectFileContent |
public static IReadOnlyCollection<TItem> GetAllItems<TItem>(this IViewStorageReader viewStorage, string keyForListOfKeys, Logger logger, string typeOfItems, uint batchSize = 200)
where TItem : class
{
return GetAllItems<TItem, IEnumerable<string>>(viewStorage, keyForListOfKeys, logger, l => l.ToList(), typeOfItems, batchSize: batchSize);
}
// Fire command and validate mediator
[Test(Description = "Executing DisplayArticlesViewCommand sends message with products articles [Mikael Deurell]")]
public void Executing_DisplayArticlesViewCommand_SendsDisplayArticleViewListWithProvidedArticles()
{
// Given the user wants to display selected articles in a dialogue view
var sut =
new ProductViewModel(new Product("1", "desc", ProductType.Assortment, "10", "10", _dummyArticles, null,
0));
int notify = 0;
ObservableCollection<ArticleViewModel> articlesReceived = null;
// Fire Command
[Test(Description = "Added product shows up in repository with correct savestate")]
public void ExecutingCreateProductCommand_WithNewProduct_ShowsUpInRepository()
{
// Given the user wants to create a new product on the Create Product View
var product = new Product("4242", "desc", ProductType.Assortment, "201001", "123", _dummyArticles, null,
1);
// When the user clicks the New button a CreateProductCommand is fired on the ViewModel
var viewModel = new ProductViewModel(product);
// Validate fired event
[Test(Description = "Verify that prop changed fires [Mikael Deurell]")]
public void Description_Changed_FiresPropertyChanged()
{
// Given the user wants to change the product description on a Product
int notify = 0;
var sut = new ProductViewModel();
sut.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals("Description"))
<UserControl x:Class="ColourLab.IndividualColourView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="controlRoot">
<StackPanel>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="StackPanel.MouseEnter">
<BeginStoryboard Name="GoUp" HandoffBehavior="Compose">
<Storyboard>
<Int32Animation Storyboard.TargetName="controlRoot" Storyboard.TargetProperty="ColourWidth" To="100" Duration="0:0:0.6"
AccelerationRatio="0.1" DecelerationRatio="0.9" />
</Storyboard>
</BeginStoryboard>