Skip to content

Instantly share code, notes, and snippets.

@Nama
Nama / del.py
Last active December 27, 2015 00:59
Deleting of incoming and outdated SQL backups. Using with crontab.
#!/usr/bin/env python3
#Deleting of incoming and outdated SQL backups - Using with crontab
import os, re
d_list = sorted( #Filenames containing unix-timestamp, sorted() will set 'd_list' ordered, from old to new
re.findall(r'\w+\.sql\.gz', #searching for filenames
','.join(os.listdir('/home/kirika')))) #Listing all files in directory and putting them comma-seperated together
for i in range(len(d_list)-4): #Count of found files -4
os.remove(d_list[i]) #the newest 4 files wont be deleted
@Nama
Nama / Yscreens.py
Created January 5, 2014 11:39
Screenshot and file upload via SSH. For windows. https://github.com/Nama/Yscreens
import os
import sys
import base64
import paramiko
import pyperclip
import configparser
from PIL import ImageGrab
from balloons import WindowsBalloonTip
config = configparser.ConfigParser()
@Nama
Nama / ybot.py
Created January 5, 2014 11:48
IRC-Bot with broadcast and triggers. https://github.com/Nama/kirika
#! /usr/bin/env python
'''Yama's A.T.S.P.-Bot for IRC-Tasks'''
import irc.bot
import irc.strings
import re
import logging
import configparser
from time import sleep
from multiprocessing import Process
on ^*:text:* has logged in.*:#yamaria: {
/echo -tm #terraria $1-
/haltdef
}
on ^*:text:* left the server.*:#yamaria: {
/echo -tm #terraria $1-
/haltdef
}
@Nama
Nama / lights.sh
Last active August 29, 2015 14:06
Sends TCP Pakets to the TCP Server. Turns on lights if Computer is reachable, off if not reachable. lights_state.sh syncs the states of the lights, so the lights are turned on on next day. Avoids turning off or on if you manually turned on or off the lights.Used with crontab.
#!/bin/bash
/usr/local/bin/ping -c 1 192.168.1.2
ec=$?
state=`cat /root/light2_state`
stat=`echo -e "licht 2 status" | nc 192.168.1.3 54321`
s=$((${#stat}-1))
stat=${stat:$s:1}
echo "nc: $stat"
echo "file: $state"
@Nama
Nama / highlight.mrc
Created October 20, 2014 18:39
Incomplete Highlight and Balloon-Notification Script for mIRC
;--------------------------------------------------- - - - -
;| Yama Control Highlight © 14.09.2008
;--------------------------------------------------- - - - -
;| Version: 3.5
;| mIRC: v6.3
;| Script-Planung: Yama
;| Script-Mod: Chialya
;--------------------------------------------------- - - - -
;| Beschreibung: Markiert die Zeile und spielt Ai.mp3 ab,
;| sobald die Nicks gerufen werden.
@Nama
Nama / homecontrol_client.py
Last active August 29, 2015 17:32
Control radio sockets and Senseo coffee machine with NetIO-App and do some other stuff. Github Repo: https://github.com/Nama/HomeControl
#!/usr/bin/python
import os
import sys
import socket
import time
from PIL import Image
from lglcd import LogitechLcd
from threading import Thread
@Nama
Nama / shorturl.py
Created July 2, 2015 17:58
URL shortener, written in Python with flask
#!/usr/bin/env python
#########################################################################################
# #
'''A.T.S.P. Short-URL Controller''' #
# #
#########################################################################################
import cymysql
from flask import Flask, redirect
app = Flask(__name__)
@Nama
Nama / lg_color_switcher.lua
Created July 2, 2015 20:15
Small script for Logitech keyboards with different backlight colors. Changes the color of the backlight permanently, smooth! Shouldnt be hard to make it use on keyboards with just two colors.
function OnEvent(event, arg)
if (event == "PROFILE_ACTIVATED") then
color()
end
end
function color()
r1 = 0
g1 = 0
b1 = 0
@Nama
Nama / ssh-tunnel_update.sh
Created July 14, 2015 08:11
Use a proxy 5 server to update packages on a Linux machine
#!/bin/bash
REPOFILE="glusterfs-3.7.list"
SSHSERVER="ssh.server"
SSHUSER="username"
# Kopiere das Repo, damit es verwendet werden kann
cp $REPOFILE /etc/apt/sources.list.d/
if [[ $? -eq 0 ]]; then
# SSH-Tunnel über den user "tunnel" zum Login-Server, welcher im Hintergrund bleibt,