Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Szalay richardszalay

View GitHub Profile
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 / 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 / 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
@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 / 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
@richardszalay
richardszalay / extract-policy.js
Created Dec 5, 2016
Extract policy document as text in AWS
View extract-policy.js
document.querySelector('#policy_document .ace_scroller').innerText
View 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 Mar 24, 2017
Positioning a fixed header below the Sitecore Experience Editor ribbon
View PositionFixedNavBar-SC-Ext.js
// 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)