This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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]; | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redRenders = function () { | |
$('*').each(function(element){ | |
$(this).css( "background-color", "red" ); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put me at server/email.js | |
Meteor.startup(function () { | |
var user = "user"; | |
var password = "password"; | |
var serverAndPort = "smtp.example.com:9999"; | |
var string = 'smtp://' + user + ':' + password + '@' + serverAndPort; | |
process.env.MAIL_URL = string; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isArray(x) { | |
return _.isArray(x) && !EJSON.isBinary(x); | |
} | |
// pulled from "LocalCollection._makeLookupFunction" | |
var dotNotationFetch = function (key) { | |
var dotLocation = key.indexOf('.'); | |
var first, lookupRest, nextIsNumeric; | |
if (dotLocation === -1) { | |
first = key; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************************************** | |
* Filename: hal_defs.h | |
* Description: This file contains useful macros and data types | |
* | |
* | |
* Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ | |
* | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only supports messages up to 65536 characters long | |
// takes a first param of byte_count and generates the correct "websocket style" header | |
// *header_len is set to the number of bytes used in header[] | |
void build_message_header(const size_t byte_count, char header[3], size_t* header_len) | |
{ | |
size_t len = byte_count; | |
if( len < 126 ) | |
{ | |
header[0] = len & 0xff; | |
*header_len = 1; |