Skip to content

Instantly share code, notes, and snippets.

View gauravssnl's full-sized avatar
😸
use code::latest ;

GAURAV gauravssnl

😸
use code::latest ;
View GitHub Profile
@gauravssnl
gauravssnl / ping.py
Created December 14, 2016 17:50 — forked from pklaus/ping.py
A pure python ping implementation using raw socket.
#!/usr/bin/env python2
"""
Other Repositories of python-ping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* https://github.com/l4m3rx/python-ping supports Python2 and Python3
* https://bitbucket.org/delroth/python-ping
@gauravssnl
gauravssnl / ping.py
Created December 14, 2016 17:54 — forked from pyos/ping.py
import time
import random
import struct
import select
import socket
def chk(data):
x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF
x = (x >> 16) + (x & 0xFFFF)
@gauravssnl
gauravssnl / nope.py
Created December 14, 2016 17:57
This imports something from the parent dir of the script file in a very nasty way.
# This is some butt ugly fuckery that basically chdirs to the
# directory that is parent to this source file, imports the
# test subject from the main script, then de-imports (not really
# cause Python doesn't support that) the stuff that it needed to
# do that as not to pollute the name space and cause tests to
# possibly fail because of that.
#
# In order for this to work it's imperative that you:
# - Have the main script on the parent directory to the one
# this script file is in.
@gauravssnl
gauravssnl / keysmith.py
Created December 14, 2016 17:57
🔑 Generates and validates random url-safe user-readable strings.
from os import urandom
from base64 import b64encode
from string import ascii_letters, digits
def randkey(size=6, altchars=b'+.', ambiguous=b'IlO9GUS'):
key = ''
while len(key) < size:
chunk = b64encode(urandom(size*2), altchars)
key += str(bytes([c for c in chunk if c not in ambiguous]), encoding='utf-8')
@gauravssnl
gauravssnl / fetch-conference.py
Created December 14, 2016 17:58 — forked from pklaus/fetch-conference.py
Downloading Slides from Indico
#!/usr/bin/env python
"""
Tool to download conference information from Indico
"""
import json, argparse, sys, re, logging, os, importlib
logger = logging.getLogger(__name__)
logging.basicConfig(format='%(levelname)s: %(message)s')
@gauravssnl
gauravssnl / convert-pickle-version.py
Created December 14, 2016 18:00 — forked from pklaus/convert-pickle-version.py
A command line tool to convert between pickle protocol versions
#!/usr/bin/env python
import pickle
import argparse
import sys
def main():
parser = argparse.ArgumentParser(description='Convert between pickle protocol versions.')
parser.add_argument('input_file')
parser.add_argument('output_file')
# coding=utf-8
"""
LICENSE http://www.apache.org/licenses/LICENSE-2.0
"""
import datetime
import sys
import time
import threading
import traceback
import SocketServer
@gauravssnl
gauravssnl / ddns.py
Created December 14, 2016 18:16 — forked from pklaus/ddns.py
A script to update the A and AAAA RRs of HOSTNAME on a DNS server according to your current external IP address using nsupdate / TSIG. This script is tested to run on Mac OS X (10.8-10.9) but you should be able to get it up and running in almost no time on any Unix or Linux system that ships nsupdate. I use this script to update my own DDNS serv…
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Written on 2013-02-04 by Philipp Klaus <philipp.l.klaus →AT→ web.de>.
Check <https://gist.github.com/4707775> for newer versions.
Uses dnspython: install with `pip install dnspython3`
"""
@gauravssnl
gauravssnl / dnsupdate.py
Created December 14, 2016 18:16 — forked from pklaus/dnsupdate.py
dnsupdate is meant to replace nsupdate, the standard DDNS update tool created by BIND authors ISC. While nsupdate does the job it is awkward to wrap in scripts and its usage in general is just not very intuitive. dnsupdate is meant to work well from the command line or from scripts and easy to use. It also does some nice things like automaticall…
#!/usr/bin/env python2.7
# Matt's DNS management tool
# Manage DNS using DDNS features
#
# See http://planetfoo.org/blog/archive/2012/01/24/a-better-nsupdate/
#
# Usage: dnsupdate -s server -k key -t ttl add _minecraft._tcp.mc.example.com SRV 0 0 25566 mc.example.com.
# -h HELP!
# -s the server
# -k the key
@gauravssnl
gauravssnl / README.md
Created December 14, 2016 18:19 — forked from pklaus/README.md
A Tool to easily backup Wordpress posts to your local filesystem.

Backup Your Wordpress Blog Using Python

A Tool to easily backup Wordpress posts to your local filesystem.

I use this together with local-blog to host a local copy of my own blog on my laptop (for use on the road etc.).

Usage