Skip to content

Instantly share code, notes, and snippets.

View orymate's full-sized avatar

Máté Őry orymate

  • Budapest, Hungary
  • 00:34 (UTC +02:00)
View GitHub Profile
@orymate
orymate / Code.gs
Created October 12, 2023 15:18
archive mails based on labels and time spent in inbox
function parseInterval(s) {
var matches = new RegExp("^expire-([0-9]+)([mhdDwM])$").exec(s);
if (!matches) {
return null;
}
var count = parseInt(matches[1]);
var unit = matches[2];
var date = new Date();
switch (unit) {
case "M":
@orymate
orymate / .i3blocks.conf
Last active May 8, 2018 07:47
Brightness control for i3blocks ThinkPad T470P
[brightness]
label=BRI
command=/home/maat/.i3/brightness
interval=5
@orymate
orymate / ip.py
Created September 25, 2016 21:05
IP4 and IP6 classes for use in SaltStack python state files (without netaddr)
class IP4(object):
"""
>>> print IP4("10.150.42.23") & IP4("255.255.0.0") | IP4("0.0.255.254")
10.150.255.254"""
def __init__(self, s="0.0.0.0"):
s = str(s)
self.ip = [int(i) for i in s.split(".")]
assert len(self.ip) == 4
assert all(0 <= i <= 255 for i in self.ip)
@orymate
orymate / wut.sh
Created September 24, 2016 10:13
Show last salt state run's result in a more verbose format
wut () {
case "$1" in
full|terse|mixed|changes|filter) so=$1; shift ;;
v|verbose|-v) so=full; shift ;;
esac
job=$(salt-run jobs.list_jobs --out=json |
jq -r '[to_entries[]|select(.value|.Function|contains("state")).key]|max')
salt-run --force-color --out=highstate --state-output=${so:-full} \
"$@" jobs.lookup_jid $job |& less -r
}
// https://codeload.github.com/niesteszeck/idDHT11/zip/master
#include "DHT.h"
DHT dht;
void setup()
{
Serial.begin(9600);
Serial.println();
Serial.println("Pin\tStatus\tHumidity (%)\tTemperature (C)");
@orymate
orymate / sl.sls
Last active April 6, 2016 17:56
Salt gyakorlat
sl:
pkg.installed
xinetd:
pkg:
- installed
service.running:
- require:
- pkg: xinetd
- watch:
@orymate
orymate / pkcs.sh
Created January 28, 2016 16:13
Certificate chain sorter
#!/bin/bash
if [ -z "$1" -o ! -f "$1" ]; then
echo Usage: $0 pkcs-file-name
exit 1
fi
openssl pkcs12 -in "$1" -nodes -out /dev/stdout |awk '/BEGIN/,/END/' | bash $(dirname $0)/sortchain.sh
#!/usr/bin/env python
from optparse import OptionParser
from subprocess import check_call
def main():
parser = OptionParser("usage: %prog [options] fqdn")
parser.add_option("-d", "--dry-run",
action="store_true", dest="dry_run")
/usr/local/sbin/rescan-scsi:
file.managed:
- mode: 755
- contents: |
#!/bin/bash
echo Before:
awk '/sd/{print $4, int(int($3)/1024/1024) "G"}' /proc/partitions
# find new devices
echo "- - -" | tee /sys/class/scsi_host/host*/scan
# rescan disk sizes (detect extension)
@orymate
orymate / etc_xinetd.d_beep
Last active August 29, 2015 14:27
vnc wall (minőségi szolgáltatás)
service beep
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/local/bin/beep.sh
server_args = -l 400
disable = no
}