Skip to content

Instantly share code, notes, and snippets.

View MattJeanes's full-sized avatar
🏳️‍🌈

Matt Jeanes MattJeanes

🏳️‍🌈
View GitHub Profile
@MattJeanes
MattJeanes / webpack.config.node.ts
Created July 24, 2017 12:30
Webpack config for serverside node applications with hacks for TypeORM and SQLite3
import { CheckerPlugin } from "awesome-typescript-loader";
import * as path from "path";
import * as webpack from "webpack";
module.exports = (env: any) => {
const prod = env && env.prod as boolean;
console.log(prod ? "Production" : "Dev" + " main build");
const analyse = env && env.analyse as boolean;
if (analyse) { console.log("Analysing build"); }
const outputDir = "./";
@MattJeanes
MattJeanes / DeleteExcludedFiles.ps1
Last active September 6, 2018 17:21 — forked from mikesigs/DeleteExcludedFiles.ps1
PowerShell Script to Find (and delete) all excluded files in a Visual Studio Solution
$Solution = "C:\_git\Mercury\Mercury.sln"
[switch]$DeleteFromDisk = $true
$ErrorActionPreference = "Stop"
$solutionDir = Split-Path $Solution | % { (Resolve-Path $_).Path }
cd $solutionDir
$projects = Select-String -Path $Solution -Pattern 'Project.*"(?<file>.*\.csproj)".*' `
| % { $_.Matches[0].Groups[1].Value } `
@MattJeanes
MattJeanes / launch.ps1
Created October 22, 2018 13:55
Manual launching and handling of IISExpress via command line/launchSettings.json
param([string]$Config, [string]$Site, [switch]$Child=$false)
if(-not $Child){
Write-Host "Starting child process"
$exe = "powershell"
$args = @("-File `"$($MyInvocation.MyCommand.Definition)`"", "-Config `"$Config`"", "-Site `"$Site`"", "-Child")
$args
Start-Process $exe -ArgumentList $args -Wait
}else{
try{
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:43434/",
"sslPort": 44301
}
},
"profiles": {
@MattJeanes
MattJeanes / tesla.js
Last active June 11, 2019 16:19
Checks delivery estimate and updates if it changes
const Nightmare = require('nightmare')
const request = require('request-promise')
const fs = require('fs');
const email = "xxxxx";
const encodedPassword = "xxxxx";
const expectedFile = "./expected.json";
const expected = require(expectedFile);
const pushoverToken = "xxxxx";
const pushoverUser = "xxxxx";
@MattJeanes
MattJeanes / MongoDBErrorStore.cs
Created November 21, 2018 01:35
MongoDB Error Store for StackExchange.Exceptional
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using StackExchange.Exceptional.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace StackExchange.Exceptional.Stores
{
@MattJeanes
MattJeanes / ReleaseNoteHelper.cs
Created March 27, 2019 16:00
Release Notes Helper for Azure DevOps
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.VisualStudio.Services.WebApi.Patch;
using Microsoft.VisualStudio.Services.WebApi.Patch.Json;
using Newtonsoft.Json;
using System;
const fetch = require("node-fetch");
const oauthClientUrl = "https://pastebin.com/raw/pS7Z6yyP"
const baseUrl = "https://owner-api.teslamotors.com";
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function getHeaders() {
@MattJeanes
MattJeanes / convert.ps1
Last active March 30, 2020 16:25
Convert a collection of files and text captions to training format
Set-Location $PSScriptRoot
if (-not (Get-Module -ListAvailable -Name "Newtonsoft.Json")) {
Install-Module "Newtonsoft.Json" -Force
}
Import-Module "Newtonsoft.Json"
. $PSScriptRoot/normalize.ps1
$commaNumberRegex = [regex]'([0-9][0-9\,]+[0-9])'
$decimalNumberRegex = [regex]'([0-9]+\.[0-9]+)'
$poundsRegex = [regex]'£([0-9\,]*[0-9]+)'
$dollarsRegex = [regex]'\$([0-9\.\,]*[0-9]+)'
$ordinalRegex = [regex]'([0-9]+)(st|nd|rd|th)'
$numberRegex = [regex]'[0-9]+'
if (-not (Get-Module -ListAvailable -Name "PSUnidecode")) {
Install-Module "PSUnidecode" -Force
}