Skip to content

Instantly share code, notes, and snippets.

@basvandorst
basvandorst / kappers_scraping.php
Last active August 29, 2015 14:16
kappers.nl scraping
<?php
// download @ http://sourceforge.net/projects/simplehtmldom/
require_once('simple_html_dom.php');
$cities = array(
'almere','amsterdam','rotterdam'
);
$total = 0;
foreach($cities as $city)
{
@basvandorst
basvandorst / aivd-cyberchallenge
Last active December 3, 2016 15:47
AIVD Cyberchallenge 2015
#!/usr/bin/lua
--[[
AIVD Cyber challenge (https://www.aivd.nl/@3269/ga-cyberchallenge/)
bas@laptop:/var/www$ lua solve.lua
[*] ---------------------------------
[*] --- AIVD Cyber challenge 2015 ---
[*] ---------------------------------
[+] Start inverting number: 4241186467
@basvandorst
basvandorst / kaggle_kfold.py
Last active September 13, 2016 14:05
Kaggle - House Prices
from sklearn.cross_validation import KFold
from sklearn import linear_model
from sklearn import ensemble
from sklearn.metrics import mean_squared_error
xpca = PCA(100).fit_transform(df_cars_maxabs);
kf = KFold(len(df), n_folds=10, shuffle=True)
@basvandorst
basvandorst / composer.json
Created November 1, 2016 14:23
php composer phpmd monolog phploc phpcpd phpcs
{
"description": "The ultimate toolbox of developer!",
"support": {
"basic_usage": "http://getcomposer.org/doc/01-basic-usage.md",
"packagist": "https://packagist.org/",
"phpqatools": "http://phpqatools.org/",
"helper": "http://composer.json.jolicode.com/"
},
"author": {
"name": "NerOcrO",
@basvandorst
basvandorst / portscan.py
Created February 14, 2018 15:08
Simple multithreaded portscanner
from threading import Thread
import socket
def scan(ip, port):
try:
con = socket.socket()
result = con.connect_ex((ip,port))
if result == 0:
print '[+] Port %d open' %port
@basvandorst
basvandorst / chunk_text_by_regex.py
Created April 4, 2024 08:56
Chunk a large text by a regex & nr of times the regex matches. Could be useful for text processing where you want to use the chunks for same regex as the tokenizer
import re
def chunk_text_by_regex(text, pattern, nr_matches):
prev = 0
chunks = []
for i, match in enumerate(re.finditer(pattern, text), start=1):
if i % nr_matches == 0:
chunks.append(text[prev:match.start()].strip())
prev = match.start()
if prev < len(text):