Skip to content

Instantly share code, notes, and snippets.

View avesus's full-sized avatar
🎯
Focusing

Brian Cannard avesus

🎯
Focusing
View GitHub Profile
@avesus
avesus / levmarq.c
Created July 10, 2023 16:33 — forked from maasencioh/levmarq.c
A simple implementation of the Levenberg-Marquardt algorithm in plain C
/*
* levmarq.c
*
* This file contains an implementation of the Levenberg-Marquardt algorithm
* for solving least-squares problems, together with some supporting routines
* for Cholesky decomposition and inversion. No attempt has been made at
* optimization. In particular, memory use in the matrix routines could be
* cut in half with a little effort (and some loss of clarity).
*
* It is assumed that the compiler supports variable-length arrays as
@ScienceElectronicsFun
ScienceElectronicsFun / Mod_LaMeresCPU_WebFPGA.v
Created September 12, 2021 16:02
Verilog CPU for WebFPGA
// @MAP_IO port_out_00[0] 06
// @MAP_IO port_out_00[1] 07
// @MAP_IO port_out_00[2] 08
// @MAP_IO port_out_00[3] 09
// @MAP_IO port_out_00[4] 10
// @MAP_IO port_out_00[5] 11
// @MAP_IO port_out_00[6] 12
// @MAP_IO port_out_00[7] 14
// @MAP_IO reset 18
@avesus
avesus / common.glsl
Last active October 29, 2023 02:54
Cartilage Shader
# ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
precision highp int;
precision highp sampler2D;
# else
precision mediump float;
precision lowp int;
precision lowp sampler2D;
# endif
@avesus
avesus / ROMA.md
Created March 13, 2020 16:25
IO classification over Read, Overwrite, Move, Append

All external world facilities should have wrappers to support unit-testable and simply clean code.

These external world facilities:

a) might return different data when reads are requested because the data can be changed either by external "actors" or by a concurrent thread of the same client (this lambda); Examples: SQL SELECT, HTTP GET

b) do provide write APIs. We classify writes according if they destroy old data or make it unavailable at old locations

@avesus
avesus / icestick.pcf
Last active November 2, 2023 05:39
Lattice iCEstick + ILI9225 display
# full iCEstick pinout:
# http://www.pighixxx.com/test/portfolio-items/icestick/
set_io CLK_pad 21
set_io FT2232H_GPIOL2_pad 1
set_io FT2232H_GPIOL1_pad 2
set_io FT2232H_GPIOL0_pad 3
set_io FT2232H_TMS_CS_pad 4
set_io FT2232H_TDO_DI_pad 7
@avesus
avesus / arty.xdc
Last active November 2, 2023 05:39
Ethernet PHY and iCE40LP384 reprogrammer over UDP
#set_property DONT_TOUCH true [get_cells { evt1/mem1/srlatch_with_ands }]
#set_property DONT_TOUCH true [get_cells { evt1/pulse1/not1 }]
#set_property DONT_TOUCH true [get_cells { evt1/pulse1/xnor1 }]
#set_property DONT_TOUCH true [get_cells { evt1 }]
set_property SEVERITY {Warning} [get_drc_checks LUTLP-1]
#set_property ALLOW_COMBINATORIAL_LOOPS TRUE [get_nets evt1/feedback]
#set_property ALLOW_COMBINATORIAL_LOOPS TRUE [get_nets evt1/mem1/in0]
#set_property ALLOW_COMBINATORIAL_LOOPS TRUE [get_nets s1/evt1/mem1/OUTPUT_EDGE]
@avesus
avesus / the-best-string-ever.cpp
Created January 18, 2019 21:52
The Best String Ever
class TuffString {
public:
template <typename T, size_t Size>
TuffString (const T (&ptr) [Size]) : ptr(ptr), len(Size - 1) {
// _dev_logA("Pre-computed length\n");
}
TuffString (const void* pString) : ptr((const char*)pString) {
@keleshev
keleshev / fold.ml
Last active November 20, 2024 09:53
(* From blog post Interpretations of Fold,
https://keleshev.com/interpretations-of-fold *)
let (=>) left right = print_char (if left = right then '.' else 'F')
open Printf
let id x = x
let const x = fun _ -> x
let sum = List.fold_left (+) 0
let (>>) f g x = g (f x)
@rahulr92
rahulr92 / lambda-calculus.clj
Created January 2, 2018 07:39
Church encoding in lambda-calculus. Examples based on the following talk (rewritten in Clojure) - https://www.youtube.com/watch?v=7BsfMMYvGaU
(ns rahul.lambda-calculus)
;; Church Numerals
(def zero (fn [f]
(fn [x]
x)))
(def one (fn [f]
(fn [x]
(f x))))
@avesus
avesus / nginx.conf
Last active December 1, 2017 05:55
Nginx perfect nodern SPA config
location /app/ {
expires max;
}
location /img/ {
expires max;
}
location = /favicon.ico {
try_files $uri =204;