Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

t k tahia-khan

View GitHub Profile
@tahia-khan
tahia-khan / gist:16b5fdd66b1544bd335f84a46af4bb63
Created Sep 5, 2017 — forked from bsmartt13/gist:efa02c40ea12c09d9c3a
OTX IP Reputation download links (updated hourly)
View gist:16b5fdd66b1544bd335f84a46af4bb63
https://reputation.alienvault.com/reputation.generic.gz
https://reputation.alienvault.com/reputation.generic
https://reputation.alienvault.com/reputation.data
https://reputation.alienvault.com/reputation.snort.gz
https://reputation.alienvault.com/reputation.snort
https://reputation.alienvault.com/reputation.iptables.gz
https://reputation.alienvault.com/reputation.iptables
https://reputation.alienvault.com/reputation.squid.gz
https://reputation.alienvault.com/reputation.squid
https://reputation.alienvault.com/reputation.unix.gz
View redbluebluered.py
def rebluebluered(s, pattern):
return search(s, pattern, dict())
def search(left, pattern, matches):
if (not pattern and left) or (pattern and not left):
return False
if not pattern and not left:
return True
View backtrack_permutations.py
def backtrack(A, k, N):
""" General backtrack algorithm which enumerates all possible solutions """
if is_a_solution(A, k, N):
process_solution(A, k, N)
return
k = k + 1
candidates = construct_candidates(A, k, N)
for c in candidates:
View priority_queue.py
class PQ:
"""
Priority queue implemented as a heap (minheap).
"""
def __init__(self ):
self.heap = [0]
self.size = 0
def insert(self, x):
View qsort.py
def qsort(A, L, U):
if L < U:
T = A[L]
M = L #pivot
for i in range(L+1, U):
if A[i] < T:
M += 1
tmp = A[M]
A[M] = A[i]
A[i] = tmp
View djikstra.py
import heapq
def djikstra(graph, s, z):
dist = {s:0}
pred = {s:None}
visited = {}
q = []
heapq.heappush(q, s)
while q:
View ATaleOfThreeCities.py
from math import sqrt, pow
class ATaleOfThreeCities:
AB = 1
BC = 2
CA = 3
def __init__(self, min1=999, min2=999):
self.min1 = min1
View permutations.py
from collections import deque
def permutations(word):
if len(word) == 1:
return [word]
perms = permutations(word[1:])
c = word[0]
res = []
View permutations.py
from collections import deque
def permutations(word):
if len(word) == 1:
return [word]
perms = permutations(word[1:])
c = word[0]
res = []
View BadNeighbours.py
class BadNeighbours:
def maxDonations(self, donations):
L = len(donations)
if L < 3:
return max(donations)
# memo1[L-2] will have maximum value of donations which
# *may* include the first neighbour (therefore cannot include
You can’t perform that action at this time.