This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Fix up ragged columns to work around problem https://github.com/wireservice/agate/issues/666 | |
import sys, csv | |
max_sniff_lines = 1000 | |
sniff_buf = [] | |
def columns_in(l): | |
split_l = list(csv.reader(l.splitlines())) # list, 0th entry holds content | |
return len(split_l[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
function hows_my_ssl() | |
{ | |
$target = "https://www.howsmyssl.com/a/check"; | |
$client = new \GuzzleHttp\Client(['http_errors' => false]); | |
$res = $client->request("GET", $target); | |
echo $res->getStatusCode() . PHP_EOL; | |
var_dump(json_decode($res->getBody(), false)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from pprint import pprint | |
def hows_my_ssl(): | |
target = "https://www.howsmyssl.com/a/check" | |
res = requests.get(target) | |
print(res.status_code) | |
pprint(res.json()) | |
hows_my_ssl() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# put output files in subdir "done" | |
mkdir -p done | |
for i in *.mp4 | |
do | |
# Extract mono (left) channel from captured video into a .wav file | |
ffmpeg -i "$i" -vn -ac 1 aud1.wav | |
# Learn noise profile from first x seconds of file, which should be "silence" | |
sox aud1.wav -n trim 0 1.0 noiseprof speech.noise | |
# Noise reduction, with mild strength, normalise file volume to -3dB, mix as identical (centre) L R stereo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from __future__ import print_function | |
import email, argparse | |
def xstr(s): | |
return str(s) if s else '' | |
def print_part(m, depth): | |
pad = ' ' * depth | |
for i in m.items(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
startT = time.time() | |
with SMTP(cfg['smtp_host'], port=cfg['smtp_port']) as smtp: | |
smtp.set_debuglevel(2) # Uncomment this if you wish to see the SMTP conversation / STARTLS neg. | |
smtp.ehlo(name='sparkpostSMIME') | |
if 'starttls' in smtp.esmtp_features: | |
smtp.starttls() # raises an exception if it fails. If continues, we're good | |
smtp.ehlo(name='sparkpostSMIME') | |
mode_str = 'STARTTLS' | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Win 10 commandlet defaults to TLS 1.0 which is deprecated as incecure! (see https://www.sparkpost.com/blog/tls-v1-0-deprecation/) | |
# Make Windows negotiate higher TLS version as follows: | |
[System.Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# Build a Credential object containing SparkPost API key as password | |
$pwd = ConvertTo-SecureString "<<Your API KEY HERE>>" -AsPlainText -Force | |
$creds = New-Object System.Management.Automation.PSCredential ("SMTP_Injection", $pwd) | |
# Send. This is using the SparkPost EU service. If you are using the US service, change SmtpServer to be smtp.sparkpostmail.com. | |
Send-MailMessage -From "[email protected]" -To [email protected] -Subject "Hello World" -Body "Here it is" -SmtpServer smtp.eu.sparkpostmail.com -Port 587 -Credential $creds -UseSsl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Bubble blaster game from Carol Vorderman book pp.164 onwards | |
from tkinter import * | |
HEIGHT = 500 | |
WIDTH = 800 | |
window = Tk() | |
window.title("Bubble Blaster") | |
window.attributes("-topmost", 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse, csv, sys | |
import dns.resolver | |
def domainpart(n): | |
# A valid email address contains exactly one @, otherwise return None = invalid | |
parts = n.split('@') | |
if len(parts) == 2: | |
return parts[1] | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import imaplib, os | |
# Very simple IMAP client - prints messages in inbox | |
imap_host = os.getenv('IMAP_HOST') | |
imap_user = os.getenv('IMAP_USER') | |
imap_pass = os.getenv('IMAP_PASSWORD') | |
# connect to host using SSL | |
imap = imaplib.IMAP4_SSL(imap_host) |
OlderNewer