Skip to content

Instantly share code, notes, and snippets.

View donkey-hotei's full-sized avatar

isaak yansane donkey-hotei

View GitHub Profile
from time import time
from sklearn.datasets import load_files
from sklearn.cross_validation import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.cluster import KMeans
from sklearn import metrics
def bench_k_means(estimator, name, data, labels):
t0 = time()
sample_size = len(data)
@donkey-hotei
donkey-hotei / gist:6c8efbf36fae214a6974
Last active September 23, 2015 15:15
task__one.py
#!/usr/bin/python
"""
Simple Sentiment Analyzer over the Cornell Moview Review Dataset
"""
import string
import numpy as np
import matplotlib.pyplot as plt
from random import randint
# nltk has some tools that might be useful...
from nltk.corpus import stopwords
@donkey-hotei
donkey-hotei / top_features.py
Last active September 23, 2015 15:14
top_features.py
#!/usr/bin/python
import numpy as np
from sklearn.dataset import load_files
def split_neg_pos_docs(data):
"""
Splits the dataset into negative and negative sets.
"""
negative_documents = b' '.join([ data.data[i] for i in range(len(data.data)) if data.target[i] == 0 ])
positive_documents = b' '.join([ data.data[i] for i in range(len(data.data)) if data.target[i] == 1 ])
@donkey-hotei
donkey-hotei / quadratic_sieve.py
Last active August 27, 2015 07:36
implementation of the quadratic sieve using SLAL
#!/usr/bin/python3
from core.vector import Vector
from core.GF2 import one, zero
from util.factoring_util import dumb_factor, intsqrt, primes, prod
def int2GF2(integer):
""" Convert integer to a binary one or zero.
0 if int is even else 1
"""
Analyzing voting data using SLAL
"""
# from Vector import Vector
from Vector import list2vector
US_file = open('US_Senate_voting_data_109.txt')
UN_file = open('UN_voting_data.txt')
US_voting_data = []
UN_voting_data = []
@donkey-hotei
donkey-hotei / cancer_data.py
Last active August 28, 2015 23:41
Application of Gradient Descent using SLAL
import sys
sys.path.append('../../' )
from core.vector import Vector
from util.matrixutil import rowdict2matrix
def read_training_data(fname, D=None):
"""Given a file in appropriate format, and given a set D of features,
returns the pair (A, b) consisting of
a P-by-D matrix A and a P-Vector b,
where P is a set of patient identification integers (IDs).
(defclass Noeud [object]
;; Node class for representing outcomes
[[--init-- (fn [self]
(setv self.acheter None) ; edge to buy node
(setv self.rester None) ; edge to stay node
(setv self.solde 0) ; balance at current node
(setv self.machine None) ; each node has a machine associated, except first node
(setv self.jour None) ; init node object attrs
None)]
[--str-- (fn [self]
@donkey-hotei
donkey-hotei / x.py
Created September 23, 2015 18:48
CSAW 2015 Precision Exploit
#!/usr/bin/python
from pwn import *
if __name__ == '__main__':
# context.binary = "precision" # name of binary
host = "54.210.15.77" # host ip
port = 1259
connection = remote(host, port) # expose connection to service
context.bits = 32 # since we're working with a 32-bit binary
response = connection.recvline()
@donkey-hotei
donkey-hotei / port_scanner.py
Created December 7, 2015 04:20
a simple port scanner done up in python
#!/usr/bin/python
# -*- coding: latin-1 -*-
# a python stealth port scanner
from logging import getLogger, ERROR
getLogger("scapy.runtime").setLevel(ERROR)
from scapy.all import *
from datetime import datetime
from time import stdftime
@donkey-hotei
donkey-hotei / cam_overflow.py
Last active December 20, 2015 09:30
a solution to the scapy-hunt edurange scenario
#!/usr/bin/python
# CAM Table Overflow is all about flooding a
# switches CAM table with a lot of fake MAC
# addresses to drive the switch into HUB mode.
from scapy.all import *
from random import randint
import subprocess
# import sys