Skip to content

Instantly share code, notes, and snippets.

View jonbrennecke's full-sized avatar

Jon Brennecke jonbrennecke

View GitHub Profile
% Estimate the power spectra of a signal using Bartlett's Method, or, if parameter 'overlap' is specified, using Welch's Method.
% This method is based on the concept of using periodogram spectrum estimates, which are the result of converting a signal from the
% time domain to the frequency domain.
%
% @see Bartlett, M.S. (1948). "Smoothing Periodograms from Time-Series with Continuous Spectra". Nature 161: 686–687.
% @see Welch, P.D. (1967) "The Use of Fast Fourier Transform for the Estimation of Power Spectra: A Method Based on
% Time Averaging Over Short, Modified Periodograms", IEEE Transactions on Audio Electroacoustics, AU-15, 70–73.
%
% @link http://en.wikipedia.org/wiki/Bartlett%27s_method
% @link http://en.wikipedia.org/wiki/Welch_method
@jonbrennecke
jonbrennecke / Pente.cpp
Created May 4, 2014 18:28
Game of Pente implementation in C++11
// compile with -std=c++11
//
// @author jonbrennecke / https://github.com/jonbrennecke
#include <iostream>
#include <vector>
#include <regex>
#include <string>
/**
@jonbrennecke
jonbrennecke / Pente.js
Created May 4, 2014 18:31
WIP implementation of Pente in JS
var board = [
[ 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 'X', 'X', 'X', 'X', 'X', 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
];
@jonbrennecke
jonbrennecke / edf.m
Last active August 29, 2015 14:03
Read EDF (European Data Format) files
function [ header, records ] = edf ( filepath )
% Parse EDF file information based on the EDF/EDF+ specs
% @see http://www.edfplus.info/specs/index.html
fid = fopen( filepath, 'rb' );
data = fread(fid,256,'*char');
% TODO regex to strip trailing whitespace
function [data]= unitactivity(chanNum,sort,snippetWidth,snippetOffset,tank,block,data)
%chanNum = channel number from which to draw data;
%sort = cluster of units to be plotted in parallel with the EEG. Can be any subset of sort codes for that channel or all of them
%snippetWidth = number of seconds of data to plot
%snippetOffset= number of seconds into the file to start plotting.
%tank and block are the data source. For instance: 'D:\OptoTagging\6_16_14','6_16_14_10min_Stim'
%
%data = an optional parameter. If a TDT block data set already exists as a structured array, the
%function will plot data from that structured array. If the data structure
%does not yet exist, DO NOT list data as a a parameter. ONLY input the
@jonbrennecke
jonbrennecke / gist:0ad618911708d7213622
Last active August 29, 2015 14:05
Chrome as Window Manager

OS


Linux Kernel X Server openbox window manager, blank config so no other programs can be activated

auto login at boot

@jonbrennecke
jonbrennecke / recover.js
Created September 4, 2014 23:36
Recover file contents from "git reset --hard" (file names are another story)
var cp = require('child_process'),
fs = require('fs'),
execSync = require('exec-sync');
var fsck = cp.spawn("git", ["fsck", "--cache", "--unreachable","$(git for-each-ref --format=\"%(objectname)\")"])
var stdout = '';
fsck.stdout.on('data',function(data){
stdout += data.toString();
@jonbrennecke
jonbrennecke / Proof.md
Last active August 29, 2015 14:26
Proof that 2 = 1
Let a = b

a^2 = ab
a^2 + a^2 = a^2 + ab
2a^2 = a^2 + ab
2a^2 - 2ab = a^2 + ab - 2ab
2a^2 - 2ab = a^2 - ab
2(a^2 - ab) = a^2 - ab
2 = 1

A king is throwing a party in 24 hours and has 1000 bottles of wine. But alas, 10 enemy bandits break into his wine cellar! The king's guards catch the spies, but only after they have poisoned 1 bottle of wine. No one knows which bottle of wine was poisoned, and the poison is such that any amount of poison will kill whoever drinks it in exactly 24 hours. The king has a plan! He will use the 10 bandits (who were going to be executed anyways) to find exactly which bottle of wine was poisoned.

What is the kings plan?

@jonbrennecke
jonbrennecke / env.ps1
Last active March 22, 2017 19:48
Environment Vars in Powershell
// Get env (like `env`)
Get-ChildItem Env:
// Set var (like `export name=value`)
[Environment]::SetEnvironmentVariable("Name", "Value")
// Remove var (like `unset name=value`)
[Environment]::SetEnvironmentVariable("Name", "Value")