Skip to content

Instantly share code, notes, and snippets.

View ppdms's full-sized avatar

Basil Papadimas ppdms

  • Informatics, AUEB
  • Athens, Greece
View GitHub Profile
@ppdms
ppdms / configuration.yml
Created June 15, 2024 17:51
Home Assistant configuration.yml snippet for Adaptive Lighting statistics
adaptive_lighting:
template:
- sensor:
- name: "Sun Position"
unit_of_measurement: "°"
state: "{{ state_attr('switch.adaptive_lighting', 'sun_position') }}"
state_class: measurement
- name: "Adaptive Color Temperature"
@ppdms
ppdms / walküre.sh
Last active May 14, 2024 08:48
Notify Discord with webhook if there's tickets for a GNO performance
#!/bin/bash
######################################################################
# @author : Vasileios Papadimas (papadimas@protonmail.com)
# @file : tickets.sh
# @created : Sunday Mar 24, 2024 20:23:31 EET
######################################################################
output=$(curl -s 'https://www.ticketservices.gr/event/gno-die-walkuere/?lang=el' | iconv -f "windows-1253" -t UTF-8)
.text
.globl _start
_start:
lw $t0, newl
li $t1, 0
main:
li $v0, 12
#include <cmath>
#include <iostream>
#include <ostream>
using std::cout;
using std::endl;
int main(int argc, char *argv[]) {
float x = 1;
while (7 + x != 7) {
@ppdms
ppdms / combinations.s
Created November 21, 2023 10:42
Calculate binomial coefficient in MIPS32 assembly
.text
.globl __start
_start:
la $a0, pn
li $v0, 4
syscall # print prompt for n
la $v0, 5
syscall # read n into $v0
/**
* @author : Vasileios Papadimas (papadimas@protonmail.com)
* @file : floatExpose.cpp
* @created : Saturday Oct 28, 2023 14:28:58 EEST
*/
#include <bitset>
#include <iostream>
#include <ostream>
using std::cout;
@ppdms
ppdms / newton.py
Created August 18, 2023 15:01
math1, cs@aueb, 2022
from tabulate import tabulate
def newton(f,fprime, x, M, Ef):
x=[x]
n=0
results = [["n", "x_n", "f(x_n)", "f\'(x_n)"],
[n, round(x[n], 8), round(f(x[n]), 8), round(fprime(x[n]), 8)]]
while n<M and abs(f(x[n])) > Ef and abs(fprime(x[n]))>0:
x.append(x[n] - f(x[n]) / fprime(x[n]))
n=n+1
@ppdms
ppdms / picSort.py
Created December 31, 2022 19:26
sort lecture photos into folders according to concurrent lectures
from PIL import Image
from datetime import datetime, timedelta
from os import listdir
from shutil import move
import re
filenames = listdir("images/")
schedule = [ # weekday, start, name
[0, 9, "Discrete"],
@ppdms
ppdms / sync.py
Created December 31, 2022 14:30
add events to Google Calendar from a Sheets spreadsheet
# WARNING: deletes all events in specified time range (line 53)
# see https://docs.google.com/spreadsheets/d/1Iwd2qV-xbHgyDU2YKQr7UedLvYhVsEmxciuPsk5rLA0/ for example spreadsheet layout
# there should be a credentials.json file in your working directory: see https://developers.google.com/calendar/api/quickstart/python#authorize_credentials_for_a_desktop_application
# also, properly setup your project's authorization screen to include both required scopes.
# code based on https://github.com/googleworkspace/python-samples/blob/main/calendar/quickstart/quickstart.py (and sheets equivalent)
from __future__ import print_function
import os.path
from google.auth.transport.requests import Request
@ppdms
ppdms / rotatePasscode.py
Last active January 28, 2022 09:14
automatically changes your Screen Time passcode on Mac
#!/usr/bin/python3
# it does what it says on the tin
# TODO: remove accesibility permission requirement
from pyautogui import write
from time import sleep
from random import randint