Skip to content

Instantly share code, notes, and snippets.

Lee Campbell LeeCampbell

Block or report user

Report or block LeeCampbell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@LeeCampbell
LeeCampbell / BufferByGate.cs
Created May 3, 2014
Buffers values from one observable, by another 'gate' observable. Allows flows to be turned on an off without loosing intermediate values.
View BufferByGate.cs
//From James World http://stackoverflow.com/questions/23431018/how-can-i-alternately-buffer-and-flow-a-live-data-stream-in-rx
// a demo data stream that emits every second
var dataStream = Observable.Interval(TimeSpan.FromSeconds(1));
// a demo flag stream that toggles every 5 seconds
var toggle = false;
var gateStream = Observable.Interval(TimeSpan.FromSeconds(5))
.Select(_ => toggle = !toggle);
@LeeCampbell
LeeCampbell / PairWithPrevious.cs
Created May 20, 2014
Rx delta without Zip/DualSubscription
View PairWithPrevious.cs
//From James World - http://social.msdn.microsoft.com/Forums/en-US/dfa87af8-b7dd-4fb5-abe2-99348d3e27e1/compare-two-object-graphs-and-get-differences?forum=rx
public static IObservable<Tuple<TSource, TSource>> PairWithPrevious<TSource>(this IObservable<TSource> source)
{
return source.Scan(
Tuple.Create(default(TSource), default(TSource)),
(acc, current) => Tuple.Create(acc.Item2, current));
}
View Mortg table
Weekly obligation (ANZ current rates)
Rate 200k@25yr 300k@25yr 400k@25yr 500k@25yr
ANZ 2y (min20%) 5.99 $296/wk $444/wk $592/wk $740/wk
ANZ 2y Low eq 6.49 $310/wk $465/wk $620/wk $775/wk
ANZ 3y 6.55 $312/wk $467/wk $623/wk $779/wk
ANZ 3y Low eq 7.05 $326/wk $489/wk $652/wk $815/wk
ANZ 4y 7.19 $330/wk $496/wk $661/wk $826/wk
ANZ 5y 7.40 $336/wk $504/wk $673/wk $841/wk
ANZ 4y Low eq 7.69 $345/wk $518/wk $691/wk $863/wk
@LeeCampbell
LeeCampbell / WindowBy.cs
Created May 22, 2014
Slice a sequence into windows based on a predicate
View WindowBy.cs
void Main()
{
var data = new List<string>(){@"$[data for first line g", "oes here]\r\n$[data for ", "second line goes here]"};
data.ToObservable()
.SelectMany(s=>s)
.WindowByExclusive(c => c=='$')
.SelectMany(window=>window.ToList().Select(l=>string.Join(string.Empty, l)))
.Where(s=>!string.IsNullOrEmpty(s))
.Dump("WindowByExclusive");
@LeeCampbell
LeeCampbell / GitRevert
Created Sep 17, 2014
Revert a merge that is not at the head
View GitRevert
# first get the merge commit hash
git log
# next get off master so you can play safe
git checkout -b RevertFeatureX
# revert the merge. Here "-m 1" says that the index 1 branch is the one to keep (hopefully this is the master/develop branch)
git revert -m 1 94d49c1d6edd3006208400b2de5920c4edff1db3
#This will then throw up a git file editor so you can enter in you commit message.
View stuff
←[0;32m virtualbox-iso: Resolving github.com (github.com)... 192.30.252.128←[0m
←[0;32m virtualbox-iso: Connecting to github.com (github.com)|192.30.252.128|:443... connected.←[0m
←[0;32m virtualbox-iso: HTTP request sent, awaiting response... 200 OK←[0m
←[0;32m virtualbox-iso: Length: unspecified [text/plain]←[0m
←[0;32m virtualbox-iso: Saving to: ‘/home/stuartrexking/.ssh/authorized_keys’←[0m
←[0;32m virtualbox-iso:←[0m
←[0;32m virtualbox-iso: 1,523 --.-K/s in 0.001s←[0m
←[0;32m virtualbox-iso:←[0m
←[0;32m virtualbox-iso: 2015-03-16 22:18:15 (1.68 MB/s) - ‘/home/stuartrexking/.ssh/authorized_keys’ saved [1523]←[0m
←[0;32m virtualbox-iso:←[0m
View MoneyPennyKafakShFail
leecampbell@lxc-vm:/scripts/lxc$ ls
kafka.sh lxc.sh
leecampbell@lxc-vm:/scripts/lxc$ ls -al
total 9
drwxrwxrwx 1 vagrant vagrant 0 Apr 5 20:58 .
drwxrwxrwx 1 vagrant vagrant 4096 Apr 5 20:58 ..
-rwxrwxrwx 1 vagrant vagrant 3815 Apr 5 20:58 kafka.sh
-rwxrwxrwx 1 vagrant vagrant 755 Apr 5 20:58 lxc.sh
leecampbell@lxc-vm:/scripts/lxc$ sudo chmod a+x /scripts/lxc/kafka.sh
leecampbell@lxc-vm:/scripts/lxc$ ls -al
View MoneyPennyKafkaDump
leecampbell@lxc-vm:~$ sed -i 's/\r//' kafka.sh
leecampbell@lxc-vm:~$ bash kafka.sh
in the file
lxc-net stop/waiting
lxc-net start/running
Setting up the GPG keyring
ERROR: Unable to fetch GPG key from keyserver.
lxc_container: lxccontainer.c: create_run_template: 1125 container creation template for zookeeper failed
lxc_container: lxc_create.c: main: 271 Error creating container zookeeper
View EventStoreWritePerfTestFuxture.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EventStore.ClientAPI;
@LeeCampbell
LeeCampbell / StubRegionManager
Created Sep 7, 2011
Prebuilt Stub RegionManager to enable friction-free testing of the IRegionManager Prism interface
View StubRegionManager
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;
using Moq;
using System.Collections.ObjectModel;
namespace ArtemisWest.Prism.Testing
You can’t perform that action at this time.