Skip to content

Instantly share code, notes, and snippets.

View cmorgado's full-sized avatar

Cristóvão Morgado cmorgado

  • Vila do Conde , Portugal
View GitHub Profile
@cmorgado
cmorgado / commongPlutus.hs
Created December 13, 2022 09:57
Common Cardano Plutus needs
-- This gist is a collection of commonly needed cardano plutus functions for validation scripts
--
/// transform any sync code to async
/// Nice when your implementing an Interface that is "async" but your implementation is no so async
public class AsyncUtils
{
public static Task<T> FromResultAsync<T>(T result)
{
var tcs = new TaskCompletionSource<T>();
tcs.SetResult(result);
return tcs.Task;
}
@cmorgado
cmorgado / ScrollToLeftGridViewBehavior.cs
Created October 10, 2014 10:28
Behavior Scroll to the last GridviewItem when you change the ItemsSource
public class ScrollToLeftGridViewBehavior : DependencyObject, IBehavior
{
public DependencyObject AssociatedObject { get; private set; }
public object ItemsSource
{
get { return (object)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
@cmorgado
cmorgado / converters.xaml
Created September 27, 2014 10:28
Cimbalino Converters Resource file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:CimbalinoConverters="using:Cimbalino.Toolkit.Converters"
>
<CimbalinoConverters:BooleanToBrushConverter x:Key="BooleanToBrushConverter" />
<CimbalinoConverters:BooleanToIntConverter x:Key="BooleanToIntConverter" />
<CimbalinoConverters:BooleanToStringConverter x:Key="BooleanToStringConverter" />
<CimbalinoConverters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
@cmorgado
cmorgado / DataProtectionExtensions.cs
Created September 26, 2014 22:36
Universal Apps : protect all data you store on settings, etc etc
using System;
using System.Threading.Tasks;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.DataProtection;
namespace CMM.Extensions
{
@cmorgado
cmorgado / RelayRT.snippet
Created September 26, 2014 22:29
VS2013 Snippet to easily create your RelayCommand using MVVM Light
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>relrt</Title>
<Author>Cristovao Morgado</Author>
<Description>Code snippet for an automatically implemented Relaycommands
@cmorgado
cmorgado / CommandOnEnterPress.cs
Created September 26, 2014 22:25
Universal App Behavior: press enter on texbox and execute your command
/// <summary>
/// <Interactivity:Interaction.Behaviors>
/// <MoreBehaviors:CommandOnEnterPress Command="{Binding DoYourCommand}" />
/// </Interactivity:Interaction.Behaviors>
/// </summary>
[Microsoft.Xaml.Interactivity.TypeConstraint(typeof(TextBox))]
class CommandOnEnterPress : DependencyObject, IBehavior
{
[Microsoft.Xaml.Interactivity.CustomPropertyValueEditor(Microsoft.Xaml.Interactivity.CustomPropertyValueEditor.PropertyBinding)]
@cmorgado
cmorgado / CommandOnEnterPressFocus.cs
Created September 26, 2014 22:23
Universal App behavior ... press enter to move focus to desired control
/// <summary>
/// <Interactivity:Interaction.Behaviors>
/// <MoreBehaviors:CommandOnEnterPressFocus Target="{Binding ElementName=yourothercontrol}" />
/// </Interactivity:Interaction.Behaviors>
/// </summary>
[Microsoft.Xaml.Interactivity.TypeConstraint(typeof(TextBox))]
class CommandOnEnterPressFocus : DependencyObject, IBehavior
{
public Windows.UI.Xaml.DependencyObject AssociatedObject { get; set; }
@cmorgado
cmorgado / resources.tt
Created September 26, 2014 22:19
Create a strongly type class to access your resw
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="System.Xml.Linq" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="System.Xml.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="Microsoft.CSharp" #>
@cmorgado
cmorgado / string.tt
Created September 26, 2014 22:15
Transforms strings.xml into resw for Windows App
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="System.Xml.Linq" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="System.Xml.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="Microsoft.CSharp" #>