Skip to content

Instantly share code, notes, and snippets.

View ofalvai's full-sized avatar

Olivér Falvai ofalvai

View GitHub Profile
@ofalvai
ofalvai / CustomSleepComponent.h
Last active October 8, 2022 20:21
Custom ESPHome deep sleep component that's controlled via MQTT (adjustable sleep duration, sleep enter trigger)
#include "esphome.h"
#include "driver/rtc_io.h"
class CustomSleepComponent : public Component, public CustomMQTTDevice {
public:
void setup() override {
subscribe(TOPIC_SLEEP_DURATION, &CustomSleepComponent::on_sleep_duration_message);
subscribe(TOPIC_SLEEP_PREVENT, &CustomSleepComponent::on_prevent_message);
subscribe(TOPIC_SLEEP_ENTER, &CustomSleepComponent::on_enter_message);
@ofalvai
ofalvai / szepkartya.py
Last active February 28, 2024 10:12
OTP SZÉP Kártya parser
import requests
from bs4 import BeautifulSoup as bs
import re
import json
CARD_NUMBER = 12345678
CARD_CODE = 678
URL_API = 'https://magan.szepkartya.otpportalok.hu/ajax/egyenleglekerdezes/'
URL_HTML = 'https://magan.szepkartya.otpportalok.hu/fooldal/'
@ofalvai
ofalvai / StravaBulkEdit.js
Last active June 28, 2017 18:50
Strava activity shoes bulk edit
/**
* Works on https://www.strava.com/athlete/training
* Overwrites all activities on the current page (use the pagination at the bottom!)
*/
var SHOE_INDEX = 2; // Starts with 0!
jQuery("#search-results tr").each((i, el) => {
var shoeSelect = jQuery(el).find("select.shoe-id").get(0);
jQuery(shoeSelect).children().eq(SHOE_INDEX).attr("selected", "selected");
jQuery(el).find("button[type='submit']").click();
})

Keybase proof

I hereby claim:

  • I am ofalvai on github.
  • I am ofalvai (https://keybase.io/ofalvai) on keybase.
  • I have a public key whose fingerprint is 36E6 EC06 D9EF 1CF8 07C9 1F50 086A B573 B5E5 2F1F

To claim this, I am signing this object:

@ofalvai
ofalvai / stat.sh
Created July 2, 2013 20:02
My little script to check the Raspberry Pi's status over SSH.
#!/bin/bash
let freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)/1000
temp=$(vcgencmd measure_temp)
temp=${temp:5}
wifi=$(cat /proc/net/wireless | grep wlan0 | awk {'print $4'} | tr -d .)
read one five fifteen rest < /proc/loadavg
@ofalvai
ofalvai / Snippyts.py
Last active December 17, 2015 06:08
Hasznos snippetek, amik jól jönnek az infó érettségihez, ha Pythonban programozol.
# Ide jönnek majd a hasznos snippetek
# Whitespace trim:
str.strip()
# Dict/List rendezése megadott kulcs alapján, pl. az elem hossza
sorted(dict, key=lambda x: len(x))
# Dict elemének értéke alapján:
sorted(dict, key=lambda x: dict[x])