Skip to content

Instantly share code, notes, and snippets.

View MarcosCobena's full-sized avatar

Marcos Cobeña Morián MarcosCobena

View GitHub Profile
@MarcosCobena
MarcosCobena / file_packager_standalone.patch
Created November 15, 2019 12:46
Patch to make file_packager.py work standalone (Emscripten master 04d13b99d0630496139fa8f424c62aad65588c7b)
--- ../Repositorios/mono/sdks/builds/toolchains/emsdk/upstream/emscripten/tools/file_packager.py 2019-11-06 18:50:40.000000000 +0100
+++ file_packager.py 2019-11-15 11:26:57.394870824 +0100
@@ -69,13 +69,13 @@
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from tools.toolchain_profiler import ToolchainProfiler
-if __name__ == '__main__':
- ToolchainProfiler.record_process_start()
-
@MarcosCobena
MarcosCobena / DumpFS.cs
Created November 11, 2019 13:06
Dumps the entire FS under path —usefull while debugging MEMFS in Wasm
private static void Dump(string path)
{
if (!Directory.Exists(path))
{
return;
}
var dirs = Directory.GetDirectories(path);
foreach (var item in dirs)
@MarcosCobena
MarcosCobena / MacOSScreenshot.cs
Created August 28, 2018 10:37
A workaround to take screenshots under macOS when Gtk# crashes doing the same (https://github.com/mono/gtk-sharp/issues/236)
using System;
using System.Runtime.InteropServices;
using AppKit;
using CoreGraphics;
using Foundation;
using ImageIO;
using MobileCoreServices;
namespace ScreenshotDemo
{
@MarcosCobena
MarcosCobena / PollyRetryDemo.cs
Created April 2, 2018 06:26
Demo scenario using Polly's Retry policy
private RetryPolicy CreateRetryPolicy() => Policy.Handle<Exception>()
.WaitAndRetryAsync(
Enumerable.Range(0, 3)
.Select(_ => TimeSpan.FromSeconds(5))
.ToList());
[...]
var policy = CreateRetryPolicy();
TResult result;
@MarcosCobena
MarcosCobena / UserDefault.mdpolicy.xml
Last active January 5, 2018 10:30
My Visual Studio for Mac's editor policy
<!-- Located at: /Users/marcos/Library/VisualStudio/7.0/Policies/ -->
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<PolicySet name="User Default" id="UserDefault">
<DotNetNamingPolicy inheritsSet="Default" />
<TextStylePolicy inheritsSet="null" scope="text/x-csharp" />
<CSharpFormattingPolicy inheritsSet="Default" inheritsScope="text/x-csharp" scope="text/x-csharp" />
<VersionControlPolicy inheritsSet="Default" />
<TextStylePolicy inheritsSet="Default" inheritsScope="text/plain" scope="text/plain">
<FileWidth>120</FileWidth>
@MarcosCobena
MarcosCobena / DoubleToTopThicknessConverter.cs
Created November 29, 2017 16:51
How to implement an attached header view flowing on top of scrollable content in Xamarin.Forms
public class DoubleToTopThicknessConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double height;
try
{
height = (double)value;
}
@MarcosCobena
MarcosCobena / HandleLeftAndRightSwipeGestures.cs
Created October 30, 2017 15:12
A platform-independent implementation of left & right swipe gestures in Xamarin.Forms
void HandleLeftAndRightSwipeGestures(object sender, Xamarin.Forms.PanUpdatedEventArgs e)
{
    switch (e.StatusType)
    {
        case GestureStatus.Started:
            lastPanStartedX = e.TotalX;
            break;
        case GestureStatus.Running:
            lastPanRunningX = e.TotalX;
            break;
@MarcosCobena
MarcosCobena / AnimateFabAccordingOnScrollListener.cs
Created September 29, 2017 11:27
Custom Android's OnScrollListener to make FAB animate along with RecyclerView's scrolls
using FloatingActionMenu = Clans.Fab.FloatingActionMenu;
public class AnimateFabAccordingOnScrollListener : Android.Support.V7.Widget.RecyclerView.OnScrollListener
{
const int AnimationDuration = 150;
readonly FloatingActionMenu _fab;
int _lastY;
bool _fabTranslated;
readonly int _bottomBarHeight;
@MarcosCobena
MarcosCobena / Custom.mac-kb.xml
Last active January 5, 2018 10:26
My Xamarin Studio key bindings
<!-- Located at: /Users/marcos/Library/VisualStudio/7.0/KeyBindings/ -->
<schemes version="1.0">
<scheme name="current">
<binding command="MonoDevelop.Refactoring.RefactoryCommands.FindReferences" shortcut="Meta+'" />
<binding command="MonoDevelop.Refactoring.Navigation.FindDerivedSymbols" shortcut="Meta+¡" />
<binding command="MonoDevelop.Unity.Documentation.UnityDocumentation" shortcut="" />
<binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RunAllTests" shortcut="Meta+T" />
</scheme>
</schemes>
@MarcosCobena
MarcosCobena / WhicheverParentViewController.cs
Last active December 22, 2016 19:07
LayoutSubviews() needed for MyWrappingView to have dynamic height
public override void LayoutSubviews()
{
base.LayoutSubviews();
var availableWidth = _myWrappingView.Frame.Width;
_myWrappingView.SetPreferredMaxLayoutWidth((float)availableWidth);
base.LayoutSubviews();
}