😶🌫️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array.prototype.selectMany = function (fn) { | |
| return this.map(fn).reduce(function (x, y) { return x.concat(y); }, []); | |
| }; | |
| // usage | |
| console.log([[1,2,3], [4,5,6]].selectMany(function (x) { return x; })); //[1,2,3,4,5,6] | |
| console.log([{ a: [1,2,3] }, { a: [4,5,6] }].selectMany(function (x) { return x.a; })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ko.validatedObservable = function (initialValue, validationFunction) { | |
| var latestValue = initialValue; | |
| function observable() { | |
| if (arguments.length > 0) { | |
| // Write | |
| // Ignore writes if the value hasn't changed | |
| if (((!observable['equalityComparer']) || !observable['equalityComparer'](latestValue, arguments[0]))) { | |
| if (validationFunction.call(null, arguments[0])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: Update notifications | |
| description: Send notifications for new updates and install or skip on action | |
| homeassistant: | |
| min_version: 2022.4.0 | |
| domain: automation | |
| input: | |
| update_entities: | |
| name: Update entities | |
| description: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Change the regex in `egrep` to match the pattern you want to reset | |
| git status -s | grep "^A" | sed 's/A //' | while read i; do git reset HEAD $i; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as cheerio from 'cheerio' | |
| export const fetchAgenda = async () => { | |
| const response = await fetch('https://ndcsydney.com/agenda') | |
| const body = await response.text() | |
| const talks = [] | |
| const $ = cheerio.load(body) | |
| $('section.day').map((i, el) => { | |
| // prettier-ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Samples.FSharp.StringTypeProvider | |
| open System | |
| open System.Reflection | |
| open Samples.FSharp.ProvidedTypes | |
| open Microsoft.FSharp.Core.CompilerServices | |
| open Microsoft.FSharp.Quotations | |
| [<TypeProvider>] | |
| type StringTypeProvider(config: TypeProviderConfig) as this = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module PubSub { | |
| interface ISubscription { | |
| (...args: any[]): void; | |
| } | |
| interface IDictionary { | |
| [name: string] : ISubscription[]; | |
| } | |
| var registry : IDictionary = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$connections": { | |
| "value": { | |
| "rss": { | |
| "connectionId": "/subscriptions/7e2b0a07-47db-4a2e-bfca-03c0d5b75f15/resourceGroups/personal-website/providers/Microsoft.Web/connections/rss", | |
| "connectionName": "rss", | |
| "id": "/subscriptions/7e2b0a07-47db-4a2e-bfca-03c0d5b75f15/providers/Microsoft.Web/locations/southcentralus/managedApis/rss" | |
| }, | |
| "twitter": { | |
| "connectionId": "/subscriptions/7e2b0a07-47db-4a2e-bfca-03c0d5b75f15/resourceGroups/personal-website/providers/Microsoft.Web/connections/twitter", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| namespace Parser.CSharp | |
| { | |
| public static class ParserCSharp | |
| { | |
| public static string[] ParseCommandline(string input) | |
| { | |
| var items = new List<string>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macroclass typedef { | |
| pattern { $x:ident : $type:ident } | |
| pattern { $x:ident : $type:lit } | |
| } | |
| let function = macro { | |
| rule { $name ($params:typedef ...) { $body ... } } => { | |
| function $name ($params$x ...) { | |
| $(if (typeof $params$x !== typeof $params$type) { | |
| throw new Error('Found type ' + (typeof $params$x) + ' but expected ' + typeof $params$type); |
NewerOlder