Skip to content

Instantly share code, notes, and snippets.

View petermcd's full-sized avatar

Peter McDonald petermcd

  • Scotland
  • 05:43 (UTC +01:00)
View GitHub Profile
@petermcd
petermcd / gist:0fcccc00469741bb523c30d62b49a6b1
Created December 25, 2019 22:40
Timing script for running pure PHP to compare against an extension written in C
<?php
$lines = file('/home/peter/php-7.4.1/Zend/zend_language_parser.c');
function string_reverse($input){
$temp = '';
for($iter = strlen($input);$iter > 0; $iter--){
$temp = $temp . $input[$iter-1];
}
return $temp;
}
@petermcd
petermcd / gist:71362fd39d87f25f15233d6861807f90
Created December 25, 2019 22:38
Timing script for running an extension
<?php
$lines = file('php-7.4.1/Zend/zend_language_parser.c');
$started = microtime();
foreach ($lines as $line) {
str_reverse($line);
}
$ended = microtime();
echo $ended - $started;
@petermcd
petermcd / logins.csv
Created February 10, 2019 12:14
A listy of credentials tried when I opened an SSH port to the internet for a week. in the format request ID, username, password, time/date of attempt, request coun try of origin, unique id representing the IP making the connection.
We can't make this file beautiful and searchable because it's too large.
id,username,password,when,country,host_id
21,admin,7ujMko0admin,2019-02-02 10:39:27,China,0
22,pi,jdd,2019-02-02 10:40:09,United Kingdom,1
23,pi,kkk,2019-02-02 10:40:11,United Kingdom,1
24,pi,lk,2019-02-02 10:40:13,United Kingdom,1
25,pi,kk',2019-02-02 10:40:16,United Kingdom,1
26,pi,kjj,2019-02-02 10:40:18,United Kingdom,1
27,pi,fds,2019-02-02 10:42:55,United Kingdom,1
28,pi,eee,2019-02-02 10:42:56,United Kingdom,1
29,pi,fds,2019-02-02 10:42:57,United Kingdom,1
@petermcd
petermcd / DateTimeDelta.py
Last active December 27, 2018 00:41
Adding days, weeks, months or years to a datetime
"""
Author: Peter McDonald
Description: Probably not the best way to do this but gives the ability to add or remove days, weeks,
months or years to a DateTime date
"""
from datetime import datetime
MonthDays = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]