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 / 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 / install-mono-amazon-linux.sh
Last active November 21, 2024 10:33
Install Mono on Amazon Linux (CentOS too)
sudo yum update -y
echo "======= INSTALLING RPM FOR MONO ======="
sudo mkdir -p /tmp/mono_dependencies
cd /tmp/mono_dependencies
sudo wget https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/l/libpng15-1.5.30-11.fc33.x86_64.rpm
sudo yum install -y libpng15-1.5.30-11.fc33.x86_64.rpm
echo "======= INSTALLING MONO ============"
sudo yum install -y yum-utils
@yetanotherchris
yetanotherchris / valve-trust-score.md
Last active October 27, 2024 20:40
Thoughts on Valve's Trust Score System
@yetanotherchris
yetanotherchris / install-kops.sh
Last active October 19, 2024 06:47
Install Kops and prequisites on Ubuntu
# Install AWS CLI, Kubectl, Kops
sudo apt update
sudo apt install -y awscli
sudo snap install kubectl --classic
curl -LO https://github.com/kubernetes/kops/releases/download/1.7.0/kops-linux-amd64
chmod +x kops-linux-amd64
mv ./kops-linux-amd64 /usr/local/bin/kops
# Setup the AWS profile
aws config
@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 / gist:4774077
Created February 12, 2013 22:29
Rounding with number formatting in C#
// No number specifier
Console.WriteLine("a) {0}", numSingle);
// Round up, ignore any decimal points.
Console.WriteLine("a) {0:##}", numSingle);
// Round up to 1 dp.
Console.WriteLine("b) {0:.#}", numSingle);
// Round up to 2 dp.
@yetanotherchris
yetanotherchris / aes-example.cs
Created January 18, 2017 18:54
C# AES asymmetric encryption and decryption example
string ivAsBase64;
string encryptedTextAsBase64;
string keyAsBase64;
using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider())
{
// Store the IV (they can be stored if you don't re-use a key)
aes.GenerateIV();
byte[] iv = aes.IV;
ivAsBase64 = Convert.ToBase64String(iv);
@yetanotherchris
yetanotherchris / gist:4986402
Created February 19, 2013 14:31
Wake up from sleep C# example
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
using System.Threading;
using System.ComponentModel;
namespace ConsoleApplication1
{
class Program
{
[DllImport("kernel32.dll")]
@yetanotherchris
yetanotherchris / docker-automation.py
Created September 5, 2016 09:07
Automating Docker images and containers with Python ()
'''
This script brings up the entire stack of Docker containers, removing the current ones.
Docker compose was tried for this task and it wasn't customisable enough.
Docker cloud was tried (with stack files) and was buggy (failed to launch, no logs returned).
Docker machine was tried, but it can't connect to existing servers only ones it created.
Rancher was too heavy weight for the task, as the containers are lightweight in DigitalOcean.
Kubernetes would've been too heavy weight for DigitalOcean.
It was written in Powershell and worked. But then converting it to Bash was too much effort.
Powershell for Linux is too much effort to install without a debian package (and none standard)
#==========================================================================================
# Get the latest Chromedriver version number
#==========================================================================================
WriteHeader "Determining Chromedriver version"
$url = "http://chromedriver.storage.googleapis.com/";
$xml = [xml](wget $url);
$chromeDriver_version = 2.12;
# XML format: <ListBucketResult><Contents><Key>...</Key></Contents></ListBucketResult>
foreach ($item in $xml.ListBucketResult.Contents)