Skip to content

Instantly share code, notes, and snippets.

@imduffy15
imduffy15 / cloud.cfg
Last active April 9, 2024 07:15
Cloud-init config example for using the none data source provider to setup a box for usage with vagrant on finding no cloud metadata service.
disable_ec2_metadata: True
datasource_list: [ "ConfigDrive", "None"]
datasource:
None:
userdata_raw: |
#!/bin/bash
groupadd vagrant
useradd -d /home/vagrant -s /bin/bash -m -g vagrant -G wheel vagrant
echo "root:vagrant" | chpasswd
#!/usr/bin/env python
import json
import requests
import urllib3
urllib3.disable_warnings()
cookie = open("cookie.txt").readline().strip()
csrf_token = [x.split("=") for x in cookie.split(";") if "csrf" in x][0][1]
package main
import (
"crypto/tls"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
)
@imduffy15
imduffy15 / README.md
Created February 11, 2023 13:43
My home assistant organiser

cleaner.py

This hides things and renames things.

area-assigner.py

This assigns things to areas based on their name

alexa-sync.py

@imduffy15
imduffy15 / OS-Tutorials.md
Last active August 16, 2022 13:21
Tutorial answers from CA321

Week 1

An OS does basically two things. What are they?

Software that provides a programmer friendly interface between application programs and the hardware by providing a virtual environment to applications.

Software that handles resource requests from application programs and prevents applications from trampling each other.

Describe the two interfaces to an operating system

@imduffy15
imduffy15 / motion_controlled_scenes_enhanced.yaml
Last active July 5, 2021 22:30 — forked from quallenbezwinger/motion_controlled_scenes_enhanced.yaml
Homeassistant blueprint for motion-activated light scene with surrounding light level check
blueprint:
name: Motion-activated light scene with surrounding light level check and optional ambient scene
description: Turn on a light scene when motion is detected. Three different scenes can be defined depending on time of day. Furthermore a source for checking sourrounding light can be defined to enable light only if it is dark enough.
domain: automation
source_url: https://gist.github.com/dirkk1980/3e5c23acb05fb639bafdc5036b91aae6
input:
motion_entity:
name: Motion Sensor
selector:
entity:
@imduffy15
imduffy15 / LargestFromTextFile.java
Created October 12, 2013 18:42
Find largest number in a text file with java
import java.io.*;
import java.util.*;
class LargestFromTextFile {
public static void main(String[] args) {
try {
Scanner file = new Scanner(new File("numbers.txt"));
int largest = file.nextInt();
while(file.hasNextInt()) {

OpenTelemetry Problem

The kafka producer doesn't appear to get the traceId of the scope its wrapped in.

#!/bin/sh
SSH_PUBLIC_KEY='insert_your_ssh_public_key_here'
function add_ssh_public_key() {
cd
mkdir -p .ssh
chmod 700 .ssh
echo "$SSH_PUBLIC_KEY" >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
FROM debian:buster-slim
# Install Chrome
RUN apt-get update \
&& apt-get install -y --no-install-recommends software-properties-common \
&& apt-add-repository contrib \
&& apt-get update \
&& apt-get install -y \
apt-transport-https \
ca-certificates \