Skip to content

Instantly share code, notes, and snippets.

View jpda's full-sized avatar
🤔
ok

John Patrick Dandison jpda

🤔
ok
View GitHub Profile
@jpda
jpda / README.md
Last active April 18, 2024 10:34
updating vscode-postgressql to work on apple silicon

vscode-postgresql for apple silicon

The currently published version of vscode-postgresql (0.3.0) uses a very old version of pgsqltoolsservice that doesn't support Apple silicon, newer versions do but the extension is not configured to use the newer versions.

While waiting on Microsoft's team to accept a PR, there are small changes to fix this now.

  • Install the psql extension
  • Navigate to the extension root on the file system (normally ~/.vscode/extensions/ms-ossdata.vscode-postgresql-0.3.0/)
  • Update two files: config.json and platform.js
  • Reload the window or close/restart vscode
@jpda
jpda / teamsup.sh
Last active July 13, 2022 14:39
teams apple silicon updater without rosetta
#!/bin/bash
# github.com/jpda
# teams updater for apple silicon macs
# today, while universal binaries exist for teams, the teams installer actually contains two packages:
# - the teams app itself
# - the MSTeamsAudioDriver - I think it's related to playing music/hi-fi audio in teams, not sure tho
# `MSTeamsAudioDriver.pkg` is still x64, so the main teams installer will ask to install rosetta
#
# to get around this, we unpack the installer pkg,
# look for the Teams.app package (`Teams_osx_app.pkg`, at least for now), and
@jpda
jpda / Program.cs
Created April 14, 2020 17:57
get jwk thumbprint
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.IdentityModel.Tokens;
namespace RsaModExpToPubKey
@jpda
jpda / silent-msal.hbs
Last active December 13, 2019 21:34
silent teams tab auth with graph scopes & adal
<!--
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
@jpda
jpda / 000-default.conf
Last active October 30, 2019 12:50
apache-jwt-to-header
# start with a redirect to 443
<VirtualHost *:80>
Redirect / https://myapp.example.com
</VirtualHost>
<VirtualHost *:443>
ServerName myapp.example.com # the DNS name users will use to connect to your app
SSLEngine on
SSLCertificateFile /etc/ssl/certs/myapp-example-com.pem # your cert path
SSLCertificateKeyFile /etc/ssl/certs/myapp-example-com-key.pem # your cert's key path
LimitRequestFieldSize 65536 # certain headers can grow larger than the default, 64K is a reasonable size
@jpda
jpda / do-a-really-bad-thing.ps1
Last active June 21, 2019 20:09
don't ever actually do this. ROPC for enabling security graph to a siem programmatically
# change me
$AppId = "" # client id, with user_impersonation rights on azure svc management
$secret = "" # app secret
$Resource = "https://management.core.windows.net/"
$TenantId = "" # tenant guid
$user = "" # some global admin account, without any extra goop - e.g., no MFA, no conditional access, etc, or you'll have to use app passwords or something similar
# or, if you use a federated account, you can use the active endpoint on your STS to authenticate, which you then use to authenticate to AAD, which you can then use for oauth
$password = "lol no" # as icky as this is, at least make this SecureString
$tokenUrl = "https://login.microsoftonline.com/$TenantId/oauth2/token"
using System;
using System.Data;
using System.Linq;
using Newtonsoft.Json.Linq;
namespace ConsoleApplication8
{
public struct VmSize
{
public string Name;
@jpda
jpda / swap-windows-colors.ps1
Created May 29, 2019 15:12
swaps windows system and apps from dark/light mode
$currentApps = (Get-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme).AppsUseLightTheme
$currentSystem = (Get-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme).SystemUsesLightTheme
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value (1 - $currentApps)
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value (1 - $currentSystem)
@jpda
jpda / Program.cs
Last active March 4, 2019 19:43
Decoding Azure Search document keys in .net core without asp.net
public async Task Go()
{
var response = await _client.GetStringAsync("https://<SEARCH_SERVICE>.search.windows.net/indexes/<INDEX>/docs?api-version=2017-11-11&search=*&%24top=100&%24select=metadata_storage_path");
dynamic data = JsonConvert.DeserializeObject(response);
foreach (dynamic a in data["value"])
{
string originalPath = a.metadata_storage_path.ToString();
// remove extra char
string path = originalPath.Substring(0, originalPath.Length - 1);
// fix padding - remove extra characters that the .netfx UrlTokenEncode adds
@jpda
jpda / cassl.cs
Created February 6, 2019 22:37
ca-verify
using System;
using System.Linq;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
namespace HttpPrivateCa
{