Skip to content

Instantly share code, notes, and snippets.

View hostmaster's full-sized avatar
🏠
Working from home

Igor Khomyakov hostmaster

🏠
Working from home
  • Russia, Saint Petersburg
View GitHub Profile
@hostmaster
hostmaster / s3-bucket-move
Created December 15, 2016 15:45 — forked from alanwill/s3-bucket-move
Move an S3 bucket to a different region
aws s3 sync s3://oldbucket s3://newbucket --source-region us-west-1 --region us-west-2
@hostmaster
hostmaster / iptables_rules.sh
Created December 5, 2016 09:40 — forked from virtualstaticvoid/iptables_rules.sh
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
#!/bin/bash
URL=http://S3_BUCKET.s3.amazonaws.com/FILENAME
filename=FILENAME
S3_MD5=$(curl -s -I -L $URL | awk '/ETag/ { gsub(/"|\r/,"",$2); print $2 }')
MD5="$(md5 -q $filename 2>/dev/null || :)"

Keybase proof

I hereby claim:

  • I am hostmaster on github.
  • I am hostmaster (https://keybase.io/hostmaster) on keybase.
  • I have a public key ASB5pWJf3Qws6exTwpuyHRSwczPADj4INmuJHFrJLm_b_Qo

To claim this, I am signing this object:

- name: Deploy authorized_keys for the user(s)
authorized_key: user="{{ item }}" key="$FILE(roles/common/files/{{ item }}.pub)" state=present
with_items: ${admin_users}
@hostmaster
hostmaster / xfs_prealloc.c
Created December 11, 2013 12:56
XFS preallocation gist
/ * lr = ((__int64_t)random() << 32) + random(); */
off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
off %= maxfsize;
fl.l_whence = SEEK_SET;
fl.l_start = off;
fl.l_len = (off64_t)(random() % (1024 * 1024));
e = xfsctl(f.path, fd, XFS_IOC_RESVSP64, &fl) < 0 ? errno : 0;
@hostmaster
hostmaster / somecode.py
Created December 10, 2013 10:30
import urllib module for py2 and py3
import sys
if sys.version > '3':
from urllib.request import urlopen
else:
from urllib import urlopen
@hostmaster
hostmaster / server.conf
Created December 6, 2013 07:06
sslh + openvpn/tcp/443
local 127.0.0.1
port 1194
proto tcp
dev tun
remote-cert-tls client
log-append /var/log/openvpn.log
ca keys/ca.crt
cert keys/server.crt
key keys/server.key
dh keys/dh1024.pem
@hostmaster
hostmaster / net_ping_legacy.pl
Last active December 29, 2015 10:39
backward compatible ssh port check
sub ssh_is_ok {
my $ip = shift;
my $p = Net::Ping->new('tcp', $PORT_PROBE_TIMEOUT);
if ( $Net::Ping::VERSION <= 2.31 ) {
$p->{port_num} = getservbyname("ssh", "tcp");
} else {
$p->port_number($SSH_PORT);
}