Skip to content

Instantly share code, notes, and snippets.

View ykhrustalev's full-sized avatar

Yuri Khrustalev ykhrustalev

View GitHub Profile
@ykhrustalev
ykhrustalev / gist:3899173
Created October 16, 2012 13:09
flush iptables
#!/bin/sh
echo "Flushing iptables rules..."
sleep 1
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
# source http://small-code.blogspot.ru/2008/05/nslookup-in-python.html
from socket import gethostbyaddr
def nslooky(ip):
try:
output = gethostbyaddr(ip)
return output[0]
except:
output = "not found"
return output
http://serverfault.com/a/316704/69170
netstat -ptu will give you the owning process ids (along with standard netstat info) for all tcp and udp conections. (Normal users will not be able to id all processes.)
If something is sending out a fair amount of constant traffic you should see it on Recv-Q or Send-Q columns 2 and 3 respectively.
Examples:
Recv-Q
sudo watch -n .1 'netstat -tup | grep -E "^[t,u]cp[6]{0,1}" | sort -nr -k2'
#!/usr/bin/env python
import grp
import json
import logging
import optparse
import os
import pwd
import re
import subprocess
logger = None
def configure_loggging():
global logger
fmt = logging.Formatter(logging.BASIC_FORMAT)
stream = logging.StreamHandler()
stream.setLevel(logging.DEBUG)
stream.setFormatter(fmt)
@ykhrustalev
ykhrustalev / gfid-resolver.sh
Created May 24, 2016 14:04 — forked from louiszuckerman/gfid-resolver.sh
Glusterfs GFID Resolver Turns a GFID into a real path in the brick
#!/bin/bash
if [[ "$#" < "2" || "$#" > "3" ]]; then
cat <<END
Glusterfs GFID resolver -- turns a GFID into a real file path
Usage: $0 <brick-path> <gfid> [-q]
<brick-path> : the path to your glusterfs brick (required)
def makedirs(path)
cur_path = ''
path.split('/').each do |sub_directory|
cur_path = "#{cur_path}/#{sub_directory}"
Dir.mkdir(cur_path) unless File.directory?(cur_path)
end
end
from __future__ import print_function
import SimpleHTTPServer
import SocketServer
import sys
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)

Keybase proof

I hereby claim:

  • I am ykhrustalev on github.
  • I am ykhrustalev (https://keybase.io/ykhrustalev) on keybase.
  • I have a public key whose fingerprint is 2831 1FF8 46F6 901F 5E2C 9301 9232 2AE1 BF49 B600

To claim this, I am signing this object:

@ykhrustalev
ykhrustalev / StorageHelper.ts
Created March 25, 2018 13:48 — forked from Digiman/StorageHelper.ts
Simple helper module on TypeScript for using local storage (HTML5) in browser. Also have the class to store the list of emails that need to use for autocomplete in the some pages.
// module with classes and logic for working with local storage in browsers via JavaScript
// see also: http://professorweb.ru/my/html/html5/level5/5_1.php
module StorageHelper {
export interface IStorageItem {
key: string;
value: any;
}
export class StorageItem {
key: string;