Skip to content

Instantly share code, notes, and snippets.

View AdrianJMartin's full-sized avatar

Adrian Martin AdrianJMartin

  • Select:
  • Leeds, UK
View GitHub Profile
@AdrianJMartin
AdrianJMartin / i_am_great.py
Created November 15, 2023 09:27
The old 10 print "" 20 goto 10 updated
import datetime
import random
import time
import colorama
fg = []
bg = []
for c in dir(colorama.Fore):
if c.startswith("_") == False:
@AdrianJMartin
AdrianJMartin / install-google-cloud-cli.sh
Last active June 5, 2024 10:50
The scripts given by Google fail when using inside docker - I tweaked it to work with Docker Debian 10/11
#!/bin/bash
GOOGLE_GPG_KEY=/etc/apt/trusted.gpg.d/cloud.google.gpg
GOOGLE_CLOUD_CLI_PACKAGE=google-cloud-cli
BRIGHT_WHITE_ON_RED="\\033[1;97;41m"
CLEAR_COLOURS="\\033[0m"
if [ $EUID -ne 0 ]; then
echo -e "$BRIGHT_WHITE_ON_RED $CLEAR_COLOURS"
@AdrianJMartin
AdrianJMartin / gist:58fbd4db8c08492eff679f06c31331b3
Created May 21, 2024 07:47
Newtonsoft.JSON JsonConverter example 1
// Define your enum
public enum Size { Small, Medium, Large }
// Class with an enum property
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
// Apply StringEnumConverter attribute to control JSON serialization
@AdrianJMartin
AdrianJMartin / get-latest-nodejs-lts.sh
Last active June 12, 2024 14:05
Install latest NodeJS LTS in debian or debian like container
#!/bin/bash
# summon with
# curl https://gist.githubusercontent.com/AdrianJMartin/34a98dfa1ebc207a04907eb92108137e/raw/get-latest-nodejs-lts.sh -LsO
BRIGHT_WHITE_ON_RED="\\033[1;97;41m"
CLEAR_COLOURS="\\033[0m"
if [ $EUID -ne 0 ]; then
let c = [ "mid-outbrain" , "ob-","AdW" , "AdC", "seedtag", "x-to-close" ];
let i = [ "MPU","adunit" ,"seedtag" ];
c.forEach( sel => document.querySelectorAll(`[class*=${sel}]`).forEach( e => e.remove() ) );
i.forEach( sel => document.querySelectorAll( `[id*=${sel}]`).forEach( e => e.remove() ) );
@AdrianJMartin
AdrianJMartin / spiral.cpp
Created August 27, 2024 12:37
number spiral generator
#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <ranges>
#include <string>
#include <vector>
@AdrianJMartin
AdrianJMartin / inotifywait-example.md
Last active September 3, 2024 16:54
use inotifywait with vscode and nodejs - can be adapted for other build chains
inotifywait -e close_write node-scratch.js -m | while read -r filename ; do node $filename ; done
function createRandomSentence(): String {
const randomWords = [
"apple", "banana", "cherry", "date", "elderberry", "fig", "grape", "honeydew", "kiwi", "lemon",
"mango", "nectarine", "orange", "papaya", "quince", "raspberry", "strawberry", "tangerine", "ugli", "vanilla",
"watermelon", "xigua", "yellowfruit", "zucchini", "apricot", "blueberry", "cantaloupe", "dragonfruit", "eggplant", "fennel",
"ginger", "huckleberry", "iceberg", "jicama", "kale", "lime", "mushroom", "nutmeg", "olive", "pear",