Skip to content

Instantly share code, notes, and snippets.

View tzermias's full-sized avatar

Zacharias Tzermias tzermias

View GitHub Profile
@tzermias
tzermias / ip_forward.md
Last active March 20, 2024 02:06
Forward traffic from wlan0 to eth0 interface

Forward traffic from a laptop's eth0 to wlan0

###To laptop

Specify an IP address to eth0 (here 192.168.56.1)

sudo ifconfig eth0 192.168.56.1 netmask 255.255.255.0
@tzermias
tzermias / pipelines.py
Last active March 14, 2024 23:35
Scrapy MySQL pipeline. Just a mirror to the asynchronous MySQL pipeline. Copy-paste it directly to pipelines.py. Database credentials are stored in settings.py. Based on http://snipplr.com/view/66986/
import MySQLdb.cursors
from twisted.enterprise import adbapi
from scrapy.xlib.pydispatch import dispatcher
from scrapy import signals
from scrapy.utils.project import get_project_settings
from scrapy import log
SETTINGS = get_project_settings()
@tzermias
tzermias / meme.sh
Created February 10, 2021 17:24
Meme Generator using ImageMagick
#!/bin/bash
# meme.sh
# Meme generator with ImageMagick
# https://www.it-cooking.com/technology/digital-image/image-processing/meme-generator-imagemagick/
usage() {
echo "Usage: $0 [ -t TOP_MSG ] [ -b BOTTOM_MSG ] SRC DST"
}
failure() {
@tzermias
tzermias / .tmux.conf
Last active October 15, 2020 20:42
My tmux config
# Set Ctrl+a as a prefix
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Indexes
set -g base-index 1
set -g pane-base-index 1
# Split panes
ffmpeg -r 12 \
-pattern_type glob -i 'photos/*.jpg' \
-i audio.mp3 \
-filter:v 'tblend,fade=t=in:s=0:d=2,fade=out:675:24' \
-filter:a 'afade=in:ss=0:d=2,afade=t=out:st=56:d=3' \
-vcodec libx264 -acodec mp3 panorama.mp4
#!/bin/sh
# Collect photos from penteli.meteo.gr and save them to a directory.
# github.com/tzermias
DOWNLOAD_DIR="$(dirname $0)/photos"
FILENAME="panorama_$(date +%s).jpg"
URL="https://penteli.meteo.gr/stations/penteli/webcam/panorama.jpg"
# Create directory to save images, if non-existent.
@tzermias
tzermias / slack-df.py
Created January 16, 2018 12:34
Calculate file usage per user for shared files in Slack
#!/usr/bin/env python
import requests
import json
# Calculate file usage per user for shared files in Slack
# zacharias.tzermias@gmail.com
API_ENDPOINT="https://slack.com/api/%s"
TOKEN = "YOUR-TOKEN-HERE"
#!/bin/bash
CGI_URL="https://server/icinga/cgi-bin"
USERNAME=""
PASSWORD=""
out=$(curl --silent -u $USERNAME:$PASSWORD "$CGI_URL/status.cgi?jsonoutput&servicestatustypes=28" |jq .status.service_status[].status 2>&1)
echo $out | awk 'BEGIN {RS=" ";d=0;c=0;u=0;w=0}
@tzermias
tzermias / DHT22_BMP180.ino
Last active March 2, 2016 16:34
Sketch that combines measurements from DHT22 and BMP180 sensors
// Sketch that combines measurements from DHT22 and BMP180 sensors
// and prints them to serial.
// Aris Tzermias (github.com/tzermias)
// Pinout on Arduino Leonardo/Yun.
// Pin 2: SDA (BMP180)
// Pin 3: SCL (BMP180)
// Pin 4: DHT22
#include "DHT.h"
@tzermias
tzermias / rate_limit.py
Created January 14, 2014 13:03
Find which method of the Twitter API (via tweepy) doesn't have any available requests.
rate_limit = api.rate_limit_status()
[key2 for key in rate_limit['resources'] for key2 in rate_limit['resources'][key].keys() if rate_limit['resources'][key][key2]['remaining']==0]