Skip to content

Instantly share code, notes, and snippets.

@rsegebre
rsegebre / ip_finder.py
Last active December 27, 2015 08:19
./ip_finder.py -h usage: ip_finder.py [options] options: --version show program's version number and exit -h, --help show this help message and exit -s, --sort Sorts and prints IPs in numberical order -f FILE, --file=FILE Indicates file to extract IPs from
#!/usr/bin/env python
#############IP FINDING SCRIPT######
# This script takes a file and prints all the ips found per line to stdout.
#
#
#######################################
import os, sys, re, socket
@rsegebre
rsegebre / fsm_accept.py
Last active September 21, 2016 19:54
Python function to generate one string for a given non-deterministic Finite State Machine (FSM) represented by a dictionary of edges {tuple:list} and an accepting state list which signifies that the FSM has reached a final state.
# I was following the Udacity Programming Languages course and this one was actually challenging and fun to figure out.
# Roberto S. 1/20/2013
edges = { (1,'h'):[3,2],
(3,'h'):[3],
(2,'h'):[3],
(2,'t'):[4],
(4,'m'):[5],
(5,'l'):[6] }
accepting = [6]