Skip to content

Instantly share code, notes, and snippets.

@esromneb
esromneb / gist:8973217
Created February 13, 2014 11:00
Add this to your meteor project, and run it from the client. This will help you visualize your template re-renderings
redRenders = function () {
$('*').each(function(element){
$(this).css( "background-color", "red" );
});
}
@esromneb
esromneb / gauss.m
Last active February 12, 2025 23:11
Gauss elimination and Gauss Jordan methods using MATLAB code
% Code from "Gauss elimination and Gauss Jordan methods using MATLAB"
% https://www.youtube.com/watch?v=kMApKEKisKE
a = [3 4 -2 2 2
4 9 -3 5 8
-2 -3 7 6 10
1 4 6 7 2];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@esromneb
esromneb / g2rref.m
Last active July 21, 2022 12:28
matlab's rref function modified to operate in gf(2)
% This is a modified version of matlab's building rref which calculates
% row-reduced echelon form in gf(2). Useful for linear codes.
% Tolerance was removed because yolo, and because all values
% should only be 0 or 1. @benathon
function [A] = g2rref(A)
%G2RREF Reduced row echelon form in gf(2).
% R = RREF(A) produces the reduced row echelon form of A in gf(2).
%
% Class support for input A:
@esromneb
esromneb / split.m
Created September 18, 2014 08:33
Split a vector of bounded length into individual return variables.
function [ o1, o2, o3, o4, o5, o6, o7, o8 ] = split( v )
%SPLIT Splits a vector of bounded length into individual return variables.
% Split() can handle arbitrarily long input vectors, but only a fixed
% number of output variables. @benathon
%
% Usage:
% vec = [1 2 3 4 5];
% [a,b,c,d,e] = split(vec);
% [f,g] = split(vec);
@esromneb
esromneb / debounce.py
Created November 12, 2015 01:57
This is a proper debounce function, the way a electrical engineer would think about it.
import time
""" This is a proper debounce function, the way a electrical engineer would think about it.
This wrapper never calls sleep. It has two counters: one for successful calls, and one for rejected calls.
If the wrapped function throws an exception, the counters and debounce timer are still correct """
class Debounce(object):
def __init__(self, period):
@esromneb
esromneb / lossysocket.py
Last active December 1, 2015 03:17
lossy socket for python allows you to tune how many packets are dropped
# This class wraps socket, and will maybe send your packet
# tune tx_drop_rate and rx_drop_rate, 0 means transmit everything, 1 means drop everything
# This class works best for UDP, as it doesn't allow you to drop TCP control messages
import socket
import random
class LossySocket(object):
def __init__(self, *p):
self._sock = socket.socket(*p)
@esromneb
esromneb / haikulists.py
Created April 24, 2018 02:58
required file for homework
haiku1 = ['A', 'fat', 'bee', 'stings', 'me', 'It', 'hurts', 'very', 'badly', 'but', 'I', 'do', 'not', 'cry', 'though']
list1 = [9, 11, 6, 14, 1, 10, 12, 0, 3, 4, 8, 5, 7, 13, 2]
haiku2 = [(8, 'feathers'), (2, 'evening'), (5, 'together'), (1, 'peaceful'), (6, 'with'), (0, 'A'), (4, 'singing'), (7, 'pretty'), (3, 'Sparrows')]
haiku3 = 'High and smooth it flew. Into the sky, soaring straight. Flying planes with you.'
@esromneb
esromneb / slope.py
Created October 22, 2018 04:03
simple way to find the slope from two points
if 1:
x1 = -659
y1 = -10000.0
x2 = 45
y2 = -40000.0
m = (y2-y1)/(x2-x1)
print "slope ", m
b = y2-(m*x2)
dashtie
shannon fifo
libevent pipe (under node)
napi helper
static hash
typed arrays in javascript( see https://www.npmjs.com/package/operator-overloading https://github.com/charlieroberts/jsdsp )
@esromneb
esromneb / ld_standard_no_vmem
Created January 7, 2020 05:24
partial ld file without vmem
START_LOC = 0x0000;
IMEM_LEN = 0x6400;
DMEM_LEN = 0x1800;
BOOT_LEN = 0x03f8;
PASS_FAIL_LEN = 0x0008;
MEMORY {
imem (R) : ORIGIN = START_LOC , LENGTH = IMEM_LEN
dmem (RW) : ORIGIN = IMEM_LEN , LENGTH = DMEM_LEN
bootloader (RW): ORIGIN = IMEM_LEN + DMEM_LEN , LENGTH = BOOT_LEN