Skip to content

Instantly share code, notes, and snippets.

View agent47nh's full-sized avatar
🤖
Beep bop beep bop...

Naim agent47nh

🤖
Beep bop beep bop...
View GitHub Profile
@agent47nh
agent47nh / zha-ikea-trafri-e1743-onoff-switch.yaml
Last active June 1, 2024 15:09
ZHA - IKEA Tradfri ON/OFF Switch (Blueprint)
blueprint:
name: ZHA - IKEA Tradfri ON/OFF Switch
description: 'Control lights with an IKEA Tradfri ON/OFF Switch (the small square ones),
for use with [ZHA](https://www.home-assistant.io/integrations/zha/).
Pressing the ON button will turn on the lights at the last set brightness (unless
the force brightness is toggled on in the blueprint).
Pressing the OFF button will turn the lights off again.
@agent47nh
agent47nh / add_user.sh
Created January 15, 2023 17:05
Add user with SSH key, first argurment must be a valid username and second argument should be a valid SSH key. It also adds user to sudoers file, enabling the user to run super user command without password.
#!/usr/bin/env bash
NEWUSER="$1"
SSHKEY="$2"
# run script as superuser
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
@agent47nh
agent47nh / mysteriousOrganism.js
Created February 1, 2022 22:18
[Solution] Challenge Project by CodeAcademy on Back-End Engineer Career Path
// Returns a random DNA base
const returnRandBase = () => {
const dnaBases = ['A', 'T', 'C', 'G'];
return dnaBases[Math.floor(Math.random() * 4)];
};
// Returns a random single stand of DNA containing 15 bases
const mockUpStrand = () => {
const newStrand = [];
for (let i = 0; i < 15; i++) {
@agent47nh
agent47nh / credit-card-checker.js
Last active February 1, 2022 21:30
[Solution] Challenge Project by CodeAcademy on Back-End Engineer Career Path
// All valid credit card numbers
const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8]
const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9]
const valid3 = [3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6]
const valid4 = [6, 0, 1, 1, 1, 4, 4, 3, 4, 0, 6, 8, 2, 9, 0, 5]
const valid5 = [4, 5, 3, 9, 4, 0, 4, 9, 6, 7, 8, 6, 9, 6, 6, 6]
// All invalid credit card numbers
const invalid1 = [4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5]
const invalid2 = [5, 7, 9, 5, 5, 9, 3, 3, 9, 2, 1, 3, 4, 6, 4, 3]