Skip to content

Instantly share code, notes, and snippets.

@jaysridhar
jaysridhar / ImageBatchConverter.py
Created March 23, 2021 10:14
Python Pillow example code for batch conversion of image files in a directory from one format (PNG, JPG, GIF, etc) to another.
#!/usr/bin/python
import argparse, glob, os
from PIL import Image
formats = ["BMP", "DIB", "EPS", "GIF", "ICNS", "ICO", "IM", "JPG", "JPEG",
"J2K", "J2P", "JPX", "MSP", "PCX", "PNG", "PPM", "SGI",
"SPIDER", "TGA", "TIFF", "WebP", "XBM"]
parser = argparse.ArgumentParser(description="Pillow example - batch converter.")
parser.add_argument('-outdir', default='.', help='Directory to save converted image files')
@jaysridhar
jaysridhar / Squid-Installation-Ubuntu-18.04-from-source.md
Last active June 21, 2023 09:53
Installing Squid proxy on Ubuntu 18.04 by building from source

Installing prequisites

apt install g++
apt install make
apt install libssl1.0-dev

Building package

@jaysridhar
jaysridhar / Ubuntu-KVM.md
Last active March 14, 2023 18:19
Setting up virtual machines on Ubuntu using KVM

Started with Ubuntu 18.04 LTS minimal install on KVM host

Installed the following KVM related packages

Running as root, obviously:

apt install -y qemu-kvm libvirt-bin bridge-utils virtinst
@jaysridhar
jaysridhar / CSV.java
Last active March 1, 2023 16:17
Java CSV Reader module. Drop into any project and use. Supports Excel compatible CSV (multi-line columns, etc).
package sample;
import java.io.InputStream;
import java.io.PushbackInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.BufferedReader;
import java.util.List;
import java.util.ArrayList;
@jaysridhar
jaysridhar / README.md
Last active September 26, 2022 11:15
Download all attachments from a Trac site

Download All Attachments from Trac

This is a simple script for downloading all attachements from all tickets in Trac. I looked around and found nothing to fit my needs so here is a script I whipped up. It uses BeautifulSoup4 to crawl the pages, and requests to fetch the content.

Installation

$ virtualenv venv
$ . venv/bin/activate
$ pip install -r requirements.txt

Following netplan creates a virtual bridge br0 connected to interface enp2s0 and both have same mac address (as required by hetzner)

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
 match: