Skip to content

Instantly share code, notes, and snippets.

@ddribin
ddribin / pot.lark
Last active November 21, 2024 16:15
Lark grammar and Python script for Potentiometers
pot : "PDB18" GANGS "-" PIN_TYPE DETENT SHAFT_LENGTH SHAFT_STYLE "-" RESISTANCE TAPER
GANGS : "1" | "2"
PIN_TYPE \
: "K" // PC pins, vertical 12.5mm
| "A" // PC pins, vertical 18.0mm
DETENT \
: "2" // Center detents
@ddribin
ddribin / potentiometer-ebnf.txt
Last active November 21, 2024 16:07
Partial EBNF for Potentiometers
part = "PDB18", gangs, "-" pin-type, detent, shaft-length, shaft-style, "-", resistance, taper ;
gangs = "1" | "2" ;
pin-type =
"K" (* PC pns vertical 12.5mm *) |
"A" (* PC pins, vertical 18.0mm *) ;
detent =
"2" (* Center detents *) |
import Foundation
func isPrime(_ n: Int) -> Bool {
return !String(repeating: "1", count: n).contains(/^.?$|^(..+?)\1+$/)
}
func isPrimeAlt(_ n: Int) -> Bool {
let s = String(repeating: "1", count: n)
return !s.contains(/^.?$|^(..+?)\1+$/)
}
@ddribin
ddribin / linear-fit.ipynb
Created February 18, 2024 19:01
Companion Jupyter notebook for my blog post, Linear Fit using Python and NumPy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ddribin
ddribin / next.log
Created June 26, 2021 20:06
servant Go Board
Info: constrained 'i_clk' to bel 'X0/Y8/io1'
Info: constrained 'q' to bel 'X13/Y6/io1'
Info: Packing constants..
Info: Packing IOs..
Info: Packing LUT-FFs..
Info: 277 LCs used as LUT4 only
Info: 124 LCs used as LUT4 and DFF
Info: Packing non-LUT FFs..
Info: 131 LCs used as DFF only
@ddribin
ddribin / FIFO_2word_FWFT.sv
Created April 25, 2021 20:37
One word FIFO with first word feed through (FWFT)
// *****************************************************************
// *** FIFO_2word_FWFT.sv V1.0, August 15, 2020
// ***
// *** This 1 word FIFO with first word feed through (FWFT)
// *** This was designed to be backwards compatible with the
// *** FIFO_3word_0_latency.sv with the 'zero latency' disabled.
// *** written by Brian Guralnick.
// ***
// *** See the included 'FIFO_2word_FWFT.png' simulation for functionality.
// ***
@ddribin
ddribin / reset.v
Created April 23, 2021 15:08
Asynchronous Assertion, Synchronous De-assertion
module reset_sync(
output reg rst_sync,
input clk, rst_n
);
reg R1;
always @(posedge clk or negedge rst_n)
if(!rst_n) begin
R1 <= 1'b0;
rst_sync <= 1'b0;
-------- Diagnostics - 2/21/2021, 11:22:54 PM
Version: 1.2.1
Current Configuration:
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
@ddribin
ddribin / fakegcc-5
Last active January 21, 2021 15:03
A script to fake out Homebrew thinking gcc-5 is installed.
#!/bin/sh
if [ "$1" = "--version" ]; then
echo 'gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609'
exit 0
fi
exit 1
-- debug logging
function log(...)
local arg={...}
local msg=""
for m in all(arg) do
msg=msg.._lstr(m)
end
_log(msg)