Skip to content

Instantly share code, notes, and snippets.

View professormahi's full-sized avatar
😀
Happy!

Mahdi Fooladgar professormahi

😀
Happy!
View GitHub Profile
@professormahi
professormahi / tsp_ga.py
Created December 25, 2016 14:59
TSP Genetic Algorithm
from random import sample, uniform, randrange, shuffle
def is_circuit(chromosome):
global adj_mat
if adj_mat[chromosome[0]][chromosome[-1]] == -1:
return False
for i in range(len(chromosome) - 1):
if adj_mat[chromosome[i]][chromosome[i+1]] == -1:
return False
@professormahi
professormahi / search_gui.py
Created November 30, 2016 16:37
UCS, BFS, and DFS search + PNG images of each level in /tmp/out/
# To use this first you must install pygraphviz
# $ sudo apt install graphviz-dev && sudo pip install pygraphviz
from queue import Queue, PriorityQueue
from pygraphviz import AGraph
from os import path, makedirs
counter = 0
def show(pth, edges, explored, frontier, start, end):
@professormahi
professormahi / search.py
Created November 30, 2016 10:14
UCS, BFS, and DFS Search in python
from queue import Queue, PriorityQueue
def bfs(graph, start, end):
"""
Compute DFS(Depth First Search) for a graph
:param graph: The given graph
:param start: Node to start BFS
:param end: Goal-node
"""
@professormahi
professormahi / README.md
Last active November 19, 2016 06:41
Installing Sentry on Debian

Installing Sentry on Debian

Install aptitude packages

sudo apt-get update
sudo apt-get install python python-setuptools python-pip python-dev libxslt1-dev libxml2-dev libmysqlclient-dev libpq-dev libffi-dev postgresql lipjpeg-dev

Install and activate virtualenv

sudo pip install -U virtualenv
virtualenv /clients/sentry/

source /clients/sentry/bin/activate

# In the server
sysctl net.ipv4.ip_forward=1 # enable ip forwarding
iptables -t nat -A POSTROUTING -o <output> -j MASQUERADE # accept ip forwarding
# In the client
ip r add default via <ip> dev <dev>
@professormahi
professormahi / SimpleHTTPServerWithUpload.py
Created April 19, 2016 13:41 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@professormahi
professormahi / ctf.infosecinstitute.com.md
Last active December 4, 2016 14:44
ctf.infosecinstitute.com CTF Challenge reviews