Skip to content

Instantly share code, notes, and snippets.

View Sean-Bradley's full-sized avatar
📰
https://sbcode.net

SBCODE Sean-Bradley

📰
https://sbcode.net
View GitHub Profile
@Sean-Bradley
Sean-Bradley / checkssl.sh
Last active October 20, 2023 17:37
A script to return the number of days before a SSL certificate expires. Visit https://sbcode.net/zabbix/system-run/ for instructions
data=`echo | openssl s_client -servername $1 -connect $1:443 2>/dev/null | openssl x509 -noout -enddate | sed -e 's#notAfter=##'`
ssldate=`date -d "${data}" '+%s'`
nowdate=`date '+%s'`
diff="$((${ssldate}-${nowdate}))"
echo $((${diff}/86400))
#what is the value Pp1d4 in the repos at https://github.com/Sean-Bradley/ECDSA_secp256k1_JordonMatrix_nodejs
#it's used to get the modular cubed root
#I want to find y in equation y² = x³ + 7 in a finite field P
P = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
Pp1d4 = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c
#Pp1d4 = P plus 1 divided by 4
#getting cubed root in a finite field
print(pow(16, Pp1d4, P)) # = 4
@Sean-Bradley
Sean-Bradley / gist:b7b223c33fd0b57b14178c19cc5d257a
Created September 25, 2021 11:34
The client.js from the Three.js Boilerplate
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
import Stats from 'three/examples/jsm/libs/stats.module'
import { GUI } from 'three/examples/jsm/libs/dat.gui.module'
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 100)
camera.position.z = 2
@Sean-Bradley
Sean-Bradley / gist:1ad4184edca352e643d7a269f878a571
Created September 25, 2021 11:26
HTML for a basic Three.js boilerplate that uses import maps.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Three.js Tutorials by Sean Bradley : https://sbcode.net/threejs/</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
overflow: hidden;
[Unit]
Description=Promtail service
After=network.target
[Service]
Type=simple
User=promtail
ExecStart=/usr/local/bin/promtail -config.file /usr/local/bin/config-promtail.yml
[Install]
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://127.0.0.1:3100/loki/api/v1/push
[Unit]
Description=Loki service
After=network.target
[Service]
Type=simple
User=loki
ExecStart=/usr/local/bin/loki -config.file /usr/local/bin/config-loki.yml
[Install]
auth_enabled: false
server:
http_listen_port: 3100
ingester:
lifecycler:
address: 127.0.0.1
ring:
kvstore:
"""Chain of Responsibility Pattern
Chain of responsibility pattern is a behavioural pattern used to achieve loose coupling
in software design.
In this example, a request from a client is passed to a chain of objects to process them.
The objects in the chain will decide how to process them and/or pas them to the next in the chain.
The objects can also modify the next in the chain if for example you wanted to run objects in a recursive manner.
"""
from abc import ABCMeta, abstractstaticmethod
"""The Command Design Pattern in Python
The command pattern is a behavioural design pattern, in which an abstraction
exists between an object that invokes a command, and the object that performs it.
This is part 2 of the Command Design Pattern tutorial,
where I create a slider, instead of the switch from part 1.
The slider also accepts a variable percentage, rather than an ON/OFF
The history also records the variable settingg
And I also add UNDO/REDO to the Invoker so that you can go backawards and forwards through time