Skip to content

Instantly share code, notes, and snippets.

@badsyntax
badsyntax / ExpressionWhereFinder.cs
Last active March 3, 2023 17:43
c# predicate builder, useful for constructing linq predicates
internal class ExpressionWhereFinder : ExpressionVisitor
{
private readonly IList<MethodCallExpression> _whereExpressions = new List<MethodCallExpression>();
public IEnumerable<MethodCallExpression> GetWhere(Expression expression)
{
Visit(expression);
return _whereExpressions;
}
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
@badsyntax
badsyntax / example.cs
Created April 29, 2022 11:55
example dotnet 6 code to sign an apple JWT from p8 certificate file
public class TokenSigningRequest
{
public string AppleTeamId { get; set; }
public string AppleServiceId { get; set; }
public string AppleKeyId { get; set; }
public string P8key { get; set; }
}
[HttpPost]
public async Task<IActionResult> CreateSignedToken([FromBody, BindRequired] TokenSigningRequest requestBody)
@badsyntax
badsyntax / multiple-gource.sh
Created April 8, 2022 08:19 — forked from PhiSYS/multiple-gource.sh
Create multiple repositories visualization video using gource and ffmpeg
#!/usr/bin/bash
declare -a repos=(
"$HOME/Projects/myproject/testing/.git"
"$HOME/Projects/myproject/testing-bundle/.git"
"$HOME/Projects/myproject/service-skeleton/.git"
"$HOME/Projects/myproject/documentation-web/.git"
"$HOME/Projects/myproject/documentation-api/.git"
"$HOME/Projects/myproject/coding-standard/.git"
"$HOME/Projects/myproject/context/microservice1/.git"
@badsyntax
badsyntax / azure-pipelines.yml
Last active February 18, 2022 12:58
Azure pipelines install dotnet on mac mini arm64
steps:
- script: |
DOTNET_VERSION="6.0.1xx"
DOTNET_TEMP_DIRECTORY=$(cat /dev/urandom | env LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
DOTNET_INSTALL_LOCATION="$(Agent.TempDirectory)/$DOTNET_TEMP_DIRECTORY"
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --architecture arm64 --channel "$DOTNET_VERSION" --install-dir "$DOTNET_INSTALL_LOCATION"
PATH="$PATH:$DOTNET_INSTALL_LOCATION"
echo "##vso[task.setvariable variable=PATH;]$PATH"
displayName: Install .NET 6.0 SDK
@badsyntax
badsyntax / build-ios.sh
Created January 12, 2022 05:16
react native build benchmarks
#!/usr/bin/env bash
echo
echo "!!!! BUILDING IOS, PLEASE WAIT... !!!!!"
echo
npm ci
npm run lint
npm run markdown-link-check
sleep 1
@badsyntax
badsyntax / instructions.md
Last active January 4, 2022 10:47
Storybook webpack 5 typescript ESM

storybook-webpack5-esm-typescript

The following instructions are collated from storybookjs/storybook#14877

mkdir storybook-esm-react-webpack5
cd storybook-esm-react-webpack5
npm init -y

# manually add "type":"module" to package.json
@badsyntax
badsyntax / s3etag.sh
Last active December 16, 2021 13:47 — forked from emersonf/s3etag.sh
Generate an S3 ETAG for a multipart upload file, on MacOS
#!/bin/bash
# Generate an S3 ETAG for a multipart upload file.
#
# From: https://gist.github.com/emersonf/7413337
# Author: Emerson Farrugia <https://github.com/emersonf>
# Modified by: Richard Willis <https://github.com/badsyntax>
# Modifications: Work with bytes instead of MB.
#
# MacOS only!
@badsyntax
badsyntax / s3Etag.ts
Last active December 19, 2021 07:10
Generate an S3 ETAG for multipart uploads in Node.js
/**
* Generate an S3 ETAG for multipart uploads in Node.js
* An implementation of this algorithm: https://stackoverflow.com/a/19896823/492325
* Author: Richard Willis <[email protected]>
*/
import fs from 'node:fs';
import crypto, { BinaryLike } from 'node:crypto';
const defaultPartSizeInBytes = 5 * 1024 * 1024; // 5MB
#!/usr/bin/env bash
# Clear watchman watches
watchman watch-del-all 2>/dev/null
# Delete metro cache
rm -rf "${TMPDIR:-/tmp}"/metro-*
# local xcodebuild cache
cd ios/