This file contains 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
#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; | |
This file contains 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 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; |
This file contains 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
// 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> |
This file contains 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
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() |
This file contains 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
// 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[]) | |
{ |
This file contains 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 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']) |