Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename trie.py
#created: 2010-08-01 20:24
#source uri: http://iregex.org/blog/trie-in-python.html
# escape bug fix by fcicq @ 2012.8.19
@mahirchavda
mahirchavda / trace.py
Last active May 24, 2020 11:33
Trace python function calls, arguments and return values
from functools import wraps
indent = 0
def trace(func):
@wraps(func)
def function_wrapper(*args, **kwargs):
"""function_wrapper of trace"""
global indent
print("{indent} HI {func_name}, args={args}, kargs={kwargs}".format(indent="\t"*indent, func_name=func.__name__, args=args, kwargs=kwargs))
indent += 1
res = func(*args, **kwargs)
@mahirchavda
mahirchavda / splunk_alias.py
Last active May 24, 2020 11:41
Make Splunk CLI Commands Shorter
# Author: mahirchavda
# Live on : https://repl.it/@MahirChavda/WTF
# To Make Splunk CLI Commands Shorter run below command in terminal for linux or in git bash for windows
# command: curl "http://wtf.mahirchavda.repl.co/splunk_alias/?splunk_home=/opt/splunk&alias_suffix=" >> ~/.bashrc && source ~/.bashrc
from flask import Flask, request
from threading import Thread
app = Flask('')
@mahirchavda
mahirchavda / fabfile.py
Created March 28, 2020 11:29 — forked from eddieantonio/fabfile.py
Fabric: task to authorize your SSH key on a remote host.
"""
Installs your SSH key on other hosts. A fabfile for lazy people.
"""
from fabric.api import task, run, put, env, cd
# Use sh instead of bash.
env.shell = '/bin/sh -l -c'
@task
38.5.1.2
38.5.1.5
38.5.1.15
38.5.1.25
39.39.39.0/24