Skip to content

Instantly share code, notes, and snippets.

@aewallin
aewallin / lucas_lehmer.py
Last active August 9, 2016 21:04
very simple Mersenne prime search
# very simple Mersenne prime search.
# AW2016-01-23
import time
import math
# http://stackoverflow.com/questions/16004407/a-fast-prime-number-sieve-in-python
def prime_sieve(n):
size = n//2
# send email, from e.g. cron-jobs and similar
import smtplib
from email.mime.text import MIMEText
def send_email(me, you, smtp_server, subject, text):
msg = MIMEText(text)
msg['Subject'] = subject
msg['From'] = me
msg['To'] = you
s = smtplib.SMTP(smtp_server)
# write data to InfluxDB database
# tags and fields (measurement data) as python dicts
import influxdb
host = 'my.influxdb.server'
port = 8086
dbname = 'my_db'
def write_dicts(measurement, tagDict, fieldDict):
import requests
import time
import syslog
"""
Simple program for testing Ethernet control of:
Mini-Circuits RC-2SP6T-S12
"""
ip ="192.168.100.30"
@aewallin
aewallin / rf_mux_test.py
Created February 20, 2018 13:59
Arduino-controlled RF-multiplexer test code
# AW2018-02-20
# For testing RF-multiplexer (Arduino Due+ETH-shield)
import requests
import time
import syslog
#ip="192.168.1.177"
ip="192.168.3.30"
def state(mux="A",state=1):
@aewallin
aewallin / itu_masks.py
Last active March 16, 2018 08:27
TDEV and MTIE masks for ITU synchronizatio / clock standards
"""
TDEV and MTIE masks for ITU Standards
AW2017-2018
ITU Primary Reference Clock
https://www.itu.int/rec/T-REC-G.811/en
ITU Primary Reference Time Clock
https://www.itu.int/rec/T-REC-G.8272/en
@aewallin
aewallin / wrs_snmp_request.py
Created April 6, 2018 10:40
White Rabbit Switch SNMP monitoring example
from snmp_helper import snmp_get_oid, snmp_extract
import numpy
# WR-switch management port, fixed ip for delpoyment
ip='192.168.0.10'
# SNMP parameters
community = 'public'
port = 161

Notes on configuring apache cassandra

AW2018-02-21

Cassandra Install

Install instructions at http://cassandra.apache.org/download/

echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
@aewallin
aewallin / ustep_calc.py
Created October 22, 2018 12:30
DDS and u-stepper calclations
import bigfloat
import numpy
dds_clk=1.0e9
ftw_length = pow(2,48)
IF = 100e6/1024.0 # 97656.25
def ftw_dds(f_hz):
return numpy.round(f_hz*ftw_length/dds_clk,0)
# AW2018-12-06
# very simple auto-courtyard for KiCad footprints
# 1. reads bounding-box of F.fab and pads
# 2. expands by clearance
# 4. writes rectangle to F.CrtYd layer
# 5. writes modified footprint to a new file
import sys
import os
import math