Skip to content

Instantly share code, notes, and snippets.

View richardszalay's full-sized avatar

Richard Szalay richardszalay

View GitHub Profile
/*
@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 / 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 / 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
@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 / 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
@richardszalay
richardszalay / extract-policy.js
Created December 5, 2016 21:49
Extract policy document as text in AWS
document.querySelector('#policy_document .ace_scroller').innerText
@richardszalay
richardszalay / Copy-EC2SecurityGroupIngress.ps1
Created February 21, 2017 06:03
Copy-EC2SecurityGroupIngress.ps1
<#
.SYNOPSIS
Copies all EC2 Security Group rules from one IP range to one or more other ranges, optionally removing the original IP's rules
.DESCRIPTION
Copies all EC2 Security Group rules from one IP range to one or more other ranges, optionally removing the original IP's rules
.PARAMETER Region
The AWS Region to apply the changes to
.PARAMETER CurrentIpRange
The IP Address or CIDR Range that should be used as a template when copying rules
.PARAMETER NewIpRanges
@richardszalay
richardszalay / PositionFixedNavBar-SC-Ext.js
Created March 24, 2017 04:35
Positioning a fixed header below the Sitecore Experience Editor ribbon
// Repositions a position-fixed header so that it always appears under the SC experience editor ribbon
// includes added support for the Sitecore Extensions Chrome extension and its support for hiding the ribbon entirely
define(["sitecore"], function (Sitecore) {
return {
priority: 50,
execute: function (context) {
// TODO: Change this CSS selector to suit your application
var FIXED_NAV_SELECTOR = 'nav';
// the 'cross piece' is a blank div that is sized to match the iframe content (where the actual ribbon is)