Skip to content

Instantly share code, notes, and snippets.

View mavaddat's full-sized avatar
🏠
Working from home

Mavaddat Javid mavaddat

🏠
Working from home
View GitHub Profile
@mavaddat
mavaddat / setupCerts.ps1
Last active May 24, 2024 03:14
Set up CA Cert bundles for all toolsets (Python, AWS, Git, NodeJs) in Windows using PowerShell Core. Answer on Stackoverflow question: https://stackoverflow.com/questions/51925384/unable-to-get-local-issuer-certificate-when-using-requests/76397035#76397035
function Set-CaCertsBundles
{
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
param(
[Parameter(HelpMessage = 'Environment variable target')]
[ValidateScript({ $_ -ne [System.EnvironmentVariableTarget]::Machine -or ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) }, ErrorMessage = 'Cannot set machine environment variables without admin privileges')]
[ArgumentCompleter({ [System.Enum]::GetNames([System.EnvironmentVariableTarget]) })]
[System.EnvironmentVariableTarget]
$Target = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ? [System.EnvironmentVariableTarget]::Machine : [System.EnvironmentVariableTarget]::User,
[Parameter(HelpMessage = 'Output file path')]
using System.Text.Json.Serialization;
using RestSharp.Authenticators;
namespace RestSharp.Tests.External.Twitter;
public interface ITwitterClient
{
Task<TwitterUser> GetUser(string user);
}
@mattjohnsonpint
mattjohnsonpint / LICENSE
Last active June 5, 2024 04:33
Unified global Unhandled Exception event for .NET MAUI
MIT License
Copyright (c) 2022 Matt Johnson-Pint
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 permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@mavaddat
mavaddat / CatLostVancouver.md
Last active June 28, 2023 06:25
How to recover a lost pet in Vancouver British Columbia

I've lost my cat several times (one time for several days) and had him mistakenly taken from me two other times (again, for days) and all those times I was able to get him back following these steps:

  1. Place your cat's litter outside your front door. The smell will help notify him to walk in the right direction if he's simply lost or hiding nearby. (Jump to step seven below if you suspect the cat is nearby.)
  2. Create a lost pet notice on BC Pet Registry and the BC SPCA's own BC SPCA Pet Search. This will not only get others looking, but the exercise of gathering all the details to fill in the form with provide you with a baseline of information about your cat that people need to help you. If your cat is tattooed or microchipped, make sure the clinic or hospital that administered the ID'ing has your current contact information. Unsure? Find out how to do this here: [BC Pet Registry Provincial Tattoo Identification Program Guide](https://b
@Alexs7zzh
Alexs7zzh / .eleventy.js
Created April 24, 2021 04:44
eleventy-img in markdown
const Image = require('@11ty/eleventy-img')
const { parseHTML } = require('linkedom')
module.exports = eleventyConfig => {
if (process.env.ELEVENTY_ENV)
eleventyConfig.addTransform('transform', (content, outputPath) => {
if (outputPath && outputPath.endsWith('.html')) {
let { document } = parseHTML(content)
@creachadair
creachadair / chrome-encrypted-cookies.md
Last active June 4, 2024 23:39
Encryption format for Chrome browser cookies

Google Chrome Encrypted Cookies

Google Chrome stores browser cookies in an SQLite database. The database has two tables, meta containing format and version metadata, and cookies with the contents of the cookies. The cookies table uses this schema:

-- To reproduce: sqlite path/to/Cookies .schema
CREATE TABLE cookies (
   creation_utc     INTEGER  NOT NULL,  -- microseconds since epoch
   host_key         TEXT     NOT NULL,  -- domain
   name             TEXT     NOT NULL,
@mavaddat
mavaddat / rejectAllPendingApprovals.js
Created July 8, 2020 09:09
Reject all pending approval requests in Microsoft Automate web interface.
document.querySelectorAll("#content-container > section > landing > div > react-app > div > section > section > section > main > div.ba-DetailsList-container.outerRoot-151 > div.ms-Viewport > div > div > div.ms-DetailsList-contentWrapper.contentWrapper-385 > div > div > div > div > div:nth-child(1) > div > div > div > div > div > div > div:nth-child(2) > div > button > span > i").forEach((e) => {
setTimeout(() => {
e.click()
}, 300);
setTimeout(() => {
document.querySelector("body > div.ms-Layer.ms-Layer--fixed > div > div > div > div.ms-Panel-main > div.ms-Panel-contentInner > div.ms-Panel-footer > div > div > button.ms-Button.ms-Button--primary.ba-Panel-footerButton.ba-Panel-footer-primaryButton > span").click();
}, 2300);
setTimeout(() => {
document.querySelector("body > div:nth-child(33) > div > div > div > div.ms-Panel-main > div.ms-Panel-contentInner > div.ms-Panel-footer > div > div > button").click();
}, 300)
@mavaddat
mavaddat / repairVSLiveShare.ps1
Last active August 9, 2021 18:26
Fix VS LiveShare extensions using completely new install. This is a more aggressive, hard reset than just uninstalling and reinstalling because it also recursively deletes the extension cache and global storage directories before reinstalling.
# Get the VS Code batch script
$vsCodeCmd = Get-Command -Name code*cmd -CommandType Application -TotalCount 1
# Verify code sign
$vsCodeExe = Resolve-Path "$(Join-Path ($vsCodeCmd| Get-Item).Directory '..')\Code*.exe"
if( $null -eq $vsCodeExe -or ((Get-AuthenticodeSignature -FilePath $vsCodeExe -ErrorAction Stop).Status -ne [System.Management.Automation.SignatureStatus]::Valid)){
throw "Could not find valid VS Code Executable."
}
# Collect all the liveshare extensions
@DrEmpiricism
DrEmpiricism / Start-WindowsCleanup.ps1
Last active January 17, 2024 05:19
Clean-up system clutter and reclaim disk space
Function Start-WindowsCleanup
{
<#
.SYNOPSIS
`Start-WindowsCleanup` cleans-up a system clutter and reclaims disk space.
.DESCRIPTION
The `Start-WindowsCleanup` cmdlet performs the following clean-up tasks to reclaim disk space:
Clears the contents of common directories of the Windows file system for both the current running user and the global system that are used to store temporary, logging, backup, cache and dump files.
@djfdyuruiry
djfdyuruiry / README.md
Last active April 28, 2024 08:34
WSL 2 - Enabling systemd

Enable systemd in WSL 2

NOTE: If you have Windows 11 there is now an official way to do this in WSL 2, use it if possible - see MS post here (WINDOWS 11 ONLY)

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh: