Skip to content

Instantly share code, notes, and snippets.

View richardszalay's full-sized avatar

Richard Szalay richardszalay

View GitHub Profile
@richardszalay
richardszalay / raix-interactive-basic.as
Created March 26, 2011 17:47
Basic raix.interactive example
var filteredAndMapped : IEnumerable = toEnumerable([1, 2, 3, 4, 5, 6, 7, 8, 9])
.filter(function(i:int):Boolean { return (i % 2) == 0); })
.map(function(i:int):String { return "It's value " + i; });
for each(var value : String in filteredAndMapped)
{
trace(value);
}
// Output:
@richardszalay
richardszalay / raix-reactive-basic.as
Created March 26, 2011 19:18
Basic raix.reactive example
var doubleClicks : IObservable = Observable.fromEvent(stage, MouseEvent.CLICK)
.timeInterval()
.filter(function(ti:TimeInterval):Boolean { return ti.interval < 300; })
.removeTimeInterval();
var subscription : ICancelable = doubleClicks.subscribe(function(me:MouseEvent):void
{
trace("Double click");
});
@richardszalay
richardszalay / SitecoreMvcEditFrame.cs
Last active April 13, 2017 04:32
Sitecore MVC EditFrame implementation
using Sitecore.Mvc.Helpers;
using Sitecore.Web.UI.WebControls;
using System;
using System.IO;
using System.Web.UI;
public static class SitecoreHelperExtensions
{
/// <summary>
/// Creates a scoped EditFrame
@richardszalay
richardszalay / wp-bluetooth-workaround-example.cs
Last active February 10, 2016 03:01
Works around a known platform issue whereby disconnecting a Bluetooth headset causes the audio to play through the loud speaker, even if the track is currently paused. Includes support for GDR2.
public class AudioPlayer
{
// Note "static" !
static readonly PlatformBluetoothIssueWorkaround bluetoothIssueWorkaround = new PlatformBluetoothIssueWorkaround();
protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
{
if (bluetoothIssueWorkaround.HandlePlayStateChanged(player, playState))
{
NotifyComplete();
return;
@richardszalay
richardszalay / XframeOptionsAttribute.cs
Last active February 25, 2020 11:39
ASP.NET MVC action filter for specifying an X-FRAME-OPTIONS header
/*
Copyright (C) 2013 Richard Szalay
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
@richardszalay
richardszalay / BackgroundAudioPlayerDefensiveExtensions.cs
Last active January 4, 2016 02:09
Adds some extension methods to BackgroundAudioPlayer to work with the exceptions it commonly throws.
/*
Copyright (C) 2013 Richard Szalay
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
/*
@licstart The following is the entire license notice for the
ActionScript code in this gist.
Copyright (C) 2009 Richard Szalay
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@richardszalay
richardszalay / TrustedSelfSignedCertificate.psm1
Created November 8, 2015 23:57
Powershell module for creating trusted self-signed certificates
#requires -Version 2.0
#region Exported Cmdlets
<#
.SYNOPSIS
Creates a self-signed certificate and copies it into the trusted store.
.DESCRIPTION
Creates a self-signed certificate and copies it into the trusted store.
@richardszalay
richardszalay / WhereConvertedExtensions.cs
Last active April 29, 2016 05:42
WhereParsed extension method, combining Where and Select for attempted conversions (like TryParse)
/*
Usage: "1,2,c,4".Split(',').WhereParsed<int>(int.TryParse)
*/
public delegate bool TryConversion<TIn, TOut>(TIn input, out TOut output);
public static class WhereConvertedExtensions
{
/// <summary>
/// Filters an enumerable to elements that succeeded in conversion via a "Try*" pattern implementation
@richardszalay
richardszalay / .bashrc
Last active October 18, 2016 21:45
Creating a Build-Once Deployment Pipeline
# https://github.com/fastlane/fastlane/issues/488
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# If not using rvm (which will set this for you)
export GEM_HOME=~/.gems
export PATH=$PATH:~/.gems/bin