Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Szalay richardszalay

View GitHub Profile
@richardszalay
richardszalay / raix-interactive-basic.as
Created Mar 26, 2011
Basic raix.interactive example
View raix-interactive-basic.as
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 Mar 26, 2011
Basic raix.reactive example
View raix-reactive-basic.as
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 Apr 13, 2017
Sitecore MVC EditFrame implementation
View SitecoreMvcEditFrame.cs
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 Feb 10, 2016
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.
View wp-bluetooth-workaround-example.cs
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 Feb 25, 2020
ASP.NET MVC action filter for specifying an X-FRAME-OPTIONS header
View XframeOptionsAttribute.cs
/*
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 Jan 4, 2016
Adds some extension methods to BackgroundAudioPlayer to work with the exceptions it commonly throws.
View BackgroundAudioPlayerDefensiveExtensions.cs
/*
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
View TimeSpan.as
/*
@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 Nov 8, 2015
Powershell module for creating trusted self-signed certificates
View TrustedSelfSignedCertificate.psm1
#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 Apr 29, 2016
WhereParsed extension method, combining Where and Select for attempted conversions (like TryParse)
View WhereConvertedExtensions.cs
/*
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 Oct 18, 2016
Creating a Build-Once Deployment Pipeline
View .bashrc
# 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