Skip to content

Instantly share code, notes, and snippets.

View asimmon's full-sized avatar

Anthony Simmon asimmon

View GitHub Profile
@asimmon
asimmon / decorator.ts
Created September 7, 2021 13:57
Screeps profiler in TypeScript
import profiler from './screeps-profiler';
export function profile(target: Function): void;
export function profile(target: object, key: string | symbol, _descriptor: TypedPropertyDescriptor<Function>): void;
export default function profile(target: object | Function, key?: string | symbol, _descriptor?: TypedPropertyDescriptor<Function>): void {
if (typeof profiler === 'undefined') {
return;
}
if (key) {
@asimmon
asimmon / zendesk-comment-permalinks.user.js
Last active October 18, 2019 18:07
Zendesk Comment Permalinks UserScript
@asimmon
asimmon / bbpr.user.js
Last active July 8, 2022 15:44
Bitbucket PR comment navigator
// ==UserScript==
// @name Better Bitbucket Pull Requests
// @namespace GSoft
// @author Anthony Simmon
// @version 1.0.0
// @match https://bitbucket.org/*/pull-requests/*
// @match https://bitbucket.org/*/branch/*
// ==/UserScript==
function BBPR_App () {
@asimmon
asimmon / demo-pillar-viewmodel.cs
Created March 3, 2016 04:35
Demo ViewModel for Pillar that uses the navigation system
public class FirstViewModel : PillarViewModelBase
{
private readonly INavigator _navigator;
public FirstViewModel(INavigator navigator)
{
_navigator = navigator;
// Go to the second view after 5 seconds
GoToSecondViewModel();
@asimmon
asimmon / demo-pillar-bootstrapper.cs
Created March 3, 2016 04:31
Sample bootstrapper class for Pillar
public class MyAppBootstrapper : PillarBootstrapper
{
private readonly Application _app;
public MyAppBootstrapper(Application app)
{
_app = app;
}
protected override void ConfigureContainer(ContainerBuilder builder)
@asimmon
asimmon / nginx-rproxy-kestrel.conf
Created February 9, 2016 01:54
Nginx configuration for reverse proxying Kestrel
server {
# Port and domain
listen 80;
server_name aspnet.local;
# Path to the wwwroot folder
root /home/developer/projects/WebApplicationBasic/wwwroot;
# Static content
location ~ \.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm|woff2|svg)$ {
@asimmon
asimmon / eventtocommand-xamarin-forms-src-2.cs
Created November 20, 2015 15:59
EventToCommand Xamarin Forms - BindableBehavior Source
public class BindableBehavior<T> : Behavior<T> where T : BindableObject
{
public T AssociatedObject { get; private set; }
protected override void OnAttachedTo(T visualElement)
{
base.OnAttachedTo(visualElement);
AssociatedObject = visualElement;
@asimmon
asimmon / eventtocommand-xamarin-forms-src-behavior.cs
Last active January 17, 2016 17:21
EventToCommand Xamarin Forms - Behavior Source
public class EventToCommandBehavior : BindableBehavior<View>
{
public static readonly BindableProperty EventNameProperty = BindableProperty.Create<EventToCommandBehavior, string>(p => p.EventName, null);
public static readonly BindableProperty CommandProperty = BindableProperty.Create<EventToCommandBehavior, ICommand>(p => p.Command, null);
public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create<EventToCommandBehavior, object>(p => p.CommandParameter, null);
public static readonly BindableProperty EventArgsConverterProperty = BindableProperty.Create<EventToCommandBehavior, IValueConverter>(p => p.EventArgsConverter, null);
public static readonly BindableProperty EventArgsConverterParameterProperty = BindableProperty.Create<EventToCommandBehavior, object>(p => p.EventArgsConverterParameter, null);
private Delegate _handler;
private EventInfo _eventInfo;
@asimmon
asimmon / eventtocommand-xamarin-forms-example-view.xaml
Last active November 20, 2015 15:57
EventToCommand Xamarin Forms - Example View
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:b="clr-namespace:HelloEventToCommand.Behaviors;assembly=HelloEventToCommand" xmlns:c="clr-namespace:HelloEventToCommand.Converters;assembly=HelloEventToCommand" x:Class="HelloEventToCommand.Views.HomeView">
<ContentPage.Resources>
<ResourceDictionary>
<c:ItemTappedEventArgsConverter x:Key="ItemTappedConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ListView ItemsSource="{Binding People}">
<ListView.Behaviors>
@asimmon
asimmon / eventtocommand-xamarin-forms-example-ea-converter.cs
Created November 20, 2015 15:56
EventToCommand Xamarin Forms - Exempe EventArgs Converter
public class ItemTappedEventArgsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var eventArgs = value as ItemTappedEventArgs;
if (eventArgs == null)
throw new ArgumentException("Expected TappedEventArgs as value", "value");
return eventArgs.Item;
}