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
@avesus
avesus / fold.ml
Created October 15, 2020 16:31 — forked from keleshev/fold.ml
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)
let () =
@avesus
avesus / convert.sh
Created August 23, 2016 17:25
Convert png to pdf
sudo apt-get install imagemagick
# To rename files with spaces:
find -name "* *" -type f | rename 's/ /_/g'
ls page*.png | sort -n | tr '\n' ' ' | sed 's/$/\ mydoc.pdf/' | xargs convert
@avesus
avesus / object-watch.js
Created May 3, 2016 13:22 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@avesus
avesus / repl-client.js
Created February 1, 2016 17:53 — forked from TooTallNate/repl-client.js
Running a "full-featured" REPL using a net.Server and net.Socket
var net = require('net')
var sock = net.connect(1337)
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true)
@avesus
avesus / Location.js
Last active September 10, 2015 13:35 — forked from barneycarroll/Location.es6.min.js
An ultra-small URI parsing function that accepts a URI-like string & returns an object with all the string properties of the native Location object for that string. Works using native property detection, without received wisdom (ie dictionaries, inference, etc).
var Location = (function LocationClosure(){
var properties = {};
// Create and return a link with the given URI
function makeLink( URI ){
var link = document.createElement( 'a' );
link.href = URI;
return link;
@avesus
avesus / inlineedit.js
Last active August 29, 2015 14:27 — forked from StephanHoyer/inlineedit.js
Inline edit mithril component
'use strict';
var m = require('mithril');
var extend = require('lodash').extend;
var setFocus = require('../util/viewhelper').setFocus;
var keymage = require('keymage');
function noop(){}
function addClass(el, className) {
@avesus
avesus / view.jsx
Last active August 29, 2015 14:27 — forked from insin/view.jsx
JSX version of a Mithril TODO example - try it with http://facebook.github.io/react/jsx-compiler.html
/**
* JSX version of https://github.com/jpmonette/todomvc-mithril/blob/1d627f1d5dc0890d0a99cdcb16d09387f68f6df0/js/views/todo-view.js
* Assumes the use of the vanilla JSX Transformer and an "mshim" object to translate tag calls to the format m() expects.
* @jsx mshim
*/
'use strict';
var m = require('mithril')
@avesus
avesus / mithril-patch.es6.golfed.js
Last active August 29, 2015 14:27
Patches Mithril to accept components as well as strings
// If you need a license, this is under the ISC license.
// In golfed ES6, just because I could... (84 characters)
this.m=(o=>Object.assign((...a)=>(typeof a[0]=='string'?o:o.component)(...a),o))(m);