Skip to content

Instantly share code, notes, and snippets.

open FSharp
open FSharp.Core
[<Measure>] type hour
[<Measure>] type gbp
type LabourType =
| Design
| UIDesign
describe("YourComponentTests", () => {
it("should resolve dependencies", () =>{
const f = TestBed.configureTestingModule({
imports: [AppModule, SpecialModule]
});
f.compileComponents().then(res => res)
const z = f.createComponent(YouComponent);
});
});
@alexswan10k
alexswan10k / .gitignore
Last active March 14, 2018 09:21
Fake as script runner - getting started
*.lock
.fake
//see https://github.com/Microsoft/TypeScript/issues/15628
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];
type Omit<T, K extends keyof T> = {[P in Diff<keyof T, K>]: T[P]};
type Test = Omit<{a: number, b: string, c: "hehe"}, "b"|"c">; // {a: number}
type Subtract<T1 extends any, T2> = Omit<T1, keyof T2>;
//Deserialize a json object back into form inputs ready for a conventional post
//Inverse of jquery $.serialize($form)
const isPrimitive = (obj) =>
(typeof obj === 'string') || (typeof obj === 'number')
const tryDumpValue = (obj) =>
{
if(!isPrimitive(obj))
return "";
//Walk all of the subfolders and execute a command
find ./ -mindepth 1 -maxdepth 1 -type d -exec bash -c 'cd {}/ && ls' \;
public static class WatinExtensions
{
public static async Task<Element> GetSingleSizzleAsync(this IEHost host, string sizzleSel, int timeout = 2000, int pollInterval = 500)
{
return await _Poll(
() => host.Elements.Filter(Find.BySelector(sizzleSel))?.First(),
element => element?.Exists ?? false,
"Element matching expression " + sizzleSel + " not found after " + timeout + "ms", timeout, pollInterval
);
}
@alexswan10k
alexswan10k / .gitignore
Last active April 8, 2016 09:20
FableTest
.vs
bin
obj
*.js
@alexswan10k
alexswan10k / SubstitutingStreamWrapper
Created February 16, 2016 16:49
Wraps a stream, allowing interception and replacing of write ops. (assumes UTF8)
public class SubstitutingStreamWrapper : Stream
{
private readonly Stream _base;
private readonly int _windowSize;
private Queue<string> _bufferedSegments = new Queue<string>();
private readonly string _find;
private readonly string _replace;
public SubstitutingStreamWrapper(Stream stream,
@alexswan10k
alexswan10k / Validator.cs
Last active December 2, 2015 10:27
Password validator
public class PasswordValidationErrorCollector
{
private readonly PasswordValidator _passwordValidator;
public PasswordValidationErrorCollector(PasswordValidator passwordValidator = null)
{
_passwordValidator = passwordValidator ?? new PasswordValidator();
}