Skip to content

Instantly share code, notes, and snippets.

View taroved's full-sized avatar

Alexandr Nesterenko taroved

View GitHub Profile
@taroved
taroved / httpclient.py
Last active September 21, 2023 15:41
Http client console code. Usage: python httpclient.py https://www.esquire.com/
#!/usr/bin/env python
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
This example demonstrates how to make a simple http client.
Usage:
httpclient.py <url>
#!/usr/bin/env python
# -*- test-case-name: twisted.names.test.test_examples -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Print the IP address for a given hostname. eg
python gethostbyname.py www.google.com
@taroved
taroved / archive_huge_dir.sh
Last active August 29, 2015 14:00
Bash script which silently compress directory with millions of files into directory structure like this: /target/directory/2014/12/millions.tar.gz (!and delete source files!)
#!/bin/bash
#example of archiving 2013 year of directory /path/to/source/dir/subdir with 512k speed limit:
#>> ./archive_huge_dir.sh -S /path/to/source/dir -T /path/to/target/dir -L 512k -n subdir -y 2013
#example of archiving december of 2013 year of directory /path/to/source/dir/millions_files_subdir with 512k speed limit:
#>> ./archive_huge_dir.sh -S /path/to/source/dir -T /path/to/target/dir -L 512k -n subdir -y 2013 -m 12
#example of archiving several years with 512k speed limit:
#>> for year in `seq 2009 2013`; do ./archive_huge_dir.sh -S /path/to/source/dir -T /path/to/target/dir -L 512k -n subdir -y $year -Y ; done
function curtime { date +"%F %T"; }
function echotime { echo `curtime`" $@"; }
@taroved
taroved / archive_millions_files_dir.sh
Last active August 29, 2015 13:59
Obsolete! Use https://gist.github.com/taroved/11269983 instead. (Bash script which silently compress directory with millions of files into directory structure like this: /target/directory/2014/12/millions.tar.gz (!and delete source files!))
#!/bin/bash
#example of archiving 2013 year of directory /path/to/source/dir/millions_files_subdir with 512k speed limit:
#>> archive_millions_files_dir.sh 512k millions_files_subdir 2013
#example of archiving december of 2013 year of directory /path/to/source/dir/millions_files_subdir with 512k speed limit:
#>> archive_millions_files_dir.sh 512k millions_files_subdir 2013 12
#example of archiving several years with 512k speed limit:
#>> for year in `seq 2010 2013`; do for subdir in `ls /path/to/source/dir`; do archive_millions_files_dir.sh 512k $subdir $year; done; done
SOURCE_DIR=/path/to/source/dir
TARGET_DIR=/path/to/target/dir