Skip to content

Instantly share code, notes, and snippets.

View clwyatt's full-sized avatar

Chris Wyatt clwyatt

View GitHub Profile
@clwyatt
clwyatt / ex.cpp
Created April 18, 2020 19:43
Example of logging allocations
#include <iostream>
int main(int argc, char *argv[])
{
int * ip = new int;
std::cout << "Allocated at " << (unsigned long)(ip) << "\n";
// do something with object, e.g.
*ip = 4;
@clwyatt
clwyatt / cntlc_tracer.cpp
Created November 12, 2018 14:33
An example program demonstrating how to handle signals
// This is an example of how to to trap Cntrl-C in a cross-platform manner
// it creates a simple REPL event loop and shows how to interrupt it.
#include <csignal>
#include <cstdlib>
// This global is needed for communication between the signal handler
// and the rest of the code. This atomic integer counts the number of times
// Cntl-C has been pressed by not reset by the REPL code.
volatile sig_atomic_t global_status_flag = 0;
@clwyatt
clwyatt / compare.cpp
Last active April 22, 2020 03:49
Updated Compare Utility for Milestone 1
// compare two wav files
// - check header similarity
// - cross correlation between two signals
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstdint>
#include <string>
#include <vector>
#include <cmath>
@clwyatt
clwyatt / CMakeLists.txt
Created September 6, 2017 01:16
CMake fixes for Milestone 0 ECE 3574 Fall 2017
cmake_minimum_required(VERSION 3.5)
project(SYNTH CXX)
# require a C++11 compiler for all targets
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
endif()
@clwyatt
clwyatt / compare.cpp
Last active September 7, 2017 10:18
Patch to compare.cpp for Milestone 0, ECE 3574 Fall 2017
// byte by byte comparison of two WAV files
// each sample must differ by at most 1
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstdint>
#include <string>
int main(int argc, char *argv[])
{
@clwyatt
clwyatt / gist:4765329
Last active December 12, 2015 11:19
Python development environment setup using virtualenv
import virtualenv, textwrap
output = virtualenv.create_bootstrap_script(textwrap.dedent("""
from os.path import join
from os import getcwd
from subprocess import call
def after_install(options, home_dir):
pip = join(getcwd(), home_dir, 'bin', 'pip')
easy = join(getcwd(), home_dir, 'bin', 'easy_install')
call([pip, 'install', 'numpy'])
call([pip, 'install', 'nibabel'])