Skip to content

Instantly share code, notes, and snippets.

View aaronpowell's full-sized avatar
😶‍🌫️

Aaron Powell aaronpowell

😶‍🌫️
View GitHub Profile
@aaronpowell
aaronpowell / update_notifications-rev.yaml
Created December 5, 2023 01:27 — forked from mdegat01/update_notifications.yaml
Update Notifications Automation Blueprint
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:
@aaronpowell
aaronpowell / selectMany.js
Created November 19, 2012 03:22
LINQ SelectMany in JavaScript
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; }));
@aaronpowell
aaronpowell / multi-reset.sh
Last active October 19, 2022 13:07
Resetting multiple files
#!/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
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
@aaronpowell
aaronpowell / StringTypeProvider.fs
Created February 6, 2015 11:02
A basic Type Provider for taking a string and making something silly.
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 =
module PubSub {
interface ISubscription {
(...args: any[]): void;
}
interface IDictionary {
[name: string] : ISubscription[];
}
var registry : IDictionary = {
@aaronpowell
aaronpowell / LogicApp.json
Created April 17, 2019 11:14
Auto tweeting logic app
{
"$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",
@aaronpowell
aaronpowell / parser.cs
Last active February 26, 2019 01:00
C# parser in F#
using System;
using System.Collections.Generic;
namespace Parser.CSharp
{
public static class ParserCSharp
{
public static string[] ParseCommandline(string input)
{
var items = new List<string>();
@aaronpowell
aaronpowell / annotations.sjs
Created May 13, 2014 06:23
Type annotations and checking with Sweet.js
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);
@aaronpowell
aaronpowell / BulkNuGetInstall.ps1
Created February 25, 2011 02:26
Install NuGet across all projects
#Installs a package into all projects in the solution (note: Requires NuGet 1.1+)
Get-Project -All | Install-Package packageName