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
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 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
@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.
@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");
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 / 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));
}
@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 / KdbClient.cs
Created Jun 4, 2013
KDB Client rewritten from sample Kx code to use more useful names.
View KdbClient.cs
//2012.06.07 fixed scoping of GUID
//2012.05.29 for use with kdb+v3.0, changed handshake and added Guid. boolean v6->vt tracks type capability.
//2012.01.26 refactored clamp into clampDT, for Date.DateTime()
//2012.01.25 rz() clamp datetime to valid range
//2010.11.17 Block sending new timetypes to version of kdb+ prior to v2.6 (use prior release of KdbClient.cs for older kdb+ versions)
// Max buffer size (default 64kB) used for reading is now a parameter to the KdbClient constructor
// Date, Month, Minute, Second, KTimeSpan are now serializable, implement IComparable
// and have default constructors for xml serialization.
// Added GetNullRepresentation(Type t)
//2010.08.05 Added KException for exceptions due to server error, authentication fail and func decode
@LeeCampbell
LeeCampbell / MyLib.Messaging.cs
Created Dec 12, 2012
Thoughts on a simple Messaging API
View MyLib.Messaging.cs
using System;
namespace MyLib.Messaging
{
public interface IConsumer<out T>
{
///<summary>Allows non-destructive read access to the next message on the queue</summary>
T Peek();
///<summary>Transactional consumer. Requires a transaction scope to be accessed.</summary>
@LeeCampbell
LeeCampbell / ScrollViewerCorrector.cs
Created Oct 26, 2012
Corrects the ScrollViewer behavior that does not allow parent to scroll once child has exhausted scrolling.
View ScrollViewerCorrector.cs
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MyLib
{
//http://serialseb.blogspot.co.uk/2007/09/wpf-tips-6-preventing-scrollviewer-from.html
You can’t perform that action at this time.