Skip to content

Instantly share code, notes, and snippets.

View yetanotherchris's full-sized avatar
🔏
;ÿÿÿÿrules

Chris S. yetanotherchris

🔏
;ÿÿÿÿrules
View GitHub Profile
@yetanotherchris
yetanotherchris / valve-trust-score.md
Last active October 27, 2024 20:40
Thoughts on Valve's Trust Score System
@yetanotherchris
yetanotherchris / youtube.py
Created September 9, 2024 14:28
Retrieve Youtube video title, author, duration (as Markdown)
import requests
import isodate # To parse ISO 8601 durations
# Create an API key in Google Cloud: API/Service Details/Credentials
API_KEY = 'mykey'
VIDEO_IDS = [
'KZSD3lauzDo', 'puddZhRgRNI', 'YJTjtoKGCYo', '-PjtJeMvsFI', 'KZSD3lauzDo',
'puddZhRgRNI', 'YJTjtoKGCYo', '-PjtJeMvsFI', 'KZSD3lauzDo', 'puddZhRgRNI',
'YJTjtoKGCYo', '-PjtJeMvsFI'
]
@yetanotherchris
yetanotherchris / firefox-bookmarks-jq.sh
Created August 21, 2024 17:07
List all Firefox bookmark titles and urls from JSON Export file, using JQ
# Tested on Ubuntu, use 'apt-get install jq'
cat ./bookmarks.json | jq '.. | select(.type?=="text/x-moz-place") | "\(.title?), \(.uri)"?'
cat ./bookmarks.json | jq -r '.. | select(.type?=="text/x-moz-place") | "- [\(.title?)](\(.uri?))"' > uris.md
# The second prints a markdown file using the title and uri
@yetanotherchris
yetanotherchris / http-load-test.ps1
Created March 30, 2022 08:34
Powershell HTTP "load testing" (about 3-5 RPS)
while ($true) { $r = wget -uri "http://somesite.com?q=1" -headers @{"Accept-Tenant"="Nz"}; echo $r.Content }
@yetanotherchris
yetanotherchris / monitor-speed.ps1
Created March 14, 2022 15:08
Monitor internet speed test in Powershell
# choco install -y jq
# npm install --global fast-cli
while ($true)
{
$now = date;
$dateRow = $now.ToString("dd-MM-yyyy HH:mm");
$dl = fast -u --json | jq '.downloadSpeed';
echo "$dateRow, $dl" >> data.txt;
@yetanotherchris
yetanotherchris / TestCircuitBreaker.Controllers.HomeController.cs
Last active August 21, 2021 14:16
Polly CircuitBreaker, Retry and Timeout configuration example for HttpClient and HttpClientFactory
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using TestCircuitBreaker.Models;
@yetanotherchris
yetanotherchris / loading-pem-ssl-windows-workaround.cs
Created December 26, 2020 16:00
Loading PEM SSL certificates in Kestrel (Windows work-around)
// See https://github.com/dotnet/runtime/issues/23749
public static class CertHelper
{
// To generate a self-signed cert:
// dotnet dev-certs https -ep $pwd/selfsigned.pem --format Pem -np
public static X509Certificate2 GetCertificate()
{
X509Certificate2 sslCert = CreateFromPublicPrivateKey("certs/selfsigned.pem", "certs/selfsigned.key");
@yetanotherchris
yetanotherchris / main.go
Last active November 27, 2020 17:44
Quote of the day in Go Lang (playing with Go for the first time)
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
@yetanotherchris
yetanotherchris / yarn-env-bars.ps1
Last active November 21, 2020 15:18
Solution to yarn global add does not work on Windows (command not found)
$yarnPath = & yarn global bin
$path = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("PATH", "$path;$yarnPath", [System.EnvironmentVariableTarget]::User)
# Your yarn path should appear at the end of the path now
[System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
# Try a global command, for example gatsby. If you're using Visual Studio Code, you'll need to restart the IDE
gatsby
@yetanotherchris
yetanotherchris / PublicKeyCryptographyExample.cs
Last active January 12, 2023 09:25
Public key cryptography by example in .NET Core
using System;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace PublicKeyCryptographyExample
{
//
// https://yetanotherchris.dev/security/public-private-key-in-netcore-by-example/
//