Skip to content

Instantly share code, notes, and snippets.

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)
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@ddribin
ddribin / # handbrake - 2018-05-19_00-44-18.txt
Created May 22, 2018 16:17
handbrake on macOS 10.13.5 - Homebrew build logs
Homebrew build logs for handbrake on macOS 10.13.5
Build date: 2018-05-19 00:44:18