Skip to content

Instantly share code, notes, and snippets.

@JamesTryand
JamesTryand / randomcheck.ps1
Created January 6, 2017 06:38
.net random number generator test
$a = [array]::CreateInstance([int],101)
1..1000000 | %{ get-random -max 100 -min 0 } | %{ $a[$_] = $a[$_] + 1 }
0..100| select @{n='Value';e={$_}}, @{n='Count';e={$a[$_]}} | sort count
gave the following results
Value Count
----- -----
100 0
32 9669
@JamesTryand
JamesTryand / builderexample.cs
Last active May 27, 2016 22:03
builder pattern example.
//
namespace Badger {
public class WhereYouNeedAThing {
public Growl Lalala(string thing, Person customer, NoiseMaker speakers) {
return new KindOfGrowl().WithA(thing).ForThe(customer).AmplifiedBy(speakers) as Growl;
}
}
@JamesTryand
JamesTryand / csharpontheconsole.ps1
Created May 17, 2016 18:07
Compile C# on the commandline in powershell
$x = @'
using System;
namespace X {
public class Y {
public string Echo(string echo) {
return echo + echo;
} } }
'@
add-type -typedefinition $x

REACT / ROUTER / REDUX (DRAFT!)

please note this is subject to change.
specifically this is currently using a single folder structure.
this approach is for learning purposes, with this structure likely to become a unit of work.

TODO

  • unit of work
  • external calls
@JamesTryand
JamesTryand / retardremover.cs
Created February 3, 2016 23:04
Public edition of my facebook retard remover.
using System;
using System.Linq;
namespace Facepalm {
// This is an example of SDD - Sarcasm Driven Development.
public class Program {
public static void Main(params string[] args) {
DoTheBanOThon.LikeRightNow();
@JamesTryand
JamesTryand / .gitconfig
Created December 15, 2015 10:05
Some Nice Aliases For Git courtesy of CaRDiaK
[alias]
lg = log --graph --oneline --all --decorate
lga = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(bold white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lgv = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
nuke = !git clean -xfd && git reset HEAD --hard && git status
clear = !git add -A && git checkout -f && git status;
@JamesTryand
JamesTryand / Listener.cs
Created November 16, 2015 10:10
Stream Listener - C# variable rate logstash equivalent.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
// Please Note this has a dependency on Rx-Main
@JamesTryand
JamesTryand / option.cs
Created September 3, 2015 14:07
C# OptionType
using System;
namespace Options {
public abstract class Option<T>
{
public class Some : Option<T>
{
public T Value { get; private set; }
public Some(T value)
@JamesTryand
JamesTryand / ArrayListExtension.cs
Created August 9, 2015 10:19
ArrayList as Enumerable Extension
using System.Collections;
using System.Collections.Generic;
namespace System.CollectionsEx
{
public static class ArrayListExtensions
{
public static IEnumerable<T> AsEnumerable<T>(this ArrayList collection)
{
@JamesTryand
JamesTryand / introrx.md
Last active August 29, 2015 14:26 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.